From 9634749c48f2d6e27d3205a827023374fc84d311 Mon Sep 17 00:00:00 2001 From: Pierre Gauthier Date: Thu, 22 Feb 2024 18:30:35 +0100 Subject: [PATCH] Clean Code Syntax --- .github/workflows/qa.yml | 2 +- src/Command/StructureClean.php | 2 +- src/Entity/GallyConfiguration.php | 2 +- src/Synchronizer/AbstractSynchronizer.php | 1 - src/Synchronizer/CatalogSynchronizer.php | 4 ++-- src/Synchronizer/SourceFieldOptionSynchronizer.php | 4 +++- src/Synchronizer/SourceFieldSynchronizer.php | 5 ++--- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml index 4487708..52765fd 100644 --- a/.github/workflows/qa.yml +++ b/.github/workflows/qa.yml @@ -20,6 +20,6 @@ jobs: php_extensions: ctype curl dom hash iconv intl gd json mbstring openssl session simplexml xml zip zlib pdo_mysql exif args: --no-plugins - name: Php cs fixer - run: php ./vendor/bin/php-cs-fixer fix --dry-run src + run: php ./vendor/bin/php-cs-fixer fix --diff --dry-run src - name: Phpstan run: php ./vendor/bin/phpstan --memory-limit=1G analyse diff --git a/src/Command/StructureClean.php b/src/Command/StructureClean.php index 5d73aa7..a41dc07 100644 --- a/src/Command/StructureClean.php +++ b/src/Command/StructureClean.php @@ -47,7 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $isQuiet = $input->getOption('quiet'); if ($isDryRun) { - $output->writeln("Running in dry run mode, add -f to really delete entities from Gally."); + $output->writeln('Running in dry run mode, add -f to really delete entities from Gally.'); $output->writeln(''); } diff --git a/src/Entity/GallyConfiguration.php b/src/Entity/GallyConfiguration.php index 433bbf5..93659f9 100644 --- a/src/Entity/GallyConfiguration.php +++ b/src/Entity/GallyConfiguration.php @@ -28,7 +28,7 @@ public function getId(): ?int return $this->id; } - public function setId(int $id = null): void + public function setId(?int $id = null): void { $this->id = $id; } diff --git a/src/Synchronizer/AbstractSynchronizer.php b/src/Synchronizer/AbstractSynchronizer.php index ec1355b..62f04a7 100644 --- a/src/Synchronizer/AbstractSynchronizer.php +++ b/src/Synchronizer/AbstractSynchronizer.php @@ -89,7 +89,6 @@ abstract protected function getIdentity(ModelInterface $entity): string; */ public function cleanAll(bool $dryRun = true, bool $quiet = false): void { - } protected function buildFetchAllParams(int $page): array diff --git a/src/Synchronizer/CatalogSynchronizer.php b/src/Synchronizer/CatalogSynchronizer.php index d4e4829..6b5483e 100644 --- a/src/Synchronizer/CatalogSynchronizer.php +++ b/src/Synchronizer/CatalogSynchronizer.php @@ -122,7 +122,7 @@ public function cleanAll(bool $dryRun = true, bool $quiet = false): void /** @var LocalizedCatalogCatalogRead $localizedCatalog */ $localizedCatalog = $this->localizedCatalogSynchronizer->getEntityFromApi($localizedCatalogCode); if (!$quiet) { - print(" Delete localized catalog {$localizedCatalog->getId()}\n"); + echo " Delete localized catalog {$localizedCatalog->getId()}\n"; } if (!$dryRun) { $this->localizedCatalogSynchronizer->deleteEntity($localizedCatalog->getId()); @@ -133,7 +133,7 @@ public function cleanAll(bool $dryRun = true, bool $quiet = false): void /** @var CatalogCatalogRead $catalog */ $catalog = $this->getEntityFromApi($catalogCode); if (!$quiet) { - print(" Delete catalog {$catalog->getId()}\n"); + echo " Delete catalog {$catalog->getId()}\n"; } if (!$dryRun) { $this->deleteEntity($catalog->getId()); diff --git a/src/Synchronizer/SourceFieldOptionSynchronizer.php b/src/Synchronizer/SourceFieldOptionSynchronizer.php index 447cde6..9351139 100644 --- a/src/Synchronizer/SourceFieldOptionSynchronizer.php +++ b/src/Synchronizer/SourceFieldOptionSynchronizer.php @@ -181,6 +181,7 @@ public function cleanAll(bool $dryRun = true, bool $quiet = false): void $attributes = $this->productAttributeRepository->findAll(); foreach ($attributes as $attribute) { if ('select' === $attribute->getType()) { + /** @var SourceFieldSourceFieldRead $sourceField */ $sourceField = $this->sourceFieldSynchronizer->getEntityByCode($metadata, $attribute->getCode()); $configuration = $attribute->getConfiguration(); foreach ($configuration['choices'] ?? [] as $code => $choice) { @@ -192,6 +193,7 @@ public function cleanAll(bool $dryRun = true, bool $quiet = false): void /** @var ProductOption[] $options */ $options = $this->productOptionRepository->findAll(); foreach ($options as $option) { + /** @var SourceFieldSourceFieldRead $sourceField */ $sourceField = $this->sourceFieldSynchronizer->getEntityByCode($metadata, $option->getCode()); /** @var ProductOptionValueInterface $value */ foreach ($option->getValues() as $value) { @@ -203,7 +205,7 @@ public function cleanAll(bool $dryRun = true, bool $quiet = false): void /** @var SourceFieldOptionSourceFieldOptionRead $sourceFieldOption */ $sourceFieldOption = $this->getEntityFromApi($sourceFieldOptionCode); if (!$quiet) { - print(" Delete sourceFieldOption {$sourceFieldOption->getSourceField()} {$sourceFieldOption->getCode()}\n"); + echo " Delete sourceFieldOption {$sourceFieldOption->getSourceField()} {$sourceFieldOption->getCode()}\n"; } if (!$dryRun) { $this->deleteEntity($sourceFieldOption->getId()); diff --git a/src/Synchronizer/SourceFieldSynchronizer.php b/src/Synchronizer/SourceFieldSynchronizer.php index e48b7d7..ff9432e 100644 --- a/src/Synchronizer/SourceFieldSynchronizer.php +++ b/src/Synchronizer/SourceFieldSynchronizer.php @@ -25,8 +25,6 @@ use Sylius\Component\Product\Model\Product; use Sylius\Component\Product\Model\ProductAttribute; use Sylius\Component\Product\Model\ProductOption; -use Sylius\Component\Product\Model\ProductOptionValueInterface; -use Sylius\Component\Product\Model\ProductOptionValueTranslation; use Sylius\Component\Resource\Repository\RepositoryInterface; /** @@ -144,6 +142,7 @@ public function cleanAll(bool $dryRun = true, bool $quiet = false): void $this->sourceFieldCodes = array_flip($this->getAllEntityCodes()); $metadataName = strtolower((new \ReflectionClass(Product::class))->getShortName()); + /** @var MetadataMetadataRead $metadata */ $metadata = $this->metadataSynchronizer->synchronizeItem(['entity' => $metadataName]); /** @var ProductAttribute[] $attributes */ @@ -162,7 +161,7 @@ public function cleanAll(bool $dryRun = true, bool $quiet = false): void /** @var SourceFieldSourceFieldRead $sourceField */ $sourceField = $this->getEntityFromApi($sourceFieldCode); if (!$sourceField->getIsSystem() && !$quiet) { - print(" Delete sourceField {$sourceField->getMetadata()} {$sourceField->getCode()}\n"); + echo " Delete sourceField {$sourceField->getMetadata()} {$sourceField->getCode()}\n"; } if (!$sourceField->getIsSystem() && !$dryRun) { $this->deleteEntity($sourceField->getId());