Skip to content

Commit

Permalink
Clean Code Syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreGauthier committed Feb 22, 2024
1 parent ef81690 commit 9634749
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/Command/StructureClean.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$isQuiet = $input->getOption('quiet');

if ($isDryRun) {
$output->writeln("<error>Running in dry run mode, add -f to really delete entities from Gally.</error>");
$output->writeln('<error>Running in dry run mode, add -f to really delete entities from Gally.</error>');
$output->writeln('');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/GallyConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion src/Synchronizer/AbstractSynchronizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Synchronizer/CatalogSynchronizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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());
Expand Down
4 changes: 3 additions & 1 deletion src/Synchronizer/SourceFieldOptionSynchronizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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());
Expand Down
5 changes: 2 additions & 3 deletions src/Synchronizer/SourceFieldSynchronizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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 */
Expand All @@ -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());
Expand Down

0 comments on commit 9634749

Please sign in to comment.