Skip to content

Commit

Permalink
chore: phpcs and phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidmattei committed Dec 13, 2024
1 parent 45d5adb commit 325b093
Show file tree
Hide file tree
Showing 28 changed files with 32 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

return self::EXECUTE_ERROR;
}
$results = JSON::decode($httpResponse->getContent());
$results = Json::decode($httpResponse->getContent());
foreach (($results['summaries'] ?? []) as $result) {
$this->io->writeln(\sprintf('%s with %s %s', $result['data'] ?? '', $result['status'] ?? '', $result['uid'] ?? ''));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private function makeResource(?string ...$path): string
return \implode('/', \array_merge($this->endPoint, \array_filter($path)));
}

public function publish(string $ouuid, string $environment, string $revisionId = null): bool
public function publish(string $ouuid, string $environment, ?string $revisionId = null): bool
{
$resource = $this->makeResource('publish', $ouuid, $environment, $revisionId ?? '');
$success = $this->client->post($resource)->getData()['success'] ?? null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function setHeadChunkSize(int $chunkSize): void
$this->headChunkSize = $chunkSize;
}

public function loadArchiveItemsInCache(string $archiveHash, Archive $archive, callable $callback = null): void
public function loadArchiveItemsInCache(string $archiveHash, Archive $archive, ?callable $callback = null): void
{
$admin = new Admin($this->client);
$command = \sprintf('%s %s', Commands::LOAD_ARCHIVE_IN_CACHE, $archiveHash);
Expand Down
6 changes: 0 additions & 6 deletions EMS/common-bundle/src/Common/File/FileReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@

final class FileReader implements FileReaderInterface
{
/**
* {@inheritDoc}
*/
public function getData(string $filename, array $options = []): array
{
$reader = IOFactory::createReaderForFile($filename);
Expand All @@ -34,9 +31,6 @@ public function getData(string $filename, array $options = []): array
return $reader->load($filename)->getActiveSheet()->toArray();
}

/**
* {@inheritDoc}
*/
public function readCells(string $filename, array $options = []): \Generator
{
$isCsv = 0 === \strcasecmp(\pathinfo($filename, PATHINFO_EXTENSION), 'csv');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,5 @@ public function update(string $ouuid, array $rawData): DraftInterface;
*/
public function save(string $ouuid, array $rawData, int $mode = self::MODE_UPDATE, bool $discardDraft = true): int;

public function publish(string $ouuid, string $environment, string $revisionId = null): bool;
public function publish(string $ouuid, string $environment, ?string $revisionId = null): bool;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ public function uploadFile(string $realPath, ?string $mimeType = null, ?string $
*/
public function setHeadChunkSize(int $chunkSize): void;

public function loadArchiveItemsInCache(string $archiveHash, Archive $archive, callable $callback = null): void;
public function loadArchiveItemsInCache(string $archiveHash, Archive $archive, ?callable $callback = null): void;
}
2 changes: 1 addition & 1 deletion EMS/common-bundle/src/Controller/FileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function generateLocalImage(Request $request, string $filename, string $c
return $response;
}

public function assetInArchive(Request $request, string $hash, string $path, int $maxAge = 604800, bool $extract = true, string $indexResource = null, string $notFoundTemplate = null): Response
public function assetInArchive(Request $request, string $hash, string $path, int $maxAge = 604800, bool $extract = true, ?string $indexResource = null, ?string $notFoundTemplate = null): Response
{
$this->closeSession($request);

Expand Down
2 changes: 1 addition & 1 deletion EMS/common-bundle/src/Storage/Archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(private readonly string $hashAlgo)
{
}

public static function fromDirectory(string $directory, string $hashAlgo, callable $callback = null): self
public static function fromDirectory(string $directory, string $hashAlgo, ?callable $callback = null): self
{
$archive = new self($hashAlgo);
$finder = new Finder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public function addFileInArchiveCache(string $hash, SplFileInfo $file, string $m
return false;
}

public function loadArchiveItemsInCache(string $archiveHash, Archive $archive, callable $callback = null): bool
public function loadArchiveItemsInCache(string $archiveHash, Archive $archive, ?callable $callback = null): bool
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion EMS/common-bundle/src/Storage/Service/EntityStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public function addFileInArchiveCache(string $hash, SplFileInfo $file, string $m
return false;
}

public function loadArchiveItemsInCache(string $archiveHash, Archive $archive, callable $callback = null): bool
public function loadArchiveItemsInCache(string $archiveHash, Archive $archive, ?callable $callback = null): bool
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function addFileInArchiveCache(string $hash, SplFileInfo $file, string $m
return \copy($file->getPathname(), $filename);
}

public function loadArchiveItemsInCache(string $archiveHash, Archive $archive, callable $callback = null): bool
public function loadArchiveItemsInCache(string $archiveHash, Archive $archive, ?callable $callback = null): bool
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion EMS/common-bundle/src/Storage/Service/S3Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public function addFileInArchiveCache(string $hash, SplFileInfo $file, string $m
return $result->hasKey('ETag');
}

public function loadArchiveItemsInCache(string $archiveHash, Archive $archive, callable $callback = null): bool
public function loadArchiveItemsInCache(string $archiveHash, Archive $archive, ?callable $callback = null): bool
{
$batch = [];
$client = $this->getS3Client();
Expand Down
2 changes: 1 addition & 1 deletion EMS/common-bundle/src/Storage/Service/StorageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ public function readFromArchiveInCache(string $hash, string $path): ?StreamWrapp

public function addFileInArchiveCache(string $hash, SplFileInfo $file, string $mimeType): bool;

public function loadArchiveItemsInCache(string $archiveHash, Archive $archive, callable $callback = null): bool;
public function loadArchiveItemsInCache(string $archiveHash, Archive $archive, ?callable $callback = null): bool;
}
4 changes: 2 additions & 2 deletions EMS/common-bundle/src/Storage/StorageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ public function saveCache(Config $config, FileInterface $file): void
}
}

public function getStreamFromArchive(string $hash, string $path, bool $extract = true, string $indexResource = null): StreamWrapper
public function getStreamFromArchive(string $hash, string $path, bool $extract = true, ?string $indexResource = null): StreamWrapper
{
if (null !== $indexResource && ('' === $path || \str_ends_with($path, '/'))) {
$path .= $indexResource;
Expand Down Expand Up @@ -701,7 +701,7 @@ public function setHeadChunkSize(int $chunkSize): void
$this->headChunkSize = $chunkSize;
}

public function loadArchiveItemsInCache(string $archiveHash, Archive $archive, callable $callback = null): void
public function loadArchiveItemsInCache(string $archiveHash, Archive $archive, ?callable $callback = null): void
{
foreach ($this->adapters as $adapter) {
if ($adapter->loadArchiveItemsInCache($archiveHash, $archive, $callback)) {
Expand Down
2 changes: 1 addition & 1 deletion EMS/common-bundle/src/Twig/AssetRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public function hash(string $input, ?string $hashAlgo = null, bool $binary = fal
/**
* @param mixed[] $options
*/
public function fileFromArchive(string $hash, string $path, array $options = []): null|string|TempFile
public function fileFromArchive(string $hash, string $path, array $options = []): string|TempFile|null
{
$extract = Type::bool($options['extract'] ?? true);
$asTempFile = Type::bool($options['asTempFile'] ?? false);
Expand Down
2 changes: 1 addition & 1 deletion EMS/core-bundle/src/Command/CleanAssetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Doctrine\Bundle\DoctrineBundle\Registry;
use Doctrine\ORM\EntityManager;
use EMS\CoreBundle\Commands;
use EMS\CommonBundle\Common\Command\AbstractCommand;
use EMS\CoreBundle\Commands;
use EMS\CoreBundle\Entity\Revision;
use EMS\CoreBundle\Entity\UploadedAsset;
use EMS\CoreBundle\Repository\RevisionRepository;
Expand Down
2 changes: 1 addition & 1 deletion EMS/core-bundle/src/Command/Submission/ExportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ExportCommand extends AbstractCommand
/** @var string[] */
private array $fields;
private ?string $filter;
private ?string $filename;
private ?string $filename;

public function __construct(
private readonly FormSubmissionService $formSubmissionService,
Expand Down
2 changes: 1 addition & 1 deletion EMS/core-bundle/src/Command/UpdateMetaFieldCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Doctrine\Bundle\DoctrineBundle\Registry;
use Doctrine\ORM\EntityManager;
use EMS\CoreBundle\Commands;
use EMS\CommonBundle\Common\Command\AbstractCommand;
use EMS\CoreBundle\Commands;
use EMS\CoreBundle\Entity\Environment;
use EMS\CoreBundle\Entity\Revision;
use EMS\CoreBundle\Exception\NotLockedException;
Expand Down
6 changes: 3 additions & 3 deletions EMS/core-bundle/src/Controller/Api/Data/PublishController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(
) {
}

public function publish(string $contentTypeName, string $ouuid, string $targetEnvironmentName, Revision $revision = null): JsonResponse
public function publish(string $contentTypeName, string $ouuid, string $targetEnvironmentName, ?Revision $revision = null): JsonResponse
{
if (null === $revision) {
$contentType = $this->contentTypeService->giveByName($contentTypeName);
Expand All @@ -44,8 +44,8 @@ public function publish(string $contentTypeName, string $ouuid, string $targetEn
}

return new JsonResponse([
'success' => true,
'already-published' => 0 === $publishedCounter,
'success' => true,
'already-published' => 0 === $publishedCounter,
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace EMS\CoreBundle\Controller\Wysiwyg;

use EMS\CommonBundle\Common\EMSLink;
use EMS\ClientHelperBundle\Helper\Asset\AssetHelperRuntime;
use EMS\CommonBundle\Common\EMSLink;
use EMS\CoreBundle\Entity\WysiwygStylesSet;
use EMS\CoreBundle\Service\WysiwygStylesSetService;
use EMS\Helpers\File\File;
Expand Down
4 changes: 2 additions & 2 deletions EMS/core-bundle/src/Form/DataField/AssetFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ public function generateMapping(FieldType $current): array
EmsFields::CONTENT_FILE_SIZE_FIELD => $this->elasticsearchService->getLongMapping(),
EmsFields::CONTENT_FILE_SIZE_FIELD_ => $this->elasticsearchService->getLongMapping(),
EmsFields::CONTENT_IMAGE_RESIZED_HASH_FIELD => $this->elasticsearchService->getKeywordMapping(),
EmsFields::CONTENT_FILE_TITLE => $mapping[$current->getName()],
],
EmsFields::CONTENT_FILE_TITLE => $mapping[$current->getName()],
],
], \array_filter($current->getMappingOptions())),
];
}
Expand Down
2 changes: 1 addition & 1 deletion EMS/core-bundle/src/Form/DataField/ContainerFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function buildOptionsForm(FormBuilderInterface $builder, array $options):
$optionsForm->get('displayOptions')
->add('icon', IconPickerType::class, ['required' => false])
->add('language', ChoiceType::class, [
'required' => false,
'required' => false,
'choices' => \array_flip(Locales::getNames()),
'choice_translation_domain' => false,
])
Expand Down
3 changes: 0 additions & 3 deletions EMS/core-bundle/src/Form/DataField/TabsFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ public function configureOptions(OptionsResolver $resolver): void
$resolver->setDefault(self::LOCALE_PREFERRED_FIRST_DISPLAY_OPTION, false);
}

/**
* {@inheritDoc}
*/
public static function isVirtual(array $option = []): bool
{
return true;
Expand Down
2 changes: 1 addition & 1 deletion EMS/core-bundle/src/Form/DataField/WysiwygFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function reverseViewTransform($data, FieldType $fieldType): DataField
$out = \preg_replace_callback(
'/('.\preg_quote(\substr($path, 0, \strlen($path) - 7), '/').')(?P<key>[^\n\r"\'\?]*)/i',
fn ($matches) => 'ems://'.$matches['key'],
$out
Type::string($out)
);

if ('' === $out) {
Expand Down
2 changes: 1 addition & 1 deletion EMS/core-bundle/src/Form/Extension/LocaleFormExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function configureOptions(OptionsResolver $resolver): void
{
$resolver
->setDefaults(['locale' => null])
->setNormalizer('locale', function (Options $options, null|string|array $value) {
->setNormalizer('locale', function (Options $options, string|array|null $value) {
try {
$language = $options['language'] ?? null;

Expand Down
1 change: 0 additions & 1 deletion EMS/core-bundle/src/Form/Field/EnvironmentPickerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace EMS\CoreBundle\Form\Field;

use EMS\CoreBundle\Entity\Environment;
use EMS\CoreBundle\Form\DataTransformer\EntityNameModelTransformer;
use EMS\CoreBundle\Service\EnvironmentService;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
Expand Down
8 changes: 4 additions & 4 deletions EMS/core-bundle/src/Form/Field/FilterOptionsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ class FilterOptionsType extends AbstractType
'asciifolding' => [
'preserve_original',
],
'synonym' => [
'synonyms',
],
'synonym' => [
'synonyms',
],
];

/**
Expand All @@ -54,7 +54,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'Stemmer' => 'stemmer',
'Elision' => 'elision',
'ASCII Folding' => 'asciifolding',
'Synonym' => 'synonym',
'Synonym' => 'synonym',
],
'attr' => [
'class' => 'fields-to-display-by-input-value',
Expand Down
2 changes: 1 addition & 1 deletion EMS/core-bundle/src/Service/Revision/RevisionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public function getByEmsLink(EMSLink $emsLink, ?\DateTimeInterface $dateTime = n
return $this->get($emsLink->getOuuid(), $emsLink->getContentType(), $dateTime);
}

private function resolveEmsLink(EMSLink $emsLink): null|Revision|DocumentInterface
private function resolveEmsLink(EMSLink $emsLink): Revision|DocumentInterface|null
{
if (!$emsLink->isValid()) {
return null;
Expand Down

0 comments on commit 325b093

Please sign in to comment.