From 8c829115e46011a1ae857875ec55cd5fb9552486 Mon Sep 17 00:00:00 2001 From: Nicolas MELONI Date: Mon, 26 Jul 2021 08:45:07 +0200 Subject: [PATCH] fix ecs --- ruleset/ecs.php | 13 +++-- ...etricProductAttributeValueValueBuilder.php | 2 +- ...electProductAttributeValueValueBuilder.php | 2 +- ...erenceEntityAttributeValueValueBuilder.php | 2 +- ...electProductAttributeValueValueBuilder.php | 2 +- .../TextProductAttributeValueValueBuilder.php | 2 +- src/Controller/AttributesController.php | 8 ++-- src/Controller/ProductsController.php | 2 +- ...AkeneoAttributeTypeMatcherCompilerPass.php | 2 +- ...AttributeValueValueBuilderCompilerPass.php | 2 +- ...entityAttributeTypeMatcherCompilerPass.php | 2 +- .../Compiler/AkeneoTaskCompilerPass.php | 2 +- .../SynoliaSyliusAkeneoExtension.php | 10 ++-- src/Entity/ApiConfiguration.php | 4 +- src/Entity/ProductConfiguration.php | 8 ++-- src/Entity/ProductFiltersRules.php | 8 ++-- src/Entity/ProductGroup.php | 4 +- src/Filter/ProductFilter.php | 24 ++++++---- .../ReferenceEntityDataTransformer.php | 4 +- src/Form/Type/ApiConfigurationType.php | 8 +++- src/Form/Type/AttributeCodeChoiceType.php | 2 +- src/Form/Type/AttributeTypeChoiceType.php | 4 +- src/Form/Type/AttributesTypeMappingType.php | 18 +++++-- src/Form/Type/CategoriesChoiceType.php | 4 +- src/Form/Type/CategoriesConfigurationType.php | 4 +- src/Form/Type/ChannelChoiceType.php | 4 +- src/Form/Type/CompletenessTypeChoiceType.php | 4 +- src/Form/Type/ProductConfigurationType.php | 8 +++- .../Type/ProductFilterRuleAdvancedType.php | 4 +- src/Form/Type/ProductFilterRuleSimpleType.php | 4 +- src/Form/Type/ProductImageAttributesType.php | 8 +++- src/Form/Type/ProductImagesMappingType.php | 12 +++-- src/Form/Type/SettingsType.php | 14 +++--- src/Logger/Messages.php | 20 ++++---- src/Manager/ProductOptionManager.php | 12 +++-- src/Manager/SettingsManager.php | 12 +++-- src/Payload/AbstractPayload.php | 2 +- .../AbstractModelAkeneoAttributeProcessor.php | 4 +- ...oductAttributeAkeneoAttributeProcessor.php | 10 ++-- .../ProductModelAkeneoAttributeProcessor.php | 4 +- ...anslationModelAkeneoAttributeProcessor.php | 12 ++--- ...ctVariantModelAkeneoAttributeProcessor.php | 10 ++-- ...anslationModelAkeneoAttributeProcessor.php | 4 +- .../FamilyVariationAxeProcessor.php | 13 ++--- .../AkeneoAttributeProcessorProvider.php | 2 +- .../AkeneoAttributePropertiesProvider.php | 2 +- ...renceEntityAttributePropertiesProvider.php | 2 +- src/Provider/AkeneoTaskProvider.php | 2 +- ...tityAttributeValueValueBuilderProvider.php | 2 +- src/Repository/ProductAttributeRepository.php | 2 +- src/Repository/ProductOptionRepository.php | 2 +- src/Retriever/FamilyRetriever.php | 4 +- src/Service/ProductChannelEnabler.php | 12 +++-- .../SyliusAkeneoLocaleCodeProvider.php | 10 ++-- .../Association/AddAssociationTypeTask.php | 4 +- .../CreateProductAssociationTask.php | 16 +++++-- .../Association/RetrieveAssociationTask.php | 2 +- src/Task/Attribute/CreateUpdateEntityTask.php | 8 ++-- src/Task/Attribute/DeleteEntityTask.php | 2 +- .../AbstractAttributeOptionTask.php | 8 ++-- .../CreateUpdateDeleteTask.php | 4 +- .../AttributeOption/RetrieveOptionsTask.php | 8 ++-- src/Task/Category/CreateUpdateEntityTask.php | 10 ++-- src/Task/Category/RetrieveCategoriesTask.php | 18 +++---- src/Task/Option/CreateUpdateTask.php | 8 ++-- .../Product/AbstractCreateProductEntities.php | 12 +++-- .../AbstractInsertProductImageTask.php | 12 +++-- .../Product/AddProductToCategoriesTask.php | 9 +++- .../CreateConfigurableProductEntitiesTask.php | 38 +++++++++------ .../CreateSimpleProductEntitiesTask.php | 14 +++--- .../Product/EnableDisableProductsTask.php | 8 ++-- src/Task/Product/RetrieveProductsTask.php | 4 +- src/Task/Product/SetupProductTask.php | 2 +- .../AddOrUpdateProductModelTask.php | 24 ++++++---- .../ProductModel/AddProductGroupsTask.php | 8 ++-- .../EnableDisableProductModelsTask.php | 8 ++-- .../RetrieveProductModelsTask.php | 4 +- src/Task/ProductModel/SetupProductTask.php | 2 +- .../Attribute/AttributeTypeMatcher.php | 2 +- .../ReferenceEntityAttributeTypeMatcher.php | 2 +- tests/PHPUnit/Api/ApiTestCase.php | 8 ++-- tests/PHPUnit/Api/GetCategoriesTest.php | 4 +- tests/PHPUnit/Api/GetProductsTest.php | 2 +- tests/PHPUnit/Client/ClientFactory.php | 2 +- .../EventSubscriber/AfterTaskSubscriber.php | 2 +- .../EventSubscriber/BeforeTaskSubscriber.php | 2 +- tests/PHPUnit/Filter/ProductFilterTest.php | 2 +- .../AkeneoAttributeDataProviderTest.php | 26 +++++----- .../PHPUnit/Retriever/FamilyRetrieverTest.php | 4 +- .../Task/Attribute/AbstractTaskTest.php | 4 +- .../Attribute/CreateUpdateDeleteTaskTest.php | 12 +++-- .../Attribute/RetrieveAttributesTaskTest.php | 2 +- .../Task/AttributeOption/AbstractTaskTest.php | 10 ++-- .../CreateUpdateDeleteTaskTest.php | 29 +++++------ .../RetrieveOptionsTaskTest.php | 2 +- .../Task/Category/AbstractTaskTest.php | 2 +- .../Category/CreateUpdateDeleteTaskTest.php | 10 ++-- .../Category/RetrieveCategoriesTaskTest.php | 2 +- .../PHPUnit/Task/Product/AbstractTaskTest.php | 38 +++++++-------- ...ateConfigurableProductEntitiesTaskTest.php | 6 ++- .../CreateSimpleProductEntitiesTaskTest.php | 48 +++++++++++-------- .../Product/EnableDisableProductTaskTest.php | 12 +++-- .../Task/ProductModel/AbstractTaskTest.php | 12 ++--- .../AddFamilyVariationAxeTaskTest.php | 12 +++-- .../AddOrUpdateProductModelTaskTest.php | 12 +++-- .../EnableDisableProductModelTaskTest.php | 10 ++-- .../Task/ProductOption/AbstractTaskTest.php | 12 ++--- .../ProductOption/CreateUpdateTaskTest.php | 36 +++++++------- .../Task/ProductOption/DeleteTaskTest.php | 4 +- 109 files changed, 533 insertions(+), 375 deletions(-) diff --git a/ruleset/ecs.php b/ruleset/ecs.php index aefa65a5..33a8d58f 100644 --- a/ruleset/ecs.php +++ b/ruleset/ecs.php @@ -17,11 +17,14 @@ dirname(__DIR__, 1) . '/spec', ]); - $parameters->set(Option::SETS, [ - SetList::SYMFONY, - SetList::PHP_73_MIGRATION, - SetList::PHP_CS_FIXER, - ]); + $containerConfigurator->import(SetList::PSR_12); + $containerConfigurator->import(SetList::PHP_CS_FIXER); + $containerConfigurator->import(SetList::SYMFONY); + $containerConfigurator->import(SetList::SYMFONY_RISKY); + $containerConfigurator->import(SetList::DOCTRINE_ANNOTATIONS); + $containerConfigurator->import(SetList::ARRAY); + $containerConfigurator->import(SetList::CLEAN_CODE); + $parameters->set(Option::SKIP, [ PhpCsFixer\Fixer\Whitespace\MethodChainingIndentationFixer::class => [ dirname(__DIR__, 1) . '/src/*/*Configuration*.php', diff --git a/src/Builder/Attribute/MetricProductAttributeValueValueBuilder.php b/src/Builder/Attribute/MetricProductAttributeValueValueBuilder.php index e692171b..a2f560ac 100644 --- a/src/Builder/Attribute/MetricProductAttributeValueValueBuilder.php +++ b/src/Builder/Attribute/MetricProductAttributeValueValueBuilder.php @@ -34,6 +34,6 @@ public function support(string $attributeCode): bool */ public function build(string $attributeCode, ?string $locale, ?string $scope, $value) { - return \trim(implode(' ', $value)); + return trim(implode(' ', $value)); } } diff --git a/src/Builder/Attribute/MultiSelectProductAttributeValueValueBuilder.php b/src/Builder/Attribute/MultiSelectProductAttributeValueValueBuilder.php index 2d243019..2ff40534 100644 --- a/src/Builder/Attribute/MultiSelectProductAttributeValueValueBuilder.php +++ b/src/Builder/Attribute/MultiSelectProductAttributeValueValueBuilder.php @@ -36,7 +36,7 @@ public function support(string $attributeCode): bool public function build(string $attributeCode, ?string $locale, ?string $scope, $values) { foreach ($values as $key => $value) { - $values[$key] = CreateUpdateDeleteTask::AKENEO_PREFIX . $value; + $values[$key] = CreateUpdateDeleteTask::AKENEO_PREFIX.$value; } return $values; diff --git a/src/Builder/Attribute/ReferenceEntityAttributeValueValueBuilder.php b/src/Builder/Attribute/ReferenceEntityAttributeValueValueBuilder.php index 5159342a..76056aaf 100644 --- a/src/Builder/Attribute/ReferenceEntityAttributeValueValueBuilder.php +++ b/src/Builder/Attribute/ReferenceEntityAttributeValueValueBuilder.php @@ -106,7 +106,7 @@ public function build(string $attributeCode, ?string $locale, ?string $scope, $v MissingScopeException | TranslationNotFoundException $exception ) { - $this->akeneoLogger->debug(\sprintf( + $this->akeneoLogger->debug(sprintf( 'Skipped attribute value "%s" for reference entity "%s" with value "%s" for locale "%s" and scope "%s"', $subAttributeCode, $referenceEntityAttributeProperties['reference_data_name'], diff --git a/src/Builder/Attribute/SelectProductAttributeValueValueBuilder.php b/src/Builder/Attribute/SelectProductAttributeValueValueBuilder.php index 20a9c546..277d438f 100644 --- a/src/Builder/Attribute/SelectProductAttributeValueValueBuilder.php +++ b/src/Builder/Attribute/SelectProductAttributeValueValueBuilder.php @@ -35,6 +35,6 @@ public function support(string $attributeCode): bool */ public function build(string $attributeCode, ?string $locale, ?string $scope, $value) { - return [CreateUpdateDeleteTask::AKENEO_PREFIX . $value]; + return [CreateUpdateDeleteTask::AKENEO_PREFIX.$value]; } } diff --git a/src/Builder/Attribute/TextProductAttributeValueValueBuilder.php b/src/Builder/Attribute/TextProductAttributeValueValueBuilder.php index 662fb194..852bf105 100644 --- a/src/Builder/Attribute/TextProductAttributeValueValueBuilder.php +++ b/src/Builder/Attribute/TextProductAttributeValueValueBuilder.php @@ -38,6 +38,6 @@ public function support(string $attributeCode): bool */ public function build(string $attributeCode, ?string $locale, ?string $scope, $value) { - return \trim((string) $value); + return trim((string) $value); } } diff --git a/src/Controller/AttributesController.php b/src/Controller/AttributesController.php index ece5a474..69e8ec8f 100644 --- a/src/Controller/AttributesController.php +++ b/src/Controller/AttributesController.php @@ -74,7 +74,9 @@ public function __invoke(Request $request): Response /** @var AttributeAkeneoSyliusMapping[] $attributeAkeneoSyliusMappings */ $attributeAkeneoSyliusMappings = $this->attributeAkeneoSyliusMappingRepository->findAll(); - $settings = ['import_referential_attributes' => SettingType::AKENEO_SETTINGS['import_referential_attributes']]; + $settings = [ + 'import_referential_attributes' => SettingType::AKENEO_SETTINGS['import_referential_attributes'], + ]; foreach ($settings as $key => $value) { $settings[$key] = $this->settingsManager->get($key); } @@ -117,13 +119,13 @@ private function removeRemovedMappedItemsFromFormRequest( array $attributeAkeneoSyliusMappings ): void { foreach ($attributeTypeMappings as $attributeTypeMapping) { - if (false === \array_search($attributeTypeMapping, $attributes[AttributesTypeMappingType::ATTRIBUTE_TYPE_MAPPINGS_CODE], true)) { + if (false === array_search($attributeTypeMapping, $attributes[AttributesTypeMappingType::ATTRIBUTE_TYPE_MAPPINGS_CODE], true)) { $this->entityManager->remove($attributeTypeMapping); } } foreach ($attributeAkeneoSyliusMappings as $attributeAkeneoSyliusMapping) { - if (false === \array_search($attributeAkeneoSyliusMapping, $attributes[AttributesTypeMappingType::ATTRIBUTE_AKENEO_SYLIUS_MAPPINGS_CODE], true)) { + if (false === array_search($attributeAkeneoSyliusMapping, $attributes[AttributesTypeMappingType::ATTRIBUTE_AKENEO_SYLIUS_MAPPINGS_CODE], true)) { $this->entityManager->remove($attributeAkeneoSyliusMapping); } } diff --git a/src/Controller/ProductsController.php b/src/Controller/ProductsController.php index ff37b589..8e02c5dc 100644 --- a/src/Controller/ProductsController.php +++ b/src/Controller/ProductsController.php @@ -90,7 +90,7 @@ private function removeElements(?Collection $productConfiguration, ?Collection $ } foreach ($productConfiguration as $defaultTax) { - if (false === \array_search($defaultTax, $productConfigurationData->toArray(), true)) { + if (false === array_search($defaultTax, $productConfigurationData->toArray(), true)) { $this->entityManager->remove($defaultTax); } } diff --git a/src/DependencyInjection/Compiler/AkeneoAttributeTypeMatcherCompilerPass.php b/src/DependencyInjection/Compiler/AkeneoAttributeTypeMatcherCompilerPass.php index 882db1ec..de48d634 100644 --- a/src/DependencyInjection/Compiler/AkeneoAttributeTypeMatcherCompilerPass.php +++ b/src/DependencyInjection/Compiler/AkeneoAttributeTypeMatcherCompilerPass.php @@ -17,7 +17,7 @@ public function process(ContainerBuilder $container): void $definition = $container->getDefinition(AttributeTypeMatcher::class); $taggedServices = $container->findTaggedServiceIds(AttributeTypeMatcherInterface::TAG_ID); - foreach (\array_keys($taggedServices) as $id) { + foreach (array_keys($taggedServices) as $id) { $definition->addMethodCall('addTypeMatcher', [new Reference($id)]); } } diff --git a/src/DependencyInjection/Compiler/AkeneoAttributeValueValueBuilderCompilerPass.php b/src/DependencyInjection/Compiler/AkeneoAttributeValueValueBuilderCompilerPass.php index 8091a7aa..0b076377 100644 --- a/src/DependencyInjection/Compiler/AkeneoAttributeValueValueBuilderCompilerPass.php +++ b/src/DependencyInjection/Compiler/AkeneoAttributeValueValueBuilderCompilerPass.php @@ -17,7 +17,7 @@ public function process(ContainerBuilder $container): void $definition = $container->getDefinition(ProductAttributeValueValueBuilder::class); $taggedServices = $container->findTaggedServiceIds(ProductAttributeValueValueBuilderInterface::TAG_ID); - foreach (\array_keys($taggedServices) as $id) { + foreach (array_keys($taggedServices) as $id) { $definition->addMethodCall('addBuilder', [new Reference($id)]); } } diff --git a/src/DependencyInjection/Compiler/AkeneoReferenceentityAttributeTypeMatcherCompilerPass.php b/src/DependencyInjection/Compiler/AkeneoReferenceentityAttributeTypeMatcherCompilerPass.php index e8662c14..4af76792 100644 --- a/src/DependencyInjection/Compiler/AkeneoReferenceentityAttributeTypeMatcherCompilerPass.php +++ b/src/DependencyInjection/Compiler/AkeneoReferenceentityAttributeTypeMatcherCompilerPass.php @@ -17,7 +17,7 @@ public function process(ContainerBuilder $container): void $definition = $container->getDefinition(ReferenceEntityAttributeTypeMatcher::class); $taggedServices = $container->findTaggedServiceIds(ReferenceEntityAttributeTypeMatcherInterface::TAG_ID); - foreach (\array_keys($taggedServices) as $id) { + foreach (array_keys($taggedServices) as $id) { $definition->addMethodCall('addTypeMatcher', [new Reference($id)]); } } diff --git a/src/DependencyInjection/Compiler/AkeneoTaskCompilerPass.php b/src/DependencyInjection/Compiler/AkeneoTaskCompilerPass.php index ee8828a5..566c3fbd 100644 --- a/src/DependencyInjection/Compiler/AkeneoTaskCompilerPass.php +++ b/src/DependencyInjection/Compiler/AkeneoTaskCompilerPass.php @@ -21,7 +21,7 @@ public function process(ContainerBuilder $container): void $definition = $container->getDefinition(AkeneoTaskProvider::class); $taggedServices = $container->findTaggedServiceIds(AkeneoTaskInterface::TAG_ID); - foreach (\array_keys($taggedServices) as $id) { + foreach (array_keys($taggedServices) as $id) { $definition->addMethodCall('addTask', [new Reference($id)]); } } diff --git a/src/DependencyInjection/SynoliaSyliusAkeneoExtension.php b/src/DependencyInjection/SynoliaSyliusAkeneoExtension.php index c91eaf34..aaa5bc26 100644 --- a/src/DependencyInjection/SynoliaSyliusAkeneoExtension.php +++ b/src/DependencyInjection/SynoliaSyliusAkeneoExtension.php @@ -20,23 +20,25 @@ final class SynoliaSyliusAkeneoExtension extends Extension implements PrependExt */ public function load(array $config, ContainerBuilder $container): void { - $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); + $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yaml'); } public function prepend(ContainerBuilder $container): void { - $container->prependExtensionConfig('monolog', ['channels' => ['akeneo']]); + $container->prependExtensionConfig('monolog', [ + 'channels' => ['akeneo'], + ]); if (!$container->hasExtension('twig')) { return; } - $viewsPath = dirname(__DIR__) . '/Resources/views/'; + $viewsPath = \dirname(__DIR__).'/Resources/views/'; // This add our override in twig paths with correct namespace. No need for final user to copy it $paths = [ - $viewsPath . 'SyliusAttributeBundle' => 'SyliusAttribute', + $viewsPath.'SyliusAttributeBundle' => 'SyliusAttribute', ]; $container->prependExtensionConfig('twig', [ diff --git a/src/Entity/ApiConfiguration.php b/src/Entity/ApiConfiguration.php index f7bb4630..5c9dc990 100644 --- a/src/Entity/ApiConfiguration.php +++ b/src/Entity/ApiConfiguration.php @@ -53,8 +53,8 @@ class ApiConfiguration implements ResourceInterface * @var int * @ORM\Column(type="integer") * @Assert\Range( - * min = ApiConfiguration::MIN_AKENEO_PAGINATION_SIZE, - * max = ApiConfiguration::MAX_AKENEO_PAGINATION_SIZE, + * min=ApiConfiguration::MIN_AKENEO_PAGINATION_SIZE, + * max=ApiConfiguration::MAX_AKENEO_PAGINATION_SIZE, * ) */ private $paginationSize = self::DEFAULT_PAGINATION_SIZE; diff --git a/src/Entity/ProductConfiguration.php b/src/Entity/ProductConfiguration.php index c7d1a0ff..414d6734 100644 --- a/src/Entity/ProductConfiguration.php +++ b/src/Entity/ProductConfiguration.php @@ -78,16 +78,16 @@ class ProductConfiguration implements ResourceInterface /** * @var bool - * @ORM\Column(name="enable_imported_products", type="boolean", options={"default" = 0}) + * @ORM\Column(name="enable_imported_products", type="boolean", options={"default"=0}) */ private $enableImportedProducts = false; /** * @var ChannelInterface[]|Collection - * @ORM\ManyToMany (targetEntity=ChannelInterface::class) + * @ORM\ManyToMany(targetEntity=ChannelInterface::class) * @ORM\JoinTable(name="akeneo_product_configuration_channels", - * joinColumns={@ORM\JoinColumn(name="product_configuration_id", referencedColumnName="id")}, - * inverseJoinColumns={@ORM\JoinColumn(name="channel_id", referencedColumnName="id", unique=true)} + * joinColumns={@ORM\JoinColumn(name="product_configuration_id", referencedColumnName="id")}, + * inverseJoinColumns={@ORM\JoinColumn(name="channel_id", referencedColumnName="id", unique=true)} * ) */ private $channelsToEnable; diff --git a/src/Entity/ProductFiltersRules.php b/src/Entity/ProductFiltersRules.php index 065542eb..33e300de 100644 --- a/src/Entity/ProductFiltersRules.php +++ b/src/Entity/ProductFiltersRules.php @@ -148,7 +148,7 @@ public function getLocales(): array public function addLocale(string $locale): self { - if (in_array($locale, $this->locales)) { + if (\in_array($locale, $this->locales)) { return $this; } @@ -161,7 +161,7 @@ public function addLocale(string $locale): self public function removeLocale(string $locale): self { - if (!in_array($locale, $this->locales)) { + if (!\in_array($locale, $this->locales)) { return $this; } @@ -251,7 +251,7 @@ public function getExcludeFamilies(): array public function addExcludeFamily(string $excludeFamily): self { - if (in_array($excludeFamily, $this->excludeFamilies)) { + if (\in_array($excludeFamily, $this->excludeFamilies)) { return $this; } @@ -264,7 +264,7 @@ public function addExcludeFamily(string $excludeFamily): self public function removeExcludeFamily(string $excludeFamily): self { - if (!in_array($excludeFamily, $this->excludeFamilies)) { + if (!\in_array($excludeFamily, $this->excludeFamilies)) { return $this; } diff --git a/src/Entity/ProductGroup.php b/src/Entity/ProductGroup.php index dd632ef0..51c1d2c4 100644 --- a/src/Entity/ProductGroup.php +++ b/src/Entity/ProductGroup.php @@ -82,7 +82,7 @@ public function getVariationAxes(): array public function addVariationAxe(string $variationAxe): self { - if (in_array($variationAxe, $this->variationAxes)) { + if (\in_array($variationAxe, $this->variationAxes)) { return $this; } @@ -93,7 +93,7 @@ public function addVariationAxe(string $variationAxe): self public function removeVariationAxe(string $variationAxe): self { - if (!in_array($variationAxe, $this->variationAxes)) { + if (!\in_array($variationAxe, $this->variationAxes)) { return $this; } diff --git a/src/Filter/ProductFilter.php b/src/Filter/ProductFilter.php index 1050ead9..cd45dbfe 100644 --- a/src/Filter/ProductFilter.php +++ b/src/Filter/ProductFilter.php @@ -65,7 +65,10 @@ public function getProductModelFilters(): array $queryParameters = $this->getExcludeFamiliesFilter($productFilterRules, $queryParameters); $queryParameters = $queryParameters->getFilters(); - $queryParameters = ['search' => $queryParameters, 'scope' => $productFilterRules->getChannel()]; + $queryParameters = [ + 'search' => $queryParameters, + 'scope' => $productFilterRules->getChannel(), + ]; } if (ProductFilterRuleAdvancedType::MODE === $productFilterRules->getMode() && !empty($productFilterRules->getAdvancedFilter())) { @@ -98,7 +101,10 @@ public function getProductFilters(): array $queryParameters = $this->getExcludeFamiliesFilter($productFilterRules, $queryParameters); $queryParameters = $this->getStatus($productFilterRules, $queryParameters); $queryParameters = $queryParameters->getFilters(); - $queryParameters = ['search' => $queryParameters, 'scope' => $productFilterRules->getChannel()]; + $queryParameters = [ + 'search' => $queryParameters, + 'scope' => $productFilterRules->getChannel(), + ]; } if (ProductFilterRuleAdvancedType::MODE === $productFilterRules->getMode() && !empty($productFilterRules->getAdvancedFilter())) { @@ -129,7 +135,7 @@ private function getAdvancedFilter(ProductFiltersRules $productFilterRules, bool } parse_str($productFilterRules->getAdvancedFilter(), $advancedFilter); - if (!array_key_exists('search', $advancedFilter)) { + if (!\array_key_exists('search', $advancedFilter)) { return $advancedFilter; } @@ -155,10 +161,10 @@ private function getProductModelCompletenessTypeAdvancedFilter(array $filter): a private function getProductModelAdvancedFilter(array $advancedFilter): array { $advancedFilter['search'] = array_filter($advancedFilter['search'], static function (string $key): bool { - return in_array($key, self::AVAILABLE_PRODUCT_MODEL_QUERIES); - }, \ARRAY_FILTER_USE_KEY); + return \in_array($key, self::AVAILABLE_PRODUCT_MODEL_QUERIES); + }, ARRAY_FILTER_USE_KEY); - if (array_key_exists('completeness', $advancedFilter['search']) && is_array($advancedFilter['search']['completeness'])) { + if (\array_key_exists('completeness', $advancedFilter['search']) && \is_array($advancedFilter['search']['completeness'])) { $advancedFilter = $this->getProductModelCompletenessTypeAdvancedFilter($advancedFilter); } @@ -218,7 +224,7 @@ private function getExcludeFamiliesFilter(ProductFiltersRules $productFilterRule private function getLocales(ProductFiltersRules $productFilterRules): array { - if (in_array($productFilterRules->getCompletenessType(), [ + if (\in_array($productFilterRules->getCompletenessType(), [ Operator::LOWER_THAN_ON_ALL_LOCALES, Operator::GREATER_THAN_ON_ALL_LOCALES, Operator::LOWER_OR_EQUALS_THAN_ON_ALL_LOCALES, @@ -241,7 +247,7 @@ private function getCompletenessFilter( return $queryParameters; } - if (in_array($completenessType, [ + if (\in_array($completenessType, [ Operator::LOWER_THAN_ON_ALL_LOCALES, Operator::GREATER_THAN_ON_ALL_LOCALES, Operator::LOWER_OR_EQUALS_THAN_ON_ALL_LOCALES, @@ -265,7 +271,7 @@ private function getCompletenessFilter( $completeness, $completenessValue, [ - 'locales' => in_array($completeness, [self::AT_LEAST_COMPLETE, self::ALL_COMPLETE]) ? $this->getLocales($productFilterRules) : [], + 'locales' => \in_array($completeness, [self::AT_LEAST_COMPLETE, self::ALL_COMPLETE]) ? $this->getLocales($productFilterRules) : [], 'scope' => $productFilterRules->getChannel(), ] ); diff --git a/src/Form/DataTransformer/ReferenceEntityDataTransformer.php b/src/Form/DataTransformer/ReferenceEntityDataTransformer.php index a2ea795d..28b7c5b1 100644 --- a/src/Form/DataTransformer/ReferenceEntityDataTransformer.php +++ b/src/Form/DataTransformer/ReferenceEntityDataTransformer.php @@ -11,7 +11,7 @@ class ReferenceEntityDataTransformer implements DataTransformerInterface { public function transform($value): string { - $json = \json_encode($value); + $json = json_encode($value); if (false === $json) { throw new ReferenceEntityTransformException('Could not transform reference entity array to json.'); @@ -22,6 +22,6 @@ public function transform($value): string public function reverseTransform($value): ?array { - return \json_decode($value, true); + return json_decode($value, true); } } diff --git a/src/Form/Type/ApiConfigurationType.php b/src/Form/Type/ApiConfigurationType.php index 42bb0510..34b89a10 100644 --- a/src/Form/Type/ApiConfigurationType.php +++ b/src/Form/Type/ApiConfigurationType.php @@ -47,11 +47,15 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'label' => 'sylius.ui.admin.akeneo.api_configuration.is_enterprise', ]) ->add('testCredentials', SubmitType::class, [ - 'attr' => ['class' => 'ui secondary button'], + 'attr' => [ + 'class' => 'ui secondary button', + ], ]) ->add('submit', SubmitType::class, [ 'label' => 'sylius.ui.save', - 'attr' => ['class' => 'ui primary button'], + 'attr' => [ + 'class' => 'ui primary button', + ], ]) ; } diff --git a/src/Form/Type/AttributeCodeChoiceType.php b/src/Form/Type/AttributeCodeChoiceType.php index 0068413a..33fb9e9d 100644 --- a/src/Form/Type/AttributeCodeChoiceType.php +++ b/src/Form/Type/AttributeCodeChoiceType.php @@ -49,7 +49,7 @@ public function configureOptions(OptionsResolver $resolver): void $attributes = []; foreach ($attributePayload->getResources() as $attributeResource) { - $attributes[($attributeResource['labels'][$this->localeContext->getLocaleCode()]) ?? \current($attributeResource['labels'])] = $attributeResource['code']; + $attributes[($attributeResource['labels'][$this->localeContext->getLocaleCode()]) ?? current($attributeResource['labels'])] = $attributeResource['code']; } $resolver->setDefaults([ diff --git a/src/Form/Type/AttributeTypeChoiceType.php b/src/Form/Type/AttributeTypeChoiceType.php index bc72e3d4..1c3d358c 100644 --- a/src/Form/Type/AttributeTypeChoiceType.php +++ b/src/Form/Type/AttributeTypeChoiceType.php @@ -23,7 +23,9 @@ public function __construct(array $attributeTypes) */ public function configureOptions(OptionsResolver $resolver): void { - $resolver->setDefault('choices', array_merge($this->attributeTypes, ['multiselect' => 'multiselect'])); + $resolver->setDefault('choices', array_merge($this->attributeTypes, [ + 'multiselect' => 'multiselect', + ])); } /** diff --git a/src/Form/Type/AttributesTypeMappingType.php b/src/Form/Type/AttributesTypeMappingType.php index 90157d99..ac604b18 100644 --- a/src/Form/Type/AttributesTypeMappingType.php +++ b/src/Form/Type/AttributesTypeMappingType.php @@ -28,7 +28,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ]) ->add(self::ATTRIBUTE_TYPE_MAPPINGS_CODE, CollectionType::class, [ 'entry_type' => AttributeTypeMappingType::class, - 'entry_options' => ['label' => false], + 'entry_options' => [ + 'label' => false, + ], 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, @@ -36,7 +38,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ]) ->add(self::ATTRIBUTE_AKENEO_SYLIUS_MAPPINGS_CODE, CollectionType::class, [ 'entry_type' => AttributeAkeneoSyliusMappingType::class, - 'entry_options' => ['label' => false], + 'entry_options' => [ + 'label' => false, + ], 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, @@ -44,13 +48,19 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ]) ->add('submit', SubmitType::class, [ 'label' => 'sylius.ui.save', - 'attr' => ['class' => 'ui primary button'], + 'attr' => [ + 'class' => 'ui primary button', + ], ]) ; } public function configureOptions(OptionsResolver $resolver): void { - $resolver->setDefaults(['data' => ['settings' => []]]); + $resolver->setDefaults([ + 'data' => [ + 'settings' => [], + ], + ]); } } diff --git a/src/Form/Type/CategoriesChoiceType.php b/src/Form/Type/CategoriesChoiceType.php index b5c3c9f9..f58dc535 100644 --- a/src/Form/Type/CategoriesChoiceType.php +++ b/src/Form/Type/CategoriesChoiceType.php @@ -50,7 +50,9 @@ public function configureOptions(OptionsResolver $resolver): void $categories[$item['code']] = $item['code']; } - $resolver->setDefaults(['choices' => $categories]); + $resolver->setDefaults([ + 'choices' => $categories, + ]); } public function getParent() diff --git a/src/Form/Type/CategoriesConfigurationType.php b/src/Form/Type/CategoriesConfigurationType.php index 01d3558f..a3f1f8f6 100644 --- a/src/Form/Type/CategoriesConfigurationType.php +++ b/src/Form/Type/CategoriesConfigurationType.php @@ -27,7 +27,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'multiple' => true, ]) ->add('submit', SubmitType::class, [ - 'attr' => ['class' => 'ui icon primary button'], + 'attr' => [ + 'class' => 'ui icon primary button', + ], 'label' => 'sylius.ui.admin.akeneo.save', ]) ; diff --git a/src/Form/Type/ChannelChoiceType.php b/src/Form/Type/ChannelChoiceType.php index a030cdf3..2be0730a 100644 --- a/src/Form/Type/ChannelChoiceType.php +++ b/src/Form/Type/ChannelChoiceType.php @@ -28,7 +28,9 @@ public function configureOptions(OptionsResolver $resolver): void $channel[$item['code']] = $item['code']; } - $resolver->setDefaults(['choices' => $channel]); + $resolver->setDefaults([ + 'choices' => $channel, + ]); } public function getParent(): string diff --git a/src/Form/Type/CompletenessTypeChoiceType.php b/src/Form/Type/CompletenessTypeChoiceType.php index 59425fef..0807ac9f 100644 --- a/src/Form/Type/CompletenessTypeChoiceType.php +++ b/src/Form/Type/CompletenessTypeChoiceType.php @@ -25,7 +25,9 @@ public function configureOptions(OptionsResolver $resolver): void 'sylius.ui.admin.akeneo.product_filter_rules.lower_or_equals_than_on_all_locales' => Operator::LOWER_OR_EQUALS_THAN_ON_ALL_LOCALES, ]; - $resolver->setDefaults(['choices' => $completenessType]); + $resolver->setDefaults([ + 'choices' => $completenessType, + ]); } public function getParent() diff --git a/src/Form/Type/ProductConfigurationType.php b/src/Form/Type/ProductConfigurationType.php index 41661ec9..c7de0631 100644 --- a/src/Form/Type/ProductConfigurationType.php +++ b/src/Form/Type/ProductConfigurationType.php @@ -44,7 +44,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ->add(self::AKENEO_IMAGE_ATTRIBUTES_MAPPINGS_CODE, CollectionType::class, [ 'required' => true, 'entry_type' => ProductImageAttributesType::class, - 'entry_options' => ['label' => false], + 'entry_options' => [ + 'label' => false, + ], 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, @@ -52,7 +54,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ->add(self::PRODUCT_IMAGES_MAPPINGS_CODE, CollectionType::class, [ 'required' => true, 'entry_type' => ProductImagesMappingType::class, - 'entry_options' => ['label' => false], + 'entry_options' => [ + 'label' => false, + ], 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, diff --git a/src/Form/Type/ProductFilterRuleAdvancedType.php b/src/Form/Type/ProductFilterRuleAdvancedType.php index 62d5dec1..af419904 100644 --- a/src/Form/Type/ProductFilterRuleAdvancedType.php +++ b/src/Form/Type/ProductFilterRuleAdvancedType.php @@ -29,7 +29,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ]) ->add('submit', SubmitType::class, [ 'label' => 'sylius.ui.save', - 'attr' => ['class' => 'ui primary button'], + 'attr' => [ + 'class' => 'ui primary button', + ], ]) ; } diff --git a/src/Form/Type/ProductFilterRuleSimpleType.php b/src/Form/Type/ProductFilterRuleSimpleType.php index 5affae68..1e1e349f 100644 --- a/src/Form/Type/ProductFilterRuleSimpleType.php +++ b/src/Form/Type/ProductFilterRuleSimpleType.php @@ -87,7 +87,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ]) ->add('submit', SubmitType::class, [ 'label' => 'sylius.ui.save', - 'attr' => ['class' => 'ui primary button'], + 'attr' => [ + 'class' => 'ui primary button', + ], ]) ; } diff --git a/src/Form/Type/ProductImageAttributesType.php b/src/Form/Type/ProductImageAttributesType.php index d6031f50..8c3d25e2 100644 --- a/src/Form/Type/ProductImageAttributesType.php +++ b/src/Form/Type/ProductImageAttributesType.php @@ -17,12 +17,16 @@ final class ProductImageAttributesType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options): void { $builder - ->add('akeneoAttributes', AttributeCodeChoiceType::class, ['label' => 'sylius.ui.admin.akeneo.products.akeneo_attributes']) + ->add('akeneoAttributes', AttributeCodeChoiceType::class, [ + 'label' => 'sylius.ui.admin.akeneo.products.akeneo_attributes', + ]) ; } public function configureOptions(OptionsResolver $resolver): void { - $resolver->setDefaults(['data_class' => ProductConfigurationAkeneoImageAttribute::class]); + $resolver->setDefaults([ + 'data_class' => ProductConfigurationAkeneoImageAttribute::class, + ]); } } diff --git a/src/Form/Type/ProductImagesMappingType.php b/src/Form/Type/ProductImagesMappingType.php index b1066c55..66959cca 100644 --- a/src/Form/Type/ProductImagesMappingType.php +++ b/src/Form/Type/ProductImagesMappingType.php @@ -18,13 +18,19 @@ final class ProductImagesMappingType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options): void { $builder - ->add('syliusAttribute', TextType::class, ['label' => 'sylius.ui.admin.akeneo.products.sylius_attribute']) - ->add('akeneoAttribute', AttributeCodeChoiceType::class, ['label' => 'sylius.ui.admin.akeneo.products.akeneo_attribute']) + ->add('syliusAttribute', TextType::class, [ + 'label' => 'sylius.ui.admin.akeneo.products.sylius_attribute', + ]) + ->add('akeneoAttribute', AttributeCodeChoiceType::class, [ + 'label' => 'sylius.ui.admin.akeneo.products.akeneo_attribute', + ]) ; } public function configureOptions(OptionsResolver $resolver): void { - $resolver->setDefaults(['data_class' => ProductConfigurationImageMapping::class]); + $resolver->setDefaults([ + 'data_class' => ProductConfigurationImageMapping::class, + ]); } } diff --git a/src/Form/Type/SettingsType.php b/src/Form/Type/SettingsType.php index 881c8832..bd8eface 100644 --- a/src/Form/Type/SettingsType.php +++ b/src/Form/Type/SettingsType.php @@ -16,7 +16,7 @@ final class SettingsType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options): void { - $entries = \array_keys($options['data']); + $entries = array_keys($options['data']); foreach ($entries as $name) { $configuration = SettingType::AKENEO_SETTINGS[$name]; // If setting's value exist in data and setting isn't disabled @@ -29,8 +29,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void if (!empty($fieldOptions['constraints']) && \is_array($fieldOptions['constraints'])) { $constraints = []; foreach ($fieldOptions['constraints'] as $class => $constraintOptions) { - if (!\class_exists($class)) { - throw new \InvalidArgumentException(\sprintf('Constraint class "%s" not found', $class)); + if (!class_exists($class)) { + throw new \InvalidArgumentException(sprintf('Constraint class "%s" not found', $class)); } $constraints[] = new $class($constraintOptions); } @@ -39,16 +39,16 @@ public function buildForm(FormBuilderInterface $builder, array $options): void } // Label I18n - $fieldOptions['label'] = 'sylius.ui.admin.akeneo.' . $name; + $fieldOptions['label'] = 'sylius.ui.admin.akeneo.'.$name; $fieldOptions['translation_domain'] = 'messages'; // Choices I18n if (!empty($fieldOptions['choices'])) { - $fieldOptions['choices'] = \array_map( + $fieldOptions['choices'] = array_map( static function ($label) use ($fieldOptions) { - return $fieldOptions['label'] . '_choices.' . $label; + return $fieldOptions['label'].'_choices.'.$label; }, - \array_combine($fieldOptions['choices'], $fieldOptions['choices']) + array_combine($fieldOptions['choices'], $fieldOptions['choices']) ); } $builder->add($name, $fieldType, $fieldOptions); diff --git a/src/Logger/Messages.php b/src/Logger/Messages.php index da0c998b..61453dc5 100644 --- a/src/Logger/Messages.php +++ b/src/Logger/Messages.php @@ -16,42 +16,42 @@ public static function commandAlreadyRunning(): string public static function endOfCommand(string $command): string { - return \sprintf('End of : %s', $command); + return sprintf('End of : %s', $command); } public static function retrieveFromAPI(string $type): string { - return \sprintf('Retrieve %s from Akeneo API', $type); + return sprintf('Retrieve %s from Akeneo API', $type); } public static function totalToImport(string $type, int $value): string { - return \sprintf('Total %s to import %d', $type, $value); + return sprintf('Total %s to import %d', $type, $value); } public static function noCodeToImport(string $type, int $value): string { - return \sprintf('%d %s do not have a code and will not be imported.', $value, $type); + return sprintf('%d %s do not have a code and will not be imported.', $value, $type); } public static function removalNoLongerExist(string $type): string { - return \sprintf('Removal of %s which no longer exist.', $type); + return sprintf('Removal of %s which no longer exist.', $type); } public static function countOfDeleted(string $type, int $value): string { - return \sprintf('%s : %d Delete', $type, $value); + return sprintf('%s : %d Delete', $type, $value); } public static function countCreateAndUpdate(string $type, int $create, int $update): string { - return \sprintf('%s : %d Create, %d Update', $type, $create, $update); + return sprintf('%s : %d Create, %d Update', $type, $create, $update); } public static function countCreateAndExist(string $type, int $create, int $exist): string { - return \sprintf('%s : %d Create, %d Already exist', $type, $create, $exist); + return sprintf('%s : %d Create, %d Already exist', $type, $create, $exist); } public static function hasBeenDeleted(string $type, string $code): string @@ -61,7 +61,7 @@ public static function hasBeenDeleted(string $type, string $code): string public static function createOrUpdate(string $type): string { - return \sprintf('Create or update %s.', $type); + return sprintf('Create or update %s.', $type); } public static function hasBeenCreated(string $type, string $code): string @@ -96,6 +96,6 @@ public static function noConfigurationSet(string $config, string $for): string public static function totalExcludedFromImport(string $type, int $value): string { - return \sprintf('Total %s excluded from import %d', $type, $value); + return sprintf('Total %s excluded from import %d', $type, $value); } } diff --git a/src/Manager/ProductOptionManager.php b/src/Manager/ProductOptionManager.php index fbbb3012..4040b796 100644 --- a/src/Manager/ProductOptionManager.php +++ b/src/Manager/ProductOptionManager.php @@ -85,7 +85,9 @@ public function __construct( public function getProductOptionFromAttribute(AttributeInterface $attribute): ?ProductOptionInterface { - return $this->productOptionRepository->findOneBy(['code' => $attribute->getCode()]); + return $this->productOptionRepository->findOneBy([ + 'code' => $attribute->getCode(), + ]); } public function createProductOptionFromAttribute(AttributeInterface $attribute): ProductOptionInterface @@ -108,7 +110,7 @@ public static function getOptionValueCodeFromProductOption( ProductOptionInterface $productOption, string $optionValueCode ): string { - return \strtolower(\sprintf('%s_%s', (string) $productOption->getCode(), $optionValueCode)); + return strtolower(sprintf('%s_%s', (string) $productOption->getCode(), $optionValueCode)); } private function updateTranslationsFromAttribute(ProductOptionInterface $productOption, AttributeInterface $attribute): void @@ -158,7 +160,7 @@ private function updateProductOptionValues(ProductOptionInterface $productOption } $productOptionValuesMapping = []; - $productOptionValueCodes = \array_keys($attribute->getConfiguration()['choices']); + $productOptionValueCodes = array_keys($attribute->getConfiguration()['choices']); foreach ($productOptionValueCodes as $productOptionValueCode) { if (isset($productOptionValuesMapping[(string) $productOptionValueCode])) { continue; @@ -195,8 +197,8 @@ private function updateProductOptionValueTranslations( foreach ($translations as $locale => $translation) { if (null === $translation) { - $translation = \sprintf('[%s]', $productOptionValueCode); - $this->akeneoLogger->warning(\sprintf( + $translation = sprintf('[%s]', $productOptionValueCode); + $this->akeneoLogger->warning(sprintf( 'Missing translation on choice "%s" for option %s, defaulted to "%s"', $productOptionValueCode, $attribute->getCode(), diff --git a/src/Manager/SettingsManager.php b/src/Manager/SettingsManager.php index 6deaf58d..790a1034 100644 --- a/src/Manager/SettingsManager.php +++ b/src/Manager/SettingsManager.php @@ -29,12 +29,14 @@ public function __construct(EntityManagerInterface $entityManager) public function get(string $name, $default = null) { /** @var Setting $setting */ - $setting = $this->entityManager->getRepository(Setting::class)->findOneBy(['name' => $name]); + $setting = $this->entityManager->getRepository(Setting::class)->findOneBy([ + 'name' => $name, + ]); if (!$setting instanceof Setting) { return $default; } - return \json_decode($setting->getValue(), true); + return json_decode($setting->getValue(), true); } /** @@ -43,13 +45,15 @@ public function get(string $name, $default = null) public function set(string $name, $value): SettingsManagerInterface { /** @var Setting $setting */ - $setting = $this->entityManager->getRepository(Setting::class)->findOneBy(['name' => $name]); + $setting = $this->entityManager->getRepository(Setting::class)->findOneBy([ + 'name' => $name, + ]); if (!$setting instanceof Setting) { $setting = new Setting($name); $this->entityManager->persist($setting); } - $setting->setValue(\json_encode($value)); + $setting->setValue(json_encode($value)); $this->entityManager->flush($setting); return $this; diff --git a/src/Payload/AbstractPayload.php b/src/Payload/AbstractPayload.php index 35583092..eb9b061a 100644 --- a/src/Payload/AbstractPayload.php +++ b/src/Payload/AbstractPayload.php @@ -44,7 +44,7 @@ public function setOutputInterface(OutputInterface $outputInterface): PipelinePa public function getType(): string { try { - return \mb_substr((new ReflectionClass($this))->getShortName(), 0, -7); + return mb_substr((new ReflectionClass($this))->getShortName(), 0, -7); } catch (\ReflectionException $e) { return ''; } diff --git a/src/Processor/ProductAttribute/AbstractModelAkeneoAttributeProcessor.php b/src/Processor/ProductAttribute/AbstractModelAkeneoAttributeProcessor.php index 23ae809a..859fe1d0 100644 --- a/src/Processor/ProductAttribute/AbstractModelAkeneoAttributeProcessor.php +++ b/src/Processor/ProductAttribute/AbstractModelAkeneoAttributeProcessor.php @@ -51,7 +51,7 @@ public function __construct( public function process(string $attributeCode, array $context = []): void { - $this->logger->debug(\sprintf( + $this->logger->debug(sprintf( 'Attribute "%s" is beeing processed by "%s"', $attributeCode, static::class @@ -80,7 +80,7 @@ public function process(string $attributeCode, array $context = []): void */ public function support(string $attributeCode, array $context = []): bool { - return \method_exists( + return method_exists( $this->model, $this->getSetterMethodFromAttributeCode($attributeCode) ); diff --git a/src/Processor/ProductAttribute/ProductAttributeAkeneoAttributeProcessor.php b/src/Processor/ProductAttribute/ProductAttributeAkeneoAttributeProcessor.php index b3d8aa86..d813d4de 100644 --- a/src/Processor/ProductAttribute/ProductAttributeAkeneoAttributeProcessor.php +++ b/src/Processor/ProductAttribute/ProductAttributeAkeneoAttributeProcessor.php @@ -71,7 +71,9 @@ public function support(string $attributeCode, array $context = []): bool $transformedAttributeCode = $this->akeneoAttributeToSyliusAttributeTransformer->transform((string) $attributeCode); /** @var AttributeInterface $attribute */ - $attribute = $this->productAttributeRepository->findOneBy(['code' => $transformedAttributeCode]); + $attribute = $this->productAttributeRepository->findOneBy([ + 'code' => $transformedAttributeCode, + ]); if (!$attribute instanceof AttributeInterface || null === $attribute->getType()) { return false; @@ -86,7 +88,7 @@ public function support(string $attributeCode, array $context = []): bool public function process(string $attributeCode, array $context = []): void { - $this->logger->debug(\sprintf( + $this->logger->debug(sprintf( 'Attribute "%s" is beeing processed by "%s"', $attributeCode, static::class @@ -99,7 +101,9 @@ public function process(string $attributeCode, array $context = []): void $transformedAttributeCode = $this->akeneoAttributeToSyliusAttributeTransformer->transform((string) $attributeCode); /** @var AttributeInterface $attribute */ - $attribute = $this->productAttributeRepository->findOneBy(['code' => $transformedAttributeCode]); + $attribute = $this->productAttributeRepository->findOneBy([ + 'code' => $transformedAttributeCode, + ]); foreach ($context['data'] as $translation) { if (null !== $translation['locale'] && false === $this->syliusAkeneoLocaleCodeProvider->isActiveLocale($translation['locale'])) { diff --git a/src/Processor/ProductAttribute/ProductModelAkeneoAttributeProcessor.php b/src/Processor/ProductAttribute/ProductModelAkeneoAttributeProcessor.php index 73bf2481..9e6c42c1 100644 --- a/src/Processor/ProductAttribute/ProductModelAkeneoAttributeProcessor.php +++ b/src/Processor/ProductAttribute/ProductModelAkeneoAttributeProcessor.php @@ -39,9 +39,9 @@ public static function getDefaultPriority(): int protected function getSetterMethodFromAttributeCode(string $attributeCode): string { - return $this->camelCaseToSnakeCaseNameConverter->denormalize(\sprintf( + return $this->camelCaseToSnakeCaseNameConverter->denormalize(sprintf( 'set%s%s', - \ucfirst($attributeCode), + ucfirst($attributeCode), self::CUSTOM_PROPERTIES_SUFFIX )); } diff --git a/src/Processor/ProductAttribute/ProductTranslationModelAkeneoAttributeProcessor.php b/src/Processor/ProductAttribute/ProductTranslationModelAkeneoAttributeProcessor.php index 19ffbc2b..415d8b17 100644 --- a/src/Processor/ProductAttribute/ProductTranslationModelAkeneoAttributeProcessor.php +++ b/src/Processor/ProductAttribute/ProductTranslationModelAkeneoAttributeProcessor.php @@ -41,7 +41,7 @@ public static function getDefaultPriority(): int public function support(string $attributeCode, array $context = []): bool { - return \method_exists( + return method_exists( $this->model, $this->getSetterMethodFromAttributeCode($attributeCode) ) && $context['model'] instanceof ProductInterface; @@ -50,17 +50,17 @@ public function support(string $attributeCode, array $context = []): bool protected function getSetterMethodFromAttributeCode(string $attributeCode): string { if (\in_array($this->camelCaseToSnakeCaseNameConverter->normalize($attributeCode), self::NATIVE_PROPERTIES) || - in_array($this->camelCaseToSnakeCaseNameConverter->denormalize($attributeCode), self::NATIVE_PROPERTIES) + \in_array($this->camelCaseToSnakeCaseNameConverter->denormalize($attributeCode), self::NATIVE_PROPERTIES) ) { - return $this->camelCaseToSnakeCaseNameConverter->denormalize(\sprintf( + return $this->camelCaseToSnakeCaseNameConverter->denormalize(sprintf( 'set%s', - \ucfirst($attributeCode) + ucfirst($attributeCode) )); } - return $this->camelCaseToSnakeCaseNameConverter->denormalize(\sprintf( + return $this->camelCaseToSnakeCaseNameConverter->denormalize(sprintf( 'set%s%s', - \ucfirst($attributeCode), + ucfirst($attributeCode), self::CUSTOM_PROPERTIES_SUFFIX )); } diff --git a/src/Processor/ProductAttribute/ProductVariantModelAkeneoAttributeProcessor.php b/src/Processor/ProductAttribute/ProductVariantModelAkeneoAttributeProcessor.php index 58849db0..ac76bb3b 100644 --- a/src/Processor/ProductAttribute/ProductVariantModelAkeneoAttributeProcessor.php +++ b/src/Processor/ProductAttribute/ProductVariantModelAkeneoAttributeProcessor.php @@ -50,17 +50,17 @@ public static function getDefaultPriority(): int protected function getSetterMethodFromAttributeCode(string $attributeCode): string { if (\in_array($this->camelCaseToSnakeCaseNameConverter->normalize($attributeCode), self::NATIVE_PROPERTIES) || - in_array($this->camelCaseToSnakeCaseNameConverter->denormalize($attributeCode), self::NATIVE_PROPERTIES) + \in_array($this->camelCaseToSnakeCaseNameConverter->denormalize($attributeCode), self::NATIVE_PROPERTIES) ) { - return $this->camelCaseToSnakeCaseNameConverter->denormalize(\sprintf( + return $this->camelCaseToSnakeCaseNameConverter->denormalize(sprintf( 'set%s', - \ucfirst($attributeCode) + ucfirst($attributeCode) )); } - return $this->camelCaseToSnakeCaseNameConverter->denormalize(\sprintf( + return $this->camelCaseToSnakeCaseNameConverter->denormalize(sprintf( 'set%s%s', - \ucfirst($attributeCode), + ucfirst($attributeCode), self::CUSTOM_PROPERTIES_SUFFIX )); } diff --git a/src/Processor/ProductAttribute/ProductVariantTranslationModelAkeneoAttributeProcessor.php b/src/Processor/ProductAttribute/ProductVariantTranslationModelAkeneoAttributeProcessor.php index 0a875e35..78abb3c9 100644 --- a/src/Processor/ProductAttribute/ProductVariantTranslationModelAkeneoAttributeProcessor.php +++ b/src/Processor/ProductAttribute/ProductVariantTranslationModelAkeneoAttributeProcessor.php @@ -39,9 +39,9 @@ public static function getDefaultPriority(): int protected function getSetterMethodFromAttributeCode(string $attributeCode): string { - return $this->camelCaseToSnakeCaseNameConverter->denormalize(\sprintf( + return $this->camelCaseToSnakeCaseNameConverter->denormalize(sprintf( 'set%s%s', - \ucfirst($attributeCode), + ucfirst($attributeCode), self::CUSTOM_PROPERTIES_SUFFIX )); } diff --git a/src/Processor/ProductGroup/FamilyVariationAxeProcessor.php b/src/Processor/ProductGroup/FamilyVariationAxeProcessor.php index 3638131b..39501ba1 100644 --- a/src/Processor/ProductGroup/FamilyVariationAxeProcessor.php +++ b/src/Processor/ProductGroup/FamilyVariationAxeProcessor.php @@ -12,6 +12,8 @@ class FamilyVariationAxeProcessor { + /** @var int */ + public $itemCount = 0; /** @var AkeneoPimEnterpriseClientInterface */ private $akeneoPimEnterpriseClient; @@ -24,9 +26,6 @@ class FamilyVariationAxeProcessor /** @var LoggerInterface */ private $logger; - /** @var int */ - public $itemCount = 0; - public function __construct( AkeneoPimEnterpriseClientInterface $akeneoPimEnterpriseClient, EntityRepository $productGroupRepository, @@ -41,7 +40,9 @@ public function __construct( public function process(array $resource, array $familiesVariantPayloads = []): array { - $productGroup = $this->productGroupRepository->findOneBy(['productParent' => $resource['code']]); + $productGroup = $this->productGroupRepository->findOneBy([ + 'productParent' => $resource['code'], + ]); if (!$productGroup instanceof ProductGroup) { return $familiesVariantPayloads; } @@ -78,14 +79,14 @@ private function addAxes( ProductGroup $productGroup ): void { foreach ($familiesVariantPayloads[$resource['family_variant']]['variant_attribute_sets'] as $variantAttributeSet) { - if (count($familiesVariantPayloads[$resource['family_variant']]['variant_attribute_sets']) !== $variantAttributeSet['level']) { + if (\count($familiesVariantPayloads[$resource['family_variant']]['variant_attribute_sets']) !== $variantAttributeSet['level']) { continue; } foreach ($variantAttributeSet['axes'] as $axe) { $productGroup->addVariationAxe($axe); ++$this->itemCount; - $this->logger->info(\sprintf( + $this->logger->info(sprintf( 'Added axe "%s" to product group "%s" for family "%s"', $axe, $productGroup->getProductParent(), diff --git a/src/Provider/AkeneoAttributeProcessorProvider.php b/src/Provider/AkeneoAttributeProcessorProvider.php index d6593823..3407f08b 100644 --- a/src/Provider/AkeneoAttributeProcessorProvider.php +++ b/src/Provider/AkeneoAttributeProcessorProvider.php @@ -30,6 +30,6 @@ public function getProcessor(string $attributeCode, array $context = []): Akeneo } } - throw new MissingAkeneoAttributeProcessorException(\sprintf('Could not find an AkeneoAttributeProcessor for attribute %s', $attributeCode)); + throw new MissingAkeneoAttributeProcessorException(sprintf('Could not find an AkeneoAttributeProcessor for attribute %s', $attributeCode)); } } diff --git a/src/Provider/AkeneoAttributePropertiesProvider.php b/src/Provider/AkeneoAttributePropertiesProvider.php index 0e9e154f..562d8cb4 100644 --- a/src/Provider/AkeneoAttributePropertiesProvider.php +++ b/src/Provider/AkeneoAttributePropertiesProvider.php @@ -67,7 +67,7 @@ public function getLabel(string $attributeCode, ?string $locale): string { $labels = $this->getLabels($attributeCode); if (null === $locale || !isset($labels[$locale])) { - return \current($labels); + return current($labels); } return $labels[$locale]; diff --git a/src/Provider/AkeneoReferenceEntityAttributePropertiesProvider.php b/src/Provider/AkeneoReferenceEntityAttributePropertiesProvider.php index 55c4003e..056fd3fa 100644 --- a/src/Provider/AkeneoReferenceEntityAttributePropertiesProvider.php +++ b/src/Provider/AkeneoReferenceEntityAttributePropertiesProvider.php @@ -67,7 +67,7 @@ public function getLabel(string $referenceEntityCode, string $referenceEntityAtt { $labels = $this->getLabels($referenceEntityCode, $referenceEntityAttributeCode); if (null === $locale || !isset($labels[$locale])) { - return \current($labels); + return current($labels); } return $labels[$locale]; diff --git a/src/Provider/AkeneoTaskProvider.php b/src/Provider/AkeneoTaskProvider.php index 231f2016..3237a6e6 100644 --- a/src/Provider/AkeneoTaskProvider.php +++ b/src/Provider/AkeneoTaskProvider.php @@ -19,7 +19,7 @@ public function addTask(AkeneoTaskInterface $akeneoTask): void public function get(string $taskClassName): AkeneoTaskInterface { if (!\array_key_exists($taskClassName, $this->tasks)) { - throw new \RuntimeException('Unable to find task ' . $taskClassName); + throw new \RuntimeException('Unable to find task '.$taskClassName); } return $this->tasks[$taskClassName]; diff --git a/src/Provider/ProductRefEntityAttributeValueValueBuilderProvider.php b/src/Provider/ProductRefEntityAttributeValueValueBuilderProvider.php index d7c8857d..0648b158 100644 --- a/src/Provider/ProductRefEntityAttributeValueValueBuilderProvider.php +++ b/src/Provider/ProductRefEntityAttributeValueValueBuilderProvider.php @@ -40,6 +40,6 @@ public function getProcessor( } } - throw new MissingAkeneoAttributeProcessorException(\sprintf('Could not find an AkeneoAttributeProcessor for attribute %s', $attributeCode)); + throw new MissingAkeneoAttributeProcessorException(sprintf('Could not find an AkeneoAttributeProcessor for attribute %s', $attributeCode)); } } diff --git a/src/Repository/ProductAttributeRepository.php b/src/Repository/ProductAttributeRepository.php index aaa8026b..b05fef17 100644 --- a/src/Repository/ProductAttributeRepository.php +++ b/src/Repository/ProductAttributeRepository.php @@ -58,7 +58,7 @@ public function getAllAttributeCodes(): array return []; } - return \array_map(function (array $data) { + return array_map(function (array $data) { return $data['code']; }, $attributeCodesResult); } diff --git a/src/Repository/ProductOptionRepository.php b/src/Repository/ProductOptionRepository.php index b9fb4fc1..a348e8c2 100644 --- a/src/Repository/ProductOptionRepository.php +++ b/src/Repository/ProductOptionRepository.php @@ -29,7 +29,7 @@ public function getRemovedOptionIds(array $codes): array return []; } - return \array_map(function (array $data) { + return array_map(function (array $data) { return $data['id']; }, $removedOptionResults); } diff --git a/src/Retriever/FamilyRetriever.php b/src/Retriever/FamilyRetriever.php index 96c715ff..72a5a48d 100644 --- a/src/Retriever/FamilyRetriever.php +++ b/src/Retriever/FamilyRetriever.php @@ -34,7 +34,7 @@ public function __construct( public function getFamilyCodeByVariantCode(string $familyVariantCode): string { - if (array_key_exists($familyVariantCode, $this->familiesByVariant)) { + if (\array_key_exists($familyVariantCode, $this->familiesByVariant)) { return $this->familiesByVariant[$familyVariantCode]; } @@ -54,7 +54,7 @@ public function getFamilyCodeByVariantCode(string $familyVariantCode): string } } - if (array_key_exists($familyVariantCode, $this->familiesByVariant)) { + if (\array_key_exists($familyVariantCode, $this->familiesByVariant)) { return $this->familiesByVariant[$familyVariantCode]; } } catch (\Throwable $exception) { diff --git a/src/Service/ProductChannelEnabler.php b/src/Service/ProductChannelEnabler.php index b1e9decb..258fdfb8 100644 --- a/src/Service/ProductChannelEnabler.php +++ b/src/Service/ProductChannelEnabler.php @@ -71,7 +71,7 @@ public function enableChannelForProduct(ProductInterface $product, array $resour private function addProductToChannel(ProductInterface $product, ChannelInterface $channel): void { $product->addChannel($channel); - $this->logger->info(\sprintf( + $this->logger->info(sprintf( 'Enabled channel "%s" for product "%s"', $channel->getCode(), $product->getCode() @@ -108,10 +108,10 @@ private function getEnabledChannelsAttributeData( throw new \LogicException('Enabled channels attribute is empty.'); } - return \current($attributeValue)['data']; + return current($attributeValue)['data']; } - throw new NoAttributeResourcesException(\sprintf('Enabled channels attribute not found for product "%s".', $product->getCode())); + throw new NoAttributeResourcesException(sprintf('Enabled channels attribute not found for product "%s".', $product->getCode())); } private function handleByAkeneoEnabledChannelsAttribute( @@ -128,9 +128,11 @@ private function handleByAkeneoEnabledChannelsAttribute( $enabledChannels = $this->getEnabledChannelsAttributeData($productConfiguration, $product, $resource); foreach ($enabledChannels as $enabledChannel) { - $channel = $this->channelRepository->findOneBy(['code' => $enabledChannel]); + $channel = $this->channelRepository->findOneBy([ + 'code' => $enabledChannel, + ]); if (!$channel instanceof ChannelInterface) { - $this->logger->warning(\sprintf( + $this->logger->warning(sprintf( 'Channel "%s" could not be activated for product "%s" because the channel was not found in the database.', $enabledChannel, $product->getCode() diff --git a/src/Service/SyliusAkeneoLocaleCodeProvider.php b/src/Service/SyliusAkeneoLocaleCodeProvider.php index c6d49ab6..d1d8bf09 100644 --- a/src/Service/SyliusAkeneoLocaleCodeProvider.php +++ b/src/Service/SyliusAkeneoLocaleCodeProvider.php @@ -34,7 +34,7 @@ public function getUsedLocalesOnBothPlatforms(): array } foreach ($this->getUsedLocalesOnAkeneo() as $apiLocale) { - if (false === $apiLocale['enabled'] || !in_array($apiLocale['code'], $this->getUsedLocalesOnSylius(), true)) { + if (false === $apiLocale['enabled'] || !\in_array($apiLocale['code'], $this->getUsedLocalesOnSylius(), true)) { continue; } $this->localesCode[$apiLocale['code']] = $apiLocale['code']; @@ -48,11 +48,11 @@ public function getUsedLocalesOnBothPlatforms(): array */ public function isLocaleDataTranslation(AttributeInterface $attribute, $data, string $locale): bool { - if (is_array($data)) { + if (\is_array($data)) { return $data['locale'] === $locale; } - if (isset($attribute->getConfiguration()['choices'][$data]) && array_key_exists($locale, $attribute->getConfiguration()['choices'][$data])) { + if (isset($attribute->getConfiguration()['choices'][$data]) && \array_key_exists($locale, $attribute->getConfiguration()['choices'][$data])) { return true; } @@ -63,7 +63,7 @@ public function isActiveLocale(string $locale): bool { $locales = $this->getUsedLocalesOnBothPlatforms(); - return in_array($locale, $locales, true); + return \in_array($locale, $locales, true); } private function getUsedLocalesOnAkeneo(): ResourceCursorInterface @@ -76,7 +76,7 @@ private function getUsedLocalesOnSylius(): array $locales = []; /** @var \Sylius\Component\Core\Model\ChannelInterface $channel */ foreach ($this->channelRepository->findAll() as $channel) { - $locales = \array_unique(\array_merge($locales, $channel + $locales = array_unique(array_merge($locales, $channel ->getLocales() ->map(function (LocaleInterface $locale) { return (string) $locale->getCode(); diff --git a/src/Task/Association/AddAssociationTypeTask.php b/src/Task/Association/AddAssociationTypeTask.php index 37659097..45380623 100644 --- a/src/Task/Association/AddAssociationTypeTask.php +++ b/src/Task/Association/AddAssociationTypeTask.php @@ -53,7 +53,9 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte } foreach ($resources->getItems() as $resource) { - $productAssociationType = $this->productAssociationTypeRepository->findOneBy(['code' => $resource['code']]); + $productAssociationType = $this->productAssociationTypeRepository->findOneBy([ + 'code' => $resource['code'], + ]); if (!$productAssociationType instanceof ProductAssociationTypeInterface) { /** @var ProductAssociationTypeInterface $productAssociationType */ $productAssociationType = $this->productAssociationTypeFactory->createNew(); diff --git a/src/Task/Association/CreateProductAssociationTask.php b/src/Task/Association/CreateProductAssociationTask.php index f339840f..c39a7fd2 100644 --- a/src/Task/Association/CreateProductAssociationTask.php +++ b/src/Task/Association/CreateProductAssociationTask.php @@ -75,7 +75,7 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte while ($results = $query->fetchAllNumeric()) { foreach ($results as $result) { - $resource = \json_decode($result[0], true); + $resource = json_decode($result[0], true); $this->createAssociationForEachAssociations($resource); } @@ -86,7 +86,9 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte private function createAssociationForEachAssociations(array $resource): void { - $product = $this->productRepository->findOneBy(['code' => $resource['identifier']]); + $product = $this->productRepository->findOneBy([ + 'code' => $resource['identifier'], + ]); if (!$product instanceof ProductInterface) { $this->logger->critical(sprintf('Product %s not found in database, association skip.', $resource['identifier'])); @@ -105,7 +107,9 @@ private function associateProducts( string $associationTypeCode, array $associations ): void { - $productAssociationType = $this->productAssociationTypeRepository->findOneBy(['code' => $associationTypeCode]); + $productAssociationType = $this->productAssociationTypeRepository->findOneBy([ + 'code' => $associationTypeCode, + ]); if (!$productAssociationType instanceof ProductAssociationTypeInterface) { $this->logger->warning(sprintf('Product association type %s not found.', $associationTypeCode)); @@ -115,7 +119,7 @@ private function associateProducts( $productAssociation = $this->productAssociationRepository->findOneBy( [ 'owner' => $product, - 'type' => $productAssociationType + 'type' => $productAssociationType, ] ); @@ -138,7 +142,9 @@ private function associateProducts( private function associateProduct(ProductAssociationInterface $productAssociation, string $associatedProduct): void { - $product = $this->productRepository->findOneBy(['code' => $associatedProduct]); + $product = $this->productRepository->findOneBy([ + 'code' => $associatedProduct, + ]); if (!$product instanceof ProductInterface) { $this->logger->warning(sprintf('Product %s not and could not be associated', $associatedProduct)); diff --git a/src/Task/Association/RetrieveAssociationTask.php b/src/Task/Association/RetrieveAssociationTask.php index 1809b154..d043d443 100644 --- a/src/Task/Association/RetrieveAssociationTask.php +++ b/src/Task/Association/RetrieveAssociationTask.php @@ -45,7 +45,7 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte $payload->setResources($resources); - $this->logger->info(Messages::totalToImport($payload->getType(), count($resources->getItems()))); + $this->logger->info(Messages::totalToImport($payload->getType(), \count($resources->getItems()))); return $payload; } diff --git a/src/Task/Attribute/CreateUpdateEntityTask.php b/src/Task/Attribute/CreateUpdateEntityTask.php index acf2290a..a444b78f 100644 --- a/src/Task/Attribute/CreateUpdateEntityTask.php +++ b/src/Task/Attribute/CreateUpdateEntityTask.php @@ -136,7 +136,7 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte $this->setAttributeTranslations($resource['labels'], $attribute); $this->entityManager->flush(); } catch (UnsupportedAttributeTypeException $unsupportedAttributeTypeException) { - $this->logger->warning(\sprintf( + $this->logger->warning(sprintf( '%s: %s', $resource['code'], $unsupportedAttributeTypeException->getMessage() @@ -166,7 +166,7 @@ private function setAttributeTranslations(array $labels, AttributeInterface $att $attribute->setFallbackLocale($usedLocalesOnBothPlatform); if (!isset($labels[$usedLocalesOnBothPlatform])) { - $attribute->setName(\sprintf('[%s]', $attribute->getCode())); + $attribute->setName(sprintf('[%s]', $attribute->getCode())); continue; } @@ -178,7 +178,9 @@ private function setAttributeTranslations(array $labels, AttributeInterface $att private function getOrCreateEntity(string $attributeCode, TypeMatcherInterface $attributeType): AttributeInterface { /** @var AttributeInterface $attribute */ - $attribute = $this->productAttributeRepository->findOneBy(['code' => $attributeCode]); + $attribute = $this->productAttributeRepository->findOneBy([ + 'code' => $attributeCode, + ]); if (!$attribute instanceof AttributeInterface) { if (!$this->productAttributeFactory instanceof AttributeFactory) { diff --git a/src/Task/Attribute/DeleteEntityTask.php b/src/Task/Attribute/DeleteEntityTask.php index f1987815..2f4ef4a4 100644 --- a/src/Task/Attribute/DeleteEntityTask.php +++ b/src/Task/Attribute/DeleteEntityTask.php @@ -100,7 +100,7 @@ private function removeUnusedAttributes(array $attributeCodes): void $attributesIdsArray = $this->productAttributeAkeneoRepository->getMissingAttributesIds($attributeCodes); /** @var array $attributesIds */ - $attributesIds = \array_map(function (array $data) { + $attributesIds = array_map(function (array $data) { return $data['id']; }, $attributesIdsArray); diff --git a/src/Task/AttributeOption/AbstractAttributeOptionTask.php b/src/Task/AttributeOption/AbstractAttributeOptionTask.php index e0b449fb..1ddd62aa 100644 --- a/src/Task/AttributeOption/AbstractAttributeOptionTask.php +++ b/src/Task/AttributeOption/AbstractAttributeOptionTask.php @@ -64,13 +64,13 @@ protected function setAttributeChoices( $choices = []; foreach ($options as $option) { foreach ($option['labels'] as $locale => $label) { - if (!in_array($locale, $this->syliusAkeneoLocaleCodeProvider->getUsedLocalesOnBothPlatforms(), true)) { + if (!\in_array($locale, $this->syliusAkeneoLocaleCodeProvider->getUsedLocalesOnBothPlatforms(), true)) { continue; } - if (!isset($choices[self::AKENEO_PREFIX . $option['code']]) && [] !== $this->getUnusedLocale($option['labels'])) { - $choices[self::AKENEO_PREFIX . $option['code']] = $this->getUnusedLocale($option['labels']); + if (!isset($choices[self::AKENEO_PREFIX.$option['code']]) && [] !== $this->getUnusedLocale($option['labels'])) { + $choices[self::AKENEO_PREFIX.$option['code']] = $this->getUnusedLocale($option['labels']); } - $choices[self::AKENEO_PREFIX . $option['code']][$locale] = $label; + $choices[self::AKENEO_PREFIX.$option['code']][$locale] = $label; } } diff --git a/src/Task/AttributeOption/CreateUpdateDeleteTask.php b/src/Task/AttributeOption/CreateUpdateDeleteTask.php index 1f92b3c5..b15bb51f 100644 --- a/src/Task/AttributeOption/CreateUpdateDeleteTask.php +++ b/src/Task/AttributeOption/CreateUpdateDeleteTask.php @@ -73,7 +73,9 @@ private function processByAttribute( bool $isMultiple ): void { $code = $this->akeneoAttributeToSyliusAttributeTransformer->transform($attributeCode); - $attribute = $this->productAttributeRepository->findOneBy(['code' => $code]); + $attribute = $this->productAttributeRepository->findOneBy([ + 'code' => $code, + ]); if (!$attribute instanceof AttributeInterface) { return; diff --git a/src/Task/AttributeOption/RetrieveOptionsTask.php b/src/Task/AttributeOption/RetrieveOptionsTask.php index ebc1737f..ffd06f12 100644 --- a/src/Task/AttributeOption/RetrieveOptionsTask.php +++ b/src/Task/AttributeOption/RetrieveOptionsTask.php @@ -55,9 +55,11 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte if (!$attributeTypeMatcher instanceof SelectAttributeTypeMatcher && !$attributeTypeMatcher instanceof MultiSelectAttributeTypeMatcher) { continue; } - $compatibleAttributes[$resource['code']] = ['isMultiple' => $attributeTypeMatcher instanceof MultiSelectAttributeTypeMatcher]; + $compatibleAttributes[$resource['code']] = [ + 'isMultiple' => $attributeTypeMatcher instanceof MultiSelectAttributeTypeMatcher, + ]; } catch (UnsupportedAttributeTypeException $unsupportedAttributeTypeException) { - $this->logger->warning(\sprintf( + $this->logger->warning(sprintf( '%s: %s', $resource['code'], $unsupportedAttributeTypeException->getMessage() @@ -68,7 +70,7 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte } $optionsPayload = $this->process($payload, $compatibleAttributes); - $this->logger->info(Messages::totalToImport($this->type, count($optionsPayload->getResources()))); + $this->logger->info(Messages::totalToImport($this->type, \count($optionsPayload->getResources()))); return $optionsPayload; } diff --git a/src/Task/Category/CreateUpdateEntityTask.php b/src/Task/Category/CreateUpdateEntityTask.php index 65e4c9f6..e10ad4a2 100644 --- a/src/Task/Category/CreateUpdateEntityTask.php +++ b/src/Task/Category/CreateUpdateEntityTask.php @@ -80,7 +80,7 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte $this->type = $payload->getType(); $this->logger->notice(Messages::createOrUpdate($this->type)); - if (!is_array($payload->getResources())) { + if (!\is_array($payload->getResources())) { throw new NoCategoryResourcesException('No resource found.'); } @@ -116,10 +116,10 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte $taxonTranslation->setName($label); $slug = Transliterator::transliterate( - \str_replace( + str_replace( '\'', '-', - \sprintf( + sprintf( '%s-%s', $resource['code'], $label @@ -161,7 +161,9 @@ private function assignParent(TaxonInterface $taxon, array $taxons, array $resou private function getOrCreateEntity(string $code): TaxonInterface { /** @var TaxonInterface $taxon */ - $taxon = $this->taxonRepository->findOneBy(['code' => $code]); + $taxon = $this->taxonRepository->findOneBy([ + 'code' => $code, + ]); if (!$taxon instanceof TaxonInterface) { /** @var TaxonInterface $taxon */ diff --git a/src/Task/Category/RetrieveCategoriesTask.php b/src/Task/Category/RetrieveCategoriesTask.php index 0e7f4b9f..ee752f37 100644 --- a/src/Task/Category/RetrieveCategoriesTask.php +++ b/src/Task/Category/RetrieveCategoriesTask.php @@ -49,14 +49,14 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte $configuration = $this->categoriesConfigurationRepository->getCategoriesConfiguration(); if (!$configuration instanceof CategoryConfiguration) { - $resourcesArray = \iterator_to_array($resources); + $resourcesArray = iterator_to_array($resources); $payload->setResources($resourcesArray); - $this->logger->info(Messages::totalToImport($payload->getType(), count($resourcesArray))); + $this->logger->info(Messages::totalToImport($payload->getType(), \count($resourcesArray))); return $payload; } - $categories = \iterator_to_array($resources); + $categories = iterator_to_array($resources); $categoriesTree = $this->buildTree($categories, null); $keptCategories = $this->excludeNotInRootCategory($configuration, $categoriesTree); @@ -65,7 +65,7 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte //Only keep category of the root category foreach ($categories as $key => $category) { if (!\in_array($category['code'], $keptCategories, true)) { - $this->logger->info(\sprintf('%s: %s is not inside selected root categories and will be excluded', $payload->getType(), $category['code'])); + $this->logger->info(sprintf('%s: %s is not inside selected root categories and will be excluded', $payload->getType(), $category['code'])); unset($categories[$key]); } } @@ -73,14 +73,14 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte //Remove excluded categories from kept categories foreach ($categories as $key => $category) { if (\in_array($category['code'], $excludedCategories, true)) { - $this->logger->info(\sprintf('%s: %s is explicitly excluded from configuration', $payload->getType(), $category['code'])); + $this->logger->info(sprintf('%s: %s is explicitly excluded from configuration', $payload->getType(), $category['code'])); unset($categories[$key]); } } - $this->logger->info(Messages::totalExcludedFromImport($payload->getType(), count($excludedCategories))); + $this->logger->info(Messages::totalExcludedFromImport($payload->getType(), \count($excludedCategories))); - $this->logger->info(Messages::totalToImport($payload->getType(), count($categories))); + $this->logger->info(Messages::totalToImport($payload->getType(), \count($categories))); $payload->setResources($categories); @@ -151,7 +151,7 @@ private function excludeNotInRootCategory(CategoryConfiguration $configuration, foreach ($configuration->getRootCategories() as $rootCategory) { $rootNode = $this->findParentNode($rootCategory, $categoriesTree); - if (!is_array($rootNode)) { + if (!\is_array($rootNode)) { return $keptCategories; } @@ -171,7 +171,7 @@ private function excludeNotImportedCategories(CategoryConfiguration $configurati foreach ($configuration->getNotImportCategories() as $notImportCategory) { $parentNode = $this->findParentNode($notImportCategory, $categoriesTree); - if (!is_array($parentNode)) { + if (!\is_array($parentNode)) { continue; } diff --git a/src/Task/Option/CreateUpdateTask.php b/src/Task/Option/CreateUpdateTask.php index 605153fb..f9d6a209 100644 --- a/src/Task/Option/CreateUpdateTask.php +++ b/src/Task/Option/CreateUpdateTask.php @@ -75,8 +75,8 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte try { $this->entityManager->beginTransaction(); - $variationAxes = \array_unique($this->getVariationAxes($payload)); - $this->logger->info(Messages::totalToImport($payload->getType(), count($variationAxes))); + $variationAxes = array_unique($this->getVariationAxes($payload)); + $this->logger->info(Messages::totalToImport($payload->getType(), \count($variationAxes))); /** @var AttributeInterface $attribute */ foreach ($this->productAttributeRepository->findByCodes($variationAxes) as $attribute) { @@ -115,7 +115,7 @@ private function getVariationAxes(PipelinePayloadInterface $payload): array $this->configurationProvider->getConfiguration()->getPaginationSize() ); - $variationAxes = \array_merge($variationAxes, $this->getVariationAxesForFamilies($familyVariants)); + $variationAxes = array_merge($variationAxes, $this->getVariationAxesForFamilies($familyVariants)); } return $variationAxes; @@ -127,7 +127,7 @@ private function getVariationAxesForFamilies(ResourceCursorInterface $familyVari foreach ($familyVariants as $familyVariant) { //Sort array of variant attribute sets by level DESC - \usort($familyVariant['variant_attribute_sets'], function ($leftVariantAttributeSets, $rightVariantAttributeSets) { + usort($familyVariant['variant_attribute_sets'], function ($leftVariantAttributeSets, $rightVariantAttributeSets) { return (int) ($leftVariantAttributeSets['level'] < $rightVariantAttributeSets['level']); }); diff --git a/src/Task/Product/AbstractCreateProductEntities.php b/src/Task/Product/AbstractCreateProductEntities.php index 22f68b2f..7b381f82 100644 --- a/src/Task/Product/AbstractCreateProductEntities.php +++ b/src/Task/Product/AbstractCreateProductEntities.php @@ -82,7 +82,9 @@ public function __construct( protected function getOrCreateSimpleVariant(ProductInterface $product): ProductVariantInterface { /** @var ProductVariantInterface $productVariant */ - $productVariant = $this->productVariantRepository->findOneBy(['code' => $product->getCode()]); + $productVariant = $this->productVariantRepository->findOneBy([ + 'code' => $product->getCode(), + ]); if (!$productVariant instanceof ProductVariantInterface) { $productVariant = $this->productVariantFactory->createForProduct($product); @@ -116,14 +118,14 @@ protected function setProductPrices( protected function countTotalProducts(bool $isSimple): int { - $query = $this->entityManager->getConnection()->prepare(\sprintf( + $query = $this->entityManager->getConnection()->prepare(sprintf( 'SELECT count(id) FROM `%s` WHERE is_simple = :is_simple', ProductPayload::TEMP_AKENEO_TABLE_NAME )); $query->bindValue('is_simple', $isSimple, ParameterType::BOOLEAN); $query->execute(); - return (int) \current($query->fetch()); + return (int) current($query->fetch()); } protected function prepareSelectQuery( @@ -131,7 +133,7 @@ protected function prepareSelectQuery( int $limit = ProductPayload::SELECT_PAGINATION_SIZE, int $offset = 0 ): Statement { - $query = $this->entityManager->getConnection()->prepare(\sprintf( + $query = $this->entityManager->getConnection()->prepare(sprintf( 'SELECT `values` FROM `%s` WHERE is_simple = :is_simple @@ -192,7 +194,7 @@ private function getPriceAttributeData(array $attributes): array throw new \LogicException('Price attribute is empty.'); } - return \current($attributeValue)['data']; + return current($attributeValue)['data']; } throw new NoAttributeResourcesException('Price attribute not found.'); diff --git a/src/Task/Product/AbstractInsertProductImageTask.php b/src/Task/Product/AbstractInsertProductImageTask.php index e07c8afc..3d78dba8 100644 --- a/src/Task/Product/AbstractInsertProductImageTask.php +++ b/src/Task/Product/AbstractInsertProductImageTask.php @@ -67,9 +67,9 @@ protected function addImage(ProductMediaPayloadInterface $payload, $object, Coll foreach ($images as $image) { try { $imageResponse = $payload->getAkeneoPimClient()->getProductMediaFileApi()->download($image['data']); - $imageName = \basename($image['data']); - $imagePath = \sys_get_temp_dir() . '/' . $imageName; - \file_put_contents($imagePath, $imageResponse->getBody()->getContents()); + $imageName = basename($image['data']); + $imagePath = sys_get_temp_dir().'/'.$imageName; + file_put_contents($imagePath, $imageResponse->getBody()->getContents()); $uploadedImage = new UploadedFile($imagePath, $imageName); /** @var ImageInterface $productImage */ @@ -80,7 +80,7 @@ protected function addImage(ProductMediaPayloadInterface $payload, $object, Coll $object->addImage($productImage); - \unlink($imagePath); + unlink($imagePath); } catch (\Throwable $throwable) { $this->logger->warning($throwable->getMessage()); } @@ -106,7 +106,9 @@ protected function getFileType(string $attributeCode): ?string { $repository = $this->entityManager->getRepository(ProductConfigurationImageMapping::class); /** @var ProductConfigurationImageMapping|null $mapping */ - $mapping = $repository->findOneBy(['akeneoAttribute' => $attributeCode]); + $mapping = $repository->findOneBy([ + 'akeneoAttribute' => $attributeCode, + ]); return ($mapping instanceof ProductConfigurationImageMapping) ? $mapping->getSyliusAttribute() : null; } diff --git a/src/Task/Product/AddProductToCategoriesTask.php b/src/Task/Product/AddProductToCategoriesTask.php index 172c5415..3dee15db 100644 --- a/src/Task/Product/AddProductToCategoriesTask.php +++ b/src/Task/Product/AddProductToCategoriesTask.php @@ -46,12 +46,17 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte } foreach ($payload->getCategories() as $category) { - $taxon = $this->taxonRepository->findOneBy(['code' => $category]); + $taxon = $this->taxonRepository->findOneBy([ + 'code' => $category, + ]); if (!$taxon instanceof TaxonInterface) { continue; } /** @var ProductTaxonInterface $productTaxon */ - $productTaxon = $this->productTaxonRepository->findOneBy(['product' => $payload->getProduct(), 'taxon' => $taxon]); + $productTaxon = $this->productTaxonRepository->findOneBy([ + 'product' => $payload->getProduct(), + 'taxon' => $taxon, + ]); if (!$productTaxon instanceof ProductTaxonInterface) { /** @var ProductTaxonInterface $productTaxon */ diff --git a/src/Task/Product/CreateConfigurableProductEntitiesTask.php b/src/Task/Product/CreateConfigurableProductEntitiesTask.php index e374de41..6c04327c 100644 --- a/src/Task/Product/CreateConfigurableProductEntitiesTask.php +++ b/src/Task/Product/CreateConfigurableProductEntitiesTask.php @@ -161,15 +161,17 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte while ($results = $query->fetchAll()) { foreach ($results as $result) { - $resource = \json_decode($result['values'], true); + $resource = json_decode($result['values'], true); try { /** @var ProductInterface $productModel */ - $productModel = $this->productRepository->findOneBy(['code' => $resource['parent']]); + $productModel = $this->productRepository->findOneBy([ + 'code' => $resource['parent'], + ]); //Skip product variant import if it does not have a parent model on Sylius - if (!$productModel instanceof ProductInterface || !is_string($productModel->getCode())) { - $this->logger->warning(\sprintf( + if (!$productModel instanceof ProductInterface || !\is_string($productModel->getCode())) { + $this->logger->warning(sprintf( 'Skipped product "%s" because model "%s" does not exist.', $resource['identifier'], $resource['parent'], @@ -180,10 +182,12 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte $this->dispatcher->dispatch(new BeforeProcessingProductVariantEvent($resource, $productModel)); - $productGroup = $this->productGroupRepository->findOneBy(['productParent' => $productModel->getCode()]); + $productGroup = $this->productGroupRepository->findOneBy([ + 'productParent' => $productModel->getCode(), + ]); if (!$productGroup instanceof ProductGroup) { - $this->logger->warning(\sprintf( + $this->logger->warning(sprintf( 'Skipped product "%s" because model "%s" does not exist as group.', $resource['identifier'], $resource['parent'], @@ -195,7 +199,7 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte $variationAxes = $productGroup->getVariationAxes(); if (0 === \count($variationAxes)) { - $this->logger->warning(\sprintf( + $this->logger->warning(sprintf( 'Skipped product "%s" because group has no variation axis.', $resource['identifier'], )); @@ -213,7 +217,7 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte } $processedCount += \count($results); - $this->logger->info(\sprintf('Processed %d products out of %d.', $processedCount, $totalItemsCount)); + $this->logger->info(sprintf('Processed %d products out of %d.', $processedCount, $totalItemsCount)); $query = $this->prepareSelectQuery(false, ProductPayload::SELECT_PAGINATION_SIZE, $processedCount); $query->execute(); } @@ -265,11 +269,13 @@ private function processVariations( } /** @var ProductOptionInterface $productOption */ - $productOption = $this->productOptionRepository->findOneBy(['code' => $attributeCode]); + $productOption = $this->productOptionRepository->findOneBy([ + 'code' => $attributeCode, + ]); //We cannot create the variant if the option does not exist if (!$productOption instanceof ProductOptionInterface) { - $this->logger->warning(\sprintf( + $this->logger->warning(sprintf( 'Skipped ProductVariant "%s" creation because ProductOption "%s" does not exist.', $variantCode, $attributeCode @@ -315,7 +321,7 @@ private function setProductOptionValues( ]); if (!$productOptionValue instanceof ProductOptionValueInterface) { - $this->logger->warning(\sprintf( + $this->logger->warning(sprintf( 'Skipped variant value %s for option %s on variant %s because ProductOptionValue does not exist.', $value, $productOption->getCode(), @@ -368,13 +374,13 @@ private function getCode(ProductOptionInterface $productOption, $data): string if (!\is_array($data)) { return ProductOptionManager::getOptionValueCodeFromProductOption( $productOption, - CreateUpdateDeleteTask::AKENEO_PREFIX . $data + CreateUpdateDeleteTask::AKENEO_PREFIX.$data ); } return ProductOptionManager::getOptionValueCodeFromProductOption( $productOption, - CreateUpdateDeleteTask::AKENEO_PREFIX . \implode('_', $data) + CreateUpdateDeleteTask::AKENEO_PREFIX.implode('_', $data) ); } @@ -387,7 +393,7 @@ private function getValue($data): string return $data; } - return \implode(' ', $data); + return implode(' ', $data); } private function updateImages(ProductPayload $payload, array $resource, ProductVariantInterface $productVariant): void @@ -403,7 +409,9 @@ private function updateImages(ProductPayload $payload, array $resource, ProductV private function getOrCreateEntity(string $variantCode, ProductInterface $productModel): ProductVariantInterface { - $productVariant = $this->productVariantRepository->findOneBy(['code' => $variantCode]); + $productVariant = $this->productVariantRepository->findOneBy([ + 'code' => $variantCode, + ]); if (!$productVariant instanceof ProductVariantInterface) { /** @var ProductVariantInterface $productVariant */ diff --git a/src/Task/Product/CreateSimpleProductEntitiesTask.php b/src/Task/Product/CreateSimpleProductEntitiesTask.php index 30e33f15..6936c269 100644 --- a/src/Task/Product/CreateSimpleProductEntitiesTask.php +++ b/src/Task/Product/CreateSimpleProductEntitiesTask.php @@ -157,7 +157,7 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte while ($results = $query->fetchAll()) { foreach ($results as $result) { - $resource = \json_decode($result['values'], true); + $resource = json_decode($result['values'], true); try { $this->dispatcher->dispatch(new BeforeProcessingProductEvent($resource)); @@ -193,7 +193,7 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte } $processedCount += \count($results); - $this->logger->info(\sprintf('Processed %d products out of %d.', $processedCount, $totalItemsCount)); + $this->logger->info(sprintf('Processed %d products out of %d.', $processedCount, $totalItemsCount)); $query = $this->prepareSelectQuery(true, ProductPayload::SELECT_PAGINATION_SIZE, $processedCount); $query->execute(); } @@ -206,7 +206,9 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte private function getOrCreateEntity(array $resource): ProductInterface { /** @var ProductInterface $product */ - $product = $this->productRepository->findOneBy(['code' => $resource['identifier']]); + $product = $this->productRepository->findOneBy([ + 'code' => $resource['identifier'], + ]); if (!$product instanceof ProductInterface) { if (!$this->productFactory instanceof ProductFactory) { @@ -264,7 +266,7 @@ private function updateProductRequirementsForActiveLocales( } if (null === $productName) { - $productName = \sprintf('[%s]', $product->getCode()); + $productName = sprintf('[%s]', $product->getCode()); ++$missingNameTranslationCount; } @@ -293,7 +295,7 @@ private function updateProductRequirementsForActiveLocales( if ($missingNameTranslationCount > 0) { //Multiple product has the same name - $productTranslation->setSlug(\sprintf( + $productTranslation->setSlug(sprintf( '%s-%s-%d', $resource['code'] ?? $resource['identifier'], $this->productSlugGenerator->generate($productName), @@ -304,7 +306,7 @@ private function updateProductRequirementsForActiveLocales( } //Multiple product has the same name - $productTranslation->setSlug(\sprintf( + $productTranslation->setSlug(sprintf( '%s-%s', $resource['code'] ?? $resource['identifier'], $this->productSlugGenerator->generate($productName) diff --git a/src/Task/Product/EnableDisableProductsTask.php b/src/Task/Product/EnableDisableProductsTask.php index a48274a5..140ba33b 100644 --- a/src/Task/Product/EnableDisableProductsTask.php +++ b/src/Task/Product/EnableDisableProductsTask.php @@ -56,11 +56,13 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte while ($results = $query->fetchAll()) { foreach ($results as $result) { - $resource = \json_decode($result['values'], true); + $resource = json_decode($result['values'], true); try { /** @var ProductInterface $product */ - $product = $this->productRepository->findOneBy(['code' => $resource['identifier']]); + $product = $this->productRepository->findOneBy([ + 'code' => $resource['identifier'], + ]); if (!$product instanceof ProductInterface) { continue; @@ -85,7 +87,7 @@ private function prepareSelectQuery( int $limit = ProductPayload::SELECT_PAGINATION_SIZE, int $offset = 0 ): Statement { - $query = $this->entityManager->getConnection()->prepare(\sprintf( + $query = $this->entityManager->getConnection()->prepare(sprintf( 'SELECT `values` FROM `%s` WHERE is_simple = :is_simple diff --git a/src/Task/Product/RetrieveProductsTask.php b/src/Task/Product/RetrieveProductsTask.php index 553ce956..58c7f480 100644 --- a/src/Task/Product/RetrieveProductsTask.php +++ b/src/Task/Product/RetrieveProductsTask.php @@ -74,12 +74,12 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte $resources instanceof Page ) { foreach ($resources->getItems() as $item) { - $sql = \sprintf( + $sql = sprintf( 'INSERT INTO `%s` (`values`, `is_simple`) VALUES (:values, :is_simple);', ProductPayload::TEMP_AKENEO_TABLE_NAME, ); $stmt = $this->entityManager->getConnection()->prepare($sql); - $stmt->bindValue('values', \json_encode($item)); + $stmt->bindValue('values', json_encode($item)); $stmt->bindValue('is_simple', null === $item['parent'], ParameterType::BOOLEAN); $stmt->execute(); diff --git a/src/Task/Product/SetupProductTask.php b/src/Task/Product/SetupProductTask.php index 6edf6cd3..4a9a099f 100644 --- a/src/Task/Product/SetupProductTask.php +++ b/src/Task/Product/SetupProductTask.php @@ -28,7 +28,7 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte { $this->taskProvider->get(TearDownProductTask::class)->__invoke($payload); - $query = \sprintf( + $query = sprintf( 'CREATE TABLE `%s` ( `id` INT NOT NULL AUTO_INCREMENT, `values` JSON NULL, diff --git a/src/Task/ProductModel/AddOrUpdateProductModelTask.php b/src/Task/ProductModel/AddOrUpdateProductModelTask.php index f8579f1c..7ff75def 100644 --- a/src/Task/ProductModel/AddOrUpdateProductModelTask.php +++ b/src/Task/ProductModel/AddOrUpdateProductModelTask.php @@ -203,7 +203,7 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte while ($results = $query->fetchAll()) { foreach ($results as $result) { - $resource = \json_decode($result['values'], true); + $resource = json_decode($result['values'], true); try { $this->dispatcher->dispatch(new BeforeProcessingProductEvent($resource)); @@ -225,7 +225,7 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte } $processedCount += \count($results); - $this->logger->info(\sprintf('Processed %d products out of %d.', $processedCount, $totalItemsCount)); + $this->logger->info(sprintf('Processed %d products out of %d.', $processedCount, $totalItemsCount)); $query = $this->prepareSelectQuery(ProductModelPayload::SELECT_PAGINATION_SIZE, $processedCount); $query->execute(); } @@ -237,20 +237,20 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte private function countTotalProducts(): int { - $query = $this->entityManager->getConnection()->prepare(\sprintf( + $query = $this->entityManager->getConnection()->prepare(sprintf( 'SELECT count(id) FROM `%s`', ProductModelPayload::TEMP_AKENEO_TABLE_NAME )); $query->execute(); - return (int) \current($query->fetch()); + return (int) current($query->fetch()); } private function prepareSelectQuery( int $limit = ProductPayload::SELECT_PAGINATION_SIZE, int $offset = 0 ): Statement { - $query = $this->entityManager->getConnection()->prepare(\sprintf( + $query = $this->entityManager->getConnection()->prepare(sprintf( 'SELECT `values` FROM `%s` LIMIT :limit @@ -352,7 +352,7 @@ private function updateProductRequirementsForActiveLocales( } if (null === $productName) { - $productName = \sprintf('[%s]', $product->getCode()); + $productName = sprintf('[%s]', $product->getCode()); ++$missingNameTranslationCount; } @@ -371,7 +371,7 @@ private function updateProductRequirementsForActiveLocales( if ($missingNameTranslationCount > 0) { //Multiple product has the same name - $productTranslation->setSlug(\sprintf( + $productTranslation->setSlug(sprintf( '%s-%s-%d', $resource['code'], $this->productSlugGenerator->generate($productName), @@ -382,7 +382,7 @@ private function updateProductRequirementsForActiveLocales( } //Multiple product has the same name - $productTranslation->setSlug(\sprintf( + $productTranslation->setSlug(sprintf( '%s-%s', $resource['code'], $this->productSlugGenerator->generate($productName) @@ -404,7 +404,9 @@ private function linkCategoriesToProduct(ProductInterface $product, array &$reso private function addProductGroup(array &$resource, ProductInterface $product): void { - $productGroup = $this->productGroupRepository->findOneBy(['productParent' => $resource['parent']]); + $productGroup = $this->productGroupRepository->findOneBy([ + 'productParent' => $resource['parent'], + ]); if ($productGroup instanceof ProductGroup && 0 === $this->productGroupRepository->isProductInProductGroup($product, $productGroup)) { $productGroup->addProduct($product); @@ -414,7 +416,9 @@ private function addProductGroup(array &$resource, ProductInterface $product): v private function setMainTaxon(array &$resource, ProductInterface $product): void { if (isset($resource['categories'][0])) { - $taxon = $this->taxonRepository->findOneBy(['code' => $resource['categories'][0]]); + $taxon = $this->taxonRepository->findOneBy([ + 'code' => $resource['categories'][0], + ]); if ($taxon instanceof TaxonInterface) { $product->setMainTaxon($taxon); } diff --git a/src/Task/ProductModel/AddProductGroupsTask.php b/src/Task/ProductModel/AddProductGroupsTask.php index ea51bb38..b0c83267 100644 --- a/src/Task/ProductModel/AddProductGroupsTask.php +++ b/src/Task/ProductModel/AddProductGroupsTask.php @@ -99,7 +99,9 @@ private function createGroupForCodeAndFamily(string $code, string $family): void return; } - if ($this->productGroupRepository->findOneBy(['productParent' => $code])) { + if ($this->productGroupRepository->findOneBy([ + 'productParent' => $code, + ])) { ++$this->groupAlreadyExistCount; $this->logger->info(Messages::hasBeenAlreadyExist('ProductGroup', $code)); @@ -118,10 +120,10 @@ private function createGroupForCodeAndFamily(string $code, string $family): void private function createProductGroups(array $resource): void { - if ($resource['parent'] !== null) { + if (null !== $resource['parent']) { $this->createGroupForCodeAndFamily($resource['parent'], $resource['family']); } - if ($resource['code'] !== null) { + if (null !== $resource['code']) { $this->createGroupForCodeAndFamily($resource['code'], $resource['family']); } } diff --git a/src/Task/ProductModel/EnableDisableProductModelsTask.php b/src/Task/ProductModel/EnableDisableProductModelsTask.php index 840ae71e..81561986 100644 --- a/src/Task/ProductModel/EnableDisableProductModelsTask.php +++ b/src/Task/ProductModel/EnableDisableProductModelsTask.php @@ -57,11 +57,13 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte while ($results = $query->fetchAll()) { foreach ($results as $result) { - $resource = \json_decode($result['values'], true); + $resource = json_decode($result['values'], true); try { /** @var ProductInterface $product */ - $product = $this->productRepository->findOneBy(['code' => $resource['code']]); + $product = $this->productRepository->findOneBy([ + 'code' => $resource['code'], + ]); if (!$product instanceof ProductInterface) { continue; @@ -85,7 +87,7 @@ private function prepareSelectQuery( int $limit = ProductPayload::SELECT_PAGINATION_SIZE, int $offset = 0 ): Statement { - $query = $this->entityManager->getConnection()->prepare(\sprintf( + $query = $this->entityManager->getConnection()->prepare(sprintf( 'SELECT `values` FROM `%s` LIMIT :limit diff --git a/src/Task/ProductModel/RetrieveProductModelsTask.php b/src/Task/ProductModel/RetrieveProductModelsTask.php index cda9e683..051552b0 100644 --- a/src/Task/ProductModel/RetrieveProductModelsTask.php +++ b/src/Task/ProductModel/RetrieveProductModelsTask.php @@ -67,12 +67,12 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte if (empty($item['code'])) { ++$noCodeCount; } - $sql = \sprintf( + $sql = sprintf( 'INSERT INTO `%s` (`values`) VALUES (:values);', ProductModelPayload::TEMP_AKENEO_TABLE_NAME, ); $stmt = $this->entityManager->getConnection()->prepare($sql); - $stmt->bindValue('values', \json_encode($item)); + $stmt->bindValue('values', json_encode($item)); $stmt->execute(); } diff --git a/src/Task/ProductModel/SetupProductTask.php b/src/Task/ProductModel/SetupProductTask.php index 2c85b20c..f1a7c842 100644 --- a/src/Task/ProductModel/SetupProductTask.php +++ b/src/Task/ProductModel/SetupProductTask.php @@ -28,7 +28,7 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte { $this->taskProvider->get(TearDownProductTask::class)->__invoke($payload); - $query = \sprintf( + $query = sprintf( 'CREATE TABLE `%s` ( `id` INT NOT NULL AUTO_INCREMENT, `values` JSON NULL, diff --git a/src/TypeMatcher/Attribute/AttributeTypeMatcher.php b/src/TypeMatcher/Attribute/AttributeTypeMatcher.php index 44d33eb1..b10a0a8b 100644 --- a/src/TypeMatcher/Attribute/AttributeTypeMatcher.php +++ b/src/TypeMatcher/Attribute/AttributeTypeMatcher.php @@ -24,6 +24,6 @@ public function match(string $type): AttributeTypeMatcherInterface } } - throw new UnsupportedAttributeTypeException(\sprintf('Unsupported Attribute Type "%s"', $type)); + throw new UnsupportedAttributeTypeException(sprintf('Unsupported Attribute Type "%s"', $type)); } } diff --git a/src/TypeMatcher/ReferenceEntityAttribute/ReferenceEntityAttributeTypeMatcher.php b/src/TypeMatcher/ReferenceEntityAttribute/ReferenceEntityAttributeTypeMatcher.php index e38bb93f..4c1a66ca 100644 --- a/src/TypeMatcher/ReferenceEntityAttribute/ReferenceEntityAttributeTypeMatcher.php +++ b/src/TypeMatcher/ReferenceEntityAttribute/ReferenceEntityAttributeTypeMatcher.php @@ -24,6 +24,6 @@ public function match(string $type): ReferenceEntityAttributeTypeMatcherInterfac } } - throw new UnsupportedReferenceEntityAttributeTypeException(\sprintf('Unsupported Reference Entity Attribute Type "%s"', $type)); + throw new UnsupportedReferenceEntityAttributeTypeException(sprintf('Unsupported Reference Entity Attribute Type "%s"', $type)); } } diff --git a/tests/PHPUnit/Api/ApiTestCase.php b/tests/PHPUnit/Api/ApiTestCase.php index 4eed0a23..b336a644 100644 --- a/tests/PHPUnit/Api/ApiTestCase.php +++ b/tests/PHPUnit/Api/ApiTestCase.php @@ -36,7 +36,7 @@ protected function setUp(): void $this->server = new MockWebServer((int) $_SERVER['MOCK_SERVER_PORT'], $_SERVER['MOCK_SERVER_HOST']); $this->server->start(); $this->server->setResponseOfPath( - '/' . AuthenticationApi::TOKEN_URI, + '/'.AuthenticationApi::TOKEN_URI, new Response($this->getAuthenticatedJson()) ); } @@ -75,15 +75,15 @@ protected function createClient(): AkeneoPimEnterpriseClientInterface protected static function getSamplePath(): string { - return \dirname(__DIR__) . self::SAMPLE_PATH; + return \dirname(__DIR__).self::SAMPLE_PATH; } protected function getFileContent(string $name): string { - $file = self::getSamplePath() . $name; + $file = self::getSamplePath().$name; Assert::fileExists($file); - $content = \file_get_contents($file); + $content = file_get_contents($file); if (false === $content) { return ''; } diff --git a/tests/PHPUnit/Api/GetCategoriesTest.php b/tests/PHPUnit/Api/GetCategoriesTest.php index 3e78fb27..2a4c369d 100644 --- a/tests/PHPUnit/Api/GetCategoriesTest.php +++ b/tests/PHPUnit/Api/GetCategoriesTest.php @@ -22,7 +22,7 @@ final class GetCategoriesTest extends ApiTestCase public function testGetCategories(): void { $this->server->setResponseOfPath( - '/' . sprintf(CategoryApi::CATEGORIES_URI), + '/'.sprintf(CategoryApi::CATEGORIES_URI), new ResponseStack( new Response($this->getCategories(), [], HttpResponse::HTTP_OK) ) @@ -38,7 +38,7 @@ public function testGetCategories(): void Assert::assertInstanceOf(RequestInfo::class, $lastRequest); Assert::assertSame($lastRequest->jsonSerialize()[RequestInfo::JSON_KEY_METHOD], 'GET'); Assert::assertInstanceOf(ResourceCursor::class, $categories); - Assert::assertSame(\json_decode($this->getCategories(), true)['_embedded']['items'][0], $categories->current()); + Assert::assertSame(json_decode($this->getCategories(), true)['_embedded']['items'][0], $categories->current()); } private function getCategories(): string diff --git a/tests/PHPUnit/Api/GetProductsTest.php b/tests/PHPUnit/Api/GetProductsTest.php index 9ec94e97..a6312e8a 100644 --- a/tests/PHPUnit/Api/GetProductsTest.php +++ b/tests/PHPUnit/Api/GetProductsTest.php @@ -21,7 +21,7 @@ final class GetProductsTest extends ApiTestCase public function testGetProducts(): void { $this->server->setResponseOfPath( - '/' . ProductApi::PRODUCTS_URI, + '/'.ProductApi::PRODUCTS_URI, new ResponseStack( new Response($this->getProducts(), [], HttpResponse::HTTP_OK), new Response($this->getProducts(), [], HttpResponse::HTTP_OK) diff --git a/tests/PHPUnit/Client/ClientFactory.php b/tests/PHPUnit/Client/ClientFactory.php index 5b2819dc..a86807b8 100644 --- a/tests/PHPUnit/Client/ClientFactory.php +++ b/tests/PHPUnit/Client/ClientFactory.php @@ -23,7 +23,7 @@ public function __construct(string $mockServerHost, int $mockServerPort) public function createFromApiCredentials(): AkeneoPimEnterpriseClientInterface { - $clientBuilder = new AkeneoPimEnterpriseClientBuilder(\sprintf( + $clientBuilder = new AkeneoPimEnterpriseClientBuilder(sprintf( 'http://%s:%d', $this->mockServerHost, $this->mockServerPort diff --git a/tests/PHPUnit/EventSubscriber/AfterTaskSubscriber.php b/tests/PHPUnit/EventSubscriber/AfterTaskSubscriber.php index 14439780..f08f4c65 100644 --- a/tests/PHPUnit/EventSubscriber/AfterTaskSubscriber.php +++ b/tests/PHPUnit/EventSubscriber/AfterTaskSubscriber.php @@ -23,7 +23,7 @@ public function processEvent(AfterTaskEvent $event) { /** @var DummyPayload $payload */ $payload = $event->getPayload(); - if (\method_exists($payload, 'addLog')) { + if (method_exists($payload, 'addLog')) { $payload->addLog($event::NAME); } } diff --git a/tests/PHPUnit/EventSubscriber/BeforeTaskSubscriber.php b/tests/PHPUnit/EventSubscriber/BeforeTaskSubscriber.php index 8038abd9..9055c522 100644 --- a/tests/PHPUnit/EventSubscriber/BeforeTaskSubscriber.php +++ b/tests/PHPUnit/EventSubscriber/BeforeTaskSubscriber.php @@ -23,7 +23,7 @@ public function processEvent(BeforeTaskEvent $event) { /** @var DummyPayload $payload */ $payload = $event->getPayload(); - if (\method_exists($payload, 'addLog')) { + if (method_exists($payload, 'addLog')) { $payload->addLog($event::NAME); } } diff --git a/tests/PHPUnit/Filter/ProductFilterTest.php b/tests/PHPUnit/Filter/ProductFilterTest.php index 254fcc78..5b8bf91f 100644 --- a/tests/PHPUnit/Filter/ProductFilterTest.php +++ b/tests/PHPUnit/Filter/ProductFilterTest.php @@ -71,7 +71,7 @@ protected function setUp(): void $this->manager->flush(); $this->server->setResponseOfPath( - '/' . sprintf(LocaleApi::LOCALES_URI), + '/'.sprintf(LocaleApi::LOCALES_URI), new Response($this->getFileContent('locales.json'), [], HttpResponse::HTTP_OK) ); } diff --git a/tests/PHPUnit/Provider/AkeneoAttributeDataProviderTest.php b/tests/PHPUnit/Provider/AkeneoAttributeDataProviderTest.php index 5981bc94..5090a469 100644 --- a/tests/PHPUnit/Provider/AkeneoAttributeDataProviderTest.php +++ b/tests/PHPUnit/Provider/AkeneoAttributeDataProviderTest.php @@ -44,21 +44,21 @@ public function testUniqueValue($expectedValue, $attributeCode, $attributeValues public function uniqueAttributeDataProvider(): \Generator { - yield ['1234567890142', 'ean', \json_decode('[ + yield ['1234567890142', 'ean', json_decode('[ { "locale": null, "scope": null, "data": "1234567890142" } ]', true), 'fr_FR', 'ecommerce']; - yield ['1234567890142', 'sku', \json_decode('[ + yield ['1234567890142', 'sku', json_decode('[ { "locale": null, "scope": null, "data": "1234567890142" } ]', true), 'en_US', 'ecommerce']; - yield ['1234567890142', 'sku', \json_decode('[ + yield ['1234567890142', 'sku', json_decode('[ { "locale": null, "scope": null, @@ -78,35 +78,35 @@ public function testNonUniqueNonLocalizableNonScopableValue($expectedValue, $att public function nonUniqueNonLocalizableNonScopableAttributeDataProvider(): \Generator { - yield [[CreateUpdateDeleteTask::AKENEO_PREFIX . '600'], 'wash_temperature', \json_decode('[ + yield [[CreateUpdateDeleteTask::AKENEO_PREFIX.'600'], 'wash_temperature', json_decode('[ { "locale": null, "scope": null, "data": "600" } ]', true), 'fr_FR', 'ecommerce']; - yield [[CreateUpdateDeleteTask::AKENEO_PREFIX . '600'], 'wash_temperature', \json_decode('[ + yield [[CreateUpdateDeleteTask::AKENEO_PREFIX.'600'], 'wash_temperature', json_decode('[ { "locale": "fr_FR", "scope": null, "data": "600" } ]', true), 'fr_FR', 'ecommerce']; - yield [[CreateUpdateDeleteTask::AKENEO_PREFIX . '600'], 'wash_temperature', \json_decode('[ + yield [[CreateUpdateDeleteTask::AKENEO_PREFIX.'600'], 'wash_temperature', json_decode('[ { "locale": "fr_FR", "scope": "ecommerce", "data": "600" } ]', true), 'fr_FR', 'ecommerce']; - yield [[CreateUpdateDeleteTask::AKENEO_PREFIX . '600'], 'wash_temperature', \json_decode('[ + yield [[CreateUpdateDeleteTask::AKENEO_PREFIX.'600'], 'wash_temperature', json_decode('[ { "locale": null, "scope": "ecommerce", "data": "600" } ]', true), 'fr_FR', 'ecommerce']; - yield ['32 INCH', 'display_diagonal', \json_decode('[ + yield ['32 INCH', 'display_diagonal', json_decode('[ { "locale": null, "scope": null, @@ -129,7 +129,7 @@ public function testNonUniqueNonLocalizableScopableValue($expectedValue, $attrib public function nonUniqueNonLocalizableScopableAttributeDataProvider(): \Generator { - yield ['2011-12-02T00:00:00+01:00', 'release_date', \json_decode('[ + yield ['2011-12-02T00:00:00+01:00', 'release_date', json_decode('[ { "locale": null, "scope": "ecommerce", @@ -149,14 +149,14 @@ public function testNonUniqueLocalizableScopableValue($expectedValue, $attribute public function nonUniqueLocalizableScopableAttributeDataProvider(): \Generator { - yield ['description fr', 'variation_description', \json_decode('[ + yield ['description fr', 'variation_description', json_decode('[ { "locale": "fr_FR", "scope": null, "data": "description fr" } ]', true), 'fr_FR', 'ecommerce']; - yield ['description fr', 'variation_description', \json_decode('[ + yield ['description fr', 'variation_description', json_decode('[ { "locale": "fr_FR", "scope": null, @@ -168,7 +168,7 @@ public function nonUniqueLocalizableScopableAttributeDataProvider(): \Generator "data": "description en" } ]', true), 'fr_FR', 'ecommerce']; - yield ['description en', 'variation_description', \json_decode('[ + yield ['description en', 'variation_description', json_decode('[ { "locale": "fr_FR", "scope": null, @@ -180,7 +180,7 @@ public function nonUniqueLocalizableScopableAttributeDataProvider(): \Generator "data": "description en" } ]', true), 'en_US', 'ecommerce']; - yield ['description en', 'variation_description', \json_decode('[ + yield ['description en', 'variation_description', json_decode('[ { "locale": "fr_FR", "scope": null, diff --git a/tests/PHPUnit/Retriever/FamilyRetrieverTest.php b/tests/PHPUnit/Retriever/FamilyRetrieverTest.php index ab18b9af..47c40892 100644 --- a/tests/PHPUnit/Retriever/FamilyRetrieverTest.php +++ b/tests/PHPUnit/Retriever/FamilyRetrieverTest.php @@ -29,11 +29,11 @@ protected function setUp(): void $this->familyRetriever = self::$container->get(FamilyRetriever::class); $this->server->setResponseOfPath( - '/' . FamilyApi::FAMILIES_URI, + '/'.FamilyApi::FAMILIES_URI, new Response($this->getFileContent('families.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(FamilyVariantApi::FAMILY_VARIANTS_URI, 'clothing'), + '/'.sprintf(FamilyVariantApi::FAMILY_VARIANTS_URI, 'clothing'), new Response($this->getFileContent('family_clothing_variants.json'), [], HttpResponse::HTTP_OK) ); diff --git a/tests/PHPUnit/Task/Attribute/AbstractTaskTest.php b/tests/PHPUnit/Task/Attribute/AbstractTaskTest.php index 27009aba..157073f6 100644 --- a/tests/PHPUnit/Task/Attribute/AbstractTaskTest.php +++ b/tests/PHPUnit/Task/Attribute/AbstractTaskTest.php @@ -29,12 +29,12 @@ protected function setUp(): void $this->manager->flush(); $this->server->setResponseOfPath( - '/' . sprintf(AttributeApi::ATTRIBUTES_URI), + '/'.sprintf(AttributeApi::ATTRIBUTES_URI), new Response($this->getAttributes(), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(LocaleApi::LOCALES_URI), + '/'.sprintf(LocaleApi::LOCALES_URI), new Response($this->getLocales(), [], HttpResponse::HTTP_OK) ); diff --git a/tests/PHPUnit/Task/Attribute/CreateUpdateDeleteTaskTest.php b/tests/PHPUnit/Task/Attribute/CreateUpdateDeleteTaskTest.php index f3e4f549..4334139e 100644 --- a/tests/PHPUnit/Task/Attribute/CreateUpdateDeleteTaskTest.php +++ b/tests/PHPUnit/Task/Attribute/CreateUpdateDeleteTaskTest.php @@ -43,13 +43,17 @@ public function testCreateUpdateTask(): void $task->__invoke($payload); /** @var \Sylius\Component\Product\Model\ProductAttribute $careInstructionProductAttribute */ - $careInstructionProductAttribute = self::$container->get('sylius.repository.product_attribute')->findOneBy(['code' => 'care_instructions']); + $careInstructionProductAttribute = self::$container->get('sylius.repository.product_attribute')->findOneBy([ + 'code' => 'care_instructions', + ]); $this->assertNotNull($careInstructionProductAttribute); $this->assertEquals('Instructions d\'entretien', $careInstructionProductAttribute->getTranslation('fr_FR')->getName()); $this->assertEquals('Care instructions', $careInstructionProductAttribute->getTranslation('en_US')->getName()); /** @var \Sylius\Component\Product\Model\ProductAttribute $colorProductAttribute */ - $colorProductAttribute = self::$container->get('sylius.repository.product_attribute')->findOneBy(['code' => 'color']); + $colorProductAttribute = self::$container->get('sylius.repository.product_attribute')->findOneBy([ + 'code' => 'color', + ]); $this->assertNotNull($colorProductAttribute); $this->assertEquals('Couleur', $colorProductAttribute->getTranslation('fr_FR')->getName()); $this->assertEquals('Color', $colorProductAttribute->getTranslation('en_US')->getName()); @@ -75,7 +79,9 @@ public function testDeleteTask(): void /** @var DeleteEntityTask $deleteTask */ $deleteTask = $this->taskProvider->get(DeleteEntityTask::class); $deleteTask->__invoke($createUpdatePayload); - $oldAttribute = self::$container->get('sylius.repository.product_attribute')->findOneBy(['code' => $attributeToDelete->getCode()]); + $oldAttribute = self::$container->get('sylius.repository.product_attribute')->findOneBy([ + 'code' => $attributeToDelete->getCode(), + ]); $this->assertNull($oldAttribute); } diff --git a/tests/PHPUnit/Task/Attribute/RetrieveAttributesTaskTest.php b/tests/PHPUnit/Task/Attribute/RetrieveAttributesTaskTest.php index dc000187..8f273435 100644 --- a/tests/PHPUnit/Task/Attribute/RetrieveAttributesTaskTest.php +++ b/tests/PHPUnit/Task/Attribute/RetrieveAttributesTaskTest.php @@ -24,7 +24,7 @@ public function testGetAttributes(): void $payload = $task->__invoke($retrieveAttributePayload); $this->assertInstanceOf(AttributePayload::class, $payload); - $content = \json_decode($this->getFileContent('attributes_all.json'), true); + $content = json_decode($this->getFileContent('attributes_all.json'), true); $this->assertCount(\count($content['_embedded']['items']), $payload->getResources()); } } diff --git a/tests/PHPUnit/Task/AttributeOption/AbstractTaskTest.php b/tests/PHPUnit/Task/AttributeOption/AbstractTaskTest.php index 5284eb73..ec109854 100644 --- a/tests/PHPUnit/Task/AttributeOption/AbstractTaskTest.php +++ b/tests/PHPUnit/Task/AttributeOption/AbstractTaskTest.php @@ -26,27 +26,27 @@ protected function setUp(): void $this->manager->flush(); $this->server->setResponseOfPath( - '/' . sprintf(LocaleApi::LOCALES_URI), + '/'.sprintf(LocaleApi::LOCALES_URI), new Response($this->getLocales(), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(AttributeApi::ATTRIBUTES_URI), + '/'.sprintf(AttributeApi::ATTRIBUTES_URI), new Response($this->getFileContent('attributes_for_options.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'clothing_size'), + '/'.sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'clothing_size'), new Response($this->getFileContent('attribute_options_clothing_size.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'collection'), + '/'.sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'collection'), new Response($this->getFileContent('attribute_options_collection.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'color'), + '/'.sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'color'), new Response($this->getFileContent('attribute_options_color.json'), [], HttpResponse::HTTP_OK) ); } diff --git a/tests/PHPUnit/Task/AttributeOption/CreateUpdateDeleteTaskTest.php b/tests/PHPUnit/Task/AttributeOption/CreateUpdateDeleteTaskTest.php index 87202862..fb272f43 100644 --- a/tests/PHPUnit/Task/AttributeOption/CreateUpdateDeleteTaskTest.php +++ b/tests/PHPUnit/Task/AttributeOption/CreateUpdateDeleteTaskTest.php @@ -46,7 +46,9 @@ public function testCreateUpdateTask(): void /** @var \Synolia\SyliusAkeneoPlugin\Repository\ProductAttributeRepository $attributeRepository */ $attributeRepository = self::$container->get('sylius.repository.product_attribute'); /** @var ProductAttribute $productAttribute */ - $productAttribute = $attributeRepository->findOneBy(['code' => 'color']); + $productAttribute = $attributeRepository->findOneBy([ + 'code' => 'color', + ]); $this->assertNotNull($productAttribute); $this->assertProductAttributeTranslations($productAttribute); @@ -63,23 +65,22 @@ private function assertProductAttributeTranslations(ProductAttribute $productAtt private function assertProductAttributeChoices(ProductAttribute $productAttribute): void { $expectedChoiceCodes = [ - AbstractAttributeOptionTask::AKENEO_PREFIX . 'black', - AbstractAttributeOptionTask::AKENEO_PREFIX . 'blue', - AbstractAttributeOptionTask::AKENEO_PREFIX . 'brown', - AbstractAttributeOptionTask::AKENEO_PREFIX . 'green', - AbstractAttributeOptionTask::AKENEO_PREFIX . 'grey', - AbstractAttributeOptionTask::AKENEO_PREFIX . 'orange', - AbstractAttributeOptionTask::AKENEO_PREFIX . 'pink', - AbstractAttributeOptionTask::AKENEO_PREFIX . 'red', - AbstractAttributeOptionTask::AKENEO_PREFIX . 'white', - AbstractAttributeOptionTask::AKENEO_PREFIX . 'yellow', + AbstractAttributeOptionTask::AKENEO_PREFIX.'black', + AbstractAttributeOptionTask::AKENEO_PREFIX.'blue', + AbstractAttributeOptionTask::AKENEO_PREFIX.'brown', + AbstractAttributeOptionTask::AKENEO_PREFIX.'green', + AbstractAttributeOptionTask::AKENEO_PREFIX.'grey', + AbstractAttributeOptionTask::AKENEO_PREFIX.'orange', + AbstractAttributeOptionTask::AKENEO_PREFIX.'pink', + AbstractAttributeOptionTask::AKENEO_PREFIX.'red', + AbstractAttributeOptionTask::AKENEO_PREFIX.'white', + AbstractAttributeOptionTask::AKENEO_PREFIX.'yellow', ]; /** @var array $choices */ $choices = $productAttribute->getConfiguration()['choices']; foreach (array_keys($choices) as $attributeOptionCode) { - $this->assertEquals( - true, + $this->assertTrue( \in_array( $attributeOptionCode, $expectedChoiceCodes, @@ -91,7 +92,7 @@ private function assertProductAttributeChoices(ProductAttribute $productAttribut private function assertProductAttributeChoicesTranslations(ProductAttribute $productAttribute): void { - $blackChoice = $productAttribute->getConfiguration()['choices'][AbstractAttributeOptionTask::AKENEO_PREFIX . 'black']; + $blackChoice = $productAttribute->getConfiguration()['choices'][AbstractAttributeOptionTask::AKENEO_PREFIX.'black']; $this->assertEquals('Noir', $blackChoice['fr_FR']); $this->assertEquals('Black', $blackChoice['en_US']); diff --git a/tests/PHPUnit/Task/AttributeOption/RetrieveOptionsTaskTest.php b/tests/PHPUnit/Task/AttributeOption/RetrieveOptionsTaskTest.php index 90d74860..285bcf0a 100644 --- a/tests/PHPUnit/Task/AttributeOption/RetrieveOptionsTaskTest.php +++ b/tests/PHPUnit/Task/AttributeOption/RetrieveOptionsTaskTest.php @@ -39,7 +39,7 @@ public function testGetOptions(): void /** @var OptionsPayload $optionPayload */ $optionPayload = $task->__invoke($attributesPayload); - $options = \json_decode($this->getFileContent('attributes_for_options.json'), true); + $options = json_decode($this->getFileContent('attributes_for_options.json'), true); $optionCount = \count($options['_embedded']['items']); $this->assertCount($optionCount, $optionPayload->getResources()); diff --git a/tests/PHPUnit/Task/Category/AbstractTaskTest.php b/tests/PHPUnit/Task/Category/AbstractTaskTest.php index 41864202..b992f63e 100644 --- a/tests/PHPUnit/Task/Category/AbstractTaskTest.php +++ b/tests/PHPUnit/Task/Category/AbstractTaskTest.php @@ -30,7 +30,7 @@ protected function setUp(): void $this->manager->flush(); $this->server->setResponseOfPath( - '/' . sprintf(CategoryApi::CATEGORIES_URI), + '/'.sprintf(CategoryApi::CATEGORIES_URI), new ResponseStack( new Response($this->getCategories(), [], HttpResponse::HTTP_OK) ) diff --git a/tests/PHPUnit/Task/Category/CreateUpdateDeleteTaskTest.php b/tests/PHPUnit/Task/Category/CreateUpdateDeleteTaskTest.php index 0e8e402b..88f148cc 100644 --- a/tests/PHPUnit/Task/Category/CreateUpdateDeleteTaskTest.php +++ b/tests/PHPUnit/Task/Category/CreateUpdateDeleteTaskTest.php @@ -27,7 +27,7 @@ protected function setUp(): void parent::setUp(); $this->server->setResponseOfPath( - '/' . sprintf(CategoryApi::CATEGORIES_URI), + '/'.sprintf(CategoryApi::CATEGORIES_URI), new ResponseStack( new Response($this->getCategories(), [], HttpResponse::HTTP_OK) ) @@ -75,7 +75,9 @@ public function testCreateCategories(): void ]; foreach ($expectedTaxonToExists as $expectedTaxonToExist) { - $this->assertNotNull($taxonRepository->findOneBy(['code' => $expectedTaxonToExist])); + $this->assertNotNull($taxonRepository->findOneBy([ + 'code' => $expectedTaxonToExist, + ])); } } @@ -100,7 +102,9 @@ public function testCreateCategoriesWithRootAndExclusions(): void $expectedTaxonToExists = ['clothes', 'pants', 'shoes', 'sweat', 'coats', 'underwear']; foreach ($expectedTaxonToExists as $expectedTaxonToExist) { - $this->assertNotNull($taxonRepository->findOneBy(['code' => $expectedTaxonToExist])); + $this->assertNotNull($taxonRepository->findOneBy([ + 'code' => $expectedTaxonToExist, + ])); } } } diff --git a/tests/PHPUnit/Task/Category/RetrieveCategoriesTaskTest.php b/tests/PHPUnit/Task/Category/RetrieveCategoriesTaskTest.php index 26be564c..281c0587 100644 --- a/tests/PHPUnit/Task/Category/RetrieveCategoriesTaskTest.php +++ b/tests/PHPUnit/Task/Category/RetrieveCategoriesTaskTest.php @@ -33,7 +33,7 @@ protected function setUp(): void parent::setUp(); $this->server->setResponseOfPath( - '/' . sprintf(CategoryApi::CATEGORIES_URI), + '/'.sprintf(CategoryApi::CATEGORIES_URI), new ResponseStack( new Response($this->getCategories(), [], HttpResponse::HTTP_OK) ) diff --git a/tests/PHPUnit/Task/Product/AbstractTaskTest.php b/tests/PHPUnit/Task/Product/AbstractTaskTest.php index 77bf21d0..0c0038a0 100644 --- a/tests/PHPUnit/Task/Product/AbstractTaskTest.php +++ b/tests/PHPUnit/Task/Product/AbstractTaskTest.php @@ -41,80 +41,80 @@ protected function setUp(): void $this->manager->flush(); $this->server->setResponseOfPath( - '/' . sprintf(CategoryApi::CATEGORIES_URI), + '/'.sprintf(CategoryApi::CATEGORIES_URI), new Response($this->getFileContent('categories_all.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(AttributeApi::ATTRIBUTES_URI), + '/'.sprintf(AttributeApi::ATTRIBUTES_URI), new Response($this->getFileContent('attributes_options_apollon.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . FamilyApi::FAMILIES_URI, + '/'.FamilyApi::FAMILIES_URI, new Response($this->getFileContent('families.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(FamilyVariantApi::FAMILY_VARIANTS_URI, 'clothing'), + '/'.sprintf(FamilyVariantApi::FAMILY_VARIANTS_URI, 'clothing'), new Response($this->getFileContent('family_clothing_variants.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'clothing_size'), + '/'.sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'clothing_size'), new Response($this->getFileContent('attribute_options_clothing_size.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'collection'), + '/'.sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'collection'), new Response($this->getFileContent('attribute_options_collection.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'color'), + '/'.sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'color'), new Response($this->getFileContent('attribute_options_color.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'size'), + '/'.sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'size'), new Response($this->getFileContent('attribute_options_size.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'maximum_print_size'), + '/'.sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'maximum_print_size'), new Response($this->getFileContent('attribute_options_maximum_print_size.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'multifunction_functions'), + '/'.sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'multifunction_functions'), new Response($this->getFileContent('attribute_options_multifunction_functions.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(FamilyVariantApi::FAMILY_VARIANT_URI, 'clothing', 'clothing_color_size'), + '/'.sprintf(FamilyVariantApi::FAMILY_VARIANT_URI, 'clothing', 'clothing_color_size'), new Response($this->getFileContent('family_variant_clothing_color_size.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(ProductModelApi::PRODUCT_MODELS_URI), + '/'.sprintf(ProductModelApi::PRODUCT_MODELS_URI), new Response($this->getFileContent('product_models_apollon.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(ProductApi::PRODUCTS_URI), + '/'.sprintf(ProductApi::PRODUCTS_URI), new Response($this->getFileContent('products_all.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(ProductMediaFileApi::MEDIA_FILE_DOWNLOAD_URI, '6/3/5/c/635cbfe306a1c13867fe7671c110ee3333fcba13_bag.jpg'), + '/'.sprintf(ProductMediaFileApi::MEDIA_FILE_DOWNLOAD_URI, '6/3/5/c/635cbfe306a1c13867fe7671c110ee3333fcba13_bag.jpg'), new Response($this->getFileContent('product_1111111171.jpg'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(LocaleApi::LOCALES_URI), + '/'.sprintf(LocaleApi::LOCALES_URI), new Response($this->getFileContent('locales.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(FamilyApi::FAMILY_URI, 'clothing'), + '/'.sprintf(FamilyApi::FAMILY_URI, 'clothing'), new Response($this->getFileContent('family_clothing.json'), [], HttpResponse::HTTP_OK) ); } @@ -178,14 +178,14 @@ protected function createProductConfiguration(): void protected function countTotalProducts(bool $isSimple): int { - $query = $this->manager->getConnection()->prepare(\sprintf( + $query = $this->manager->getConnection()->prepare(sprintf( 'SELECT count(id) FROM `%s` WHERE is_simple = :is_simple', ProductPayload::TEMP_AKENEO_TABLE_NAME )); $query->bindValue('is_simple', $isSimple, ParameterType::BOOLEAN); $query->execute(); - return (int) \current($query->fetch()); + return (int) current($query->fetch()); } protected function prepareSelectQuery( @@ -193,7 +193,7 @@ protected function prepareSelectQuery( int $limit = ProductPayload::SELECT_PAGINATION_SIZE, int $offset = 0 ): Statement { - $query = $this->manager->getConnection()->prepare(\sprintf( + $query = $this->manager->getConnection()->prepare(sprintf( 'SELECT `values` FROM `%s` WHERE is_simple = :is_simple diff --git a/tests/PHPUnit/Task/Product/CreateConfigurableProductEntitiesTaskTest.php b/tests/PHPUnit/Task/Product/CreateConfigurableProductEntitiesTaskTest.php index f9270876..ecd2b9a3 100644 --- a/tests/PHPUnit/Task/Product/CreateConfigurableProductEntitiesTaskTest.php +++ b/tests/PHPUnit/Task/Product/CreateConfigurableProductEntitiesTaskTest.php @@ -109,7 +109,9 @@ public function testCreateConfigurableProductsTask(): void foreach ($productsToTest as $productToTest) { /** @var \Sylius\Component\Core\Model\ProductVariantInterface $productVariant */ - $productVariant = $productVariantRepository->findOneBy(['code' => $productToTest['code']]); + $productVariant = $productVariantRepository->findOneBy([ + 'code' => $productToTest['code'], + ]); $this->assertNotNull($productVariant); //Testing product attribute translations inside models @@ -125,7 +127,7 @@ public function testCreateConfigurableProductsTask(): void //Testing product attribute translations foreach ($productVariant->getOptionValues() as $optionValue) { - if (!'size_' . $productToTest['attributes']['size'] === $optionValue->getCode()) { + if (!'size_'.$productToTest['attributes']['size'] === $optionValue->getCode()) { continue; } $productOptionValueTranslation = $productOptionValueTranslationRepository->findOneBy([ diff --git a/tests/PHPUnit/Task/Product/CreateSimpleProductEntitiesTaskTest.php b/tests/PHPUnit/Task/Product/CreateSimpleProductEntitiesTaskTest.php index 0e7d7084..1eeb4543 100644 --- a/tests/PHPUnit/Task/Product/CreateSimpleProductEntitiesTaskTest.php +++ b/tests/PHPUnit/Task/Product/CreateSimpleProductEntitiesTaskTest.php @@ -89,7 +89,9 @@ public function testCreateSimpleProductsTask(): void $createSimpleProductEntitiesTask->__invoke($productPayload); /** @var \Sylius\Component\Core\Model\ProductInterface $product */ - $product = self::$container->get('sylius.repository.product')->findOneBy(['code' => '1111111171']); + $product = self::$container->get('sylius.repository.product')->findOneBy([ + 'code' => '1111111171', + ]); $this->assertNotNull($product); //Testing product attribute translations inside models @@ -115,7 +117,9 @@ public function testCreateSimpleProductsTask(): void //Testing simple variant /** @var \Sylius\Component\Core\Model\ProductVariantInterface $productVariant */ - $productVariant = self::$container->get('sylius.repository.product_variant')->findOneBy(['code' => $product->getCode()]); + $productVariant = self::$container->get('sylius.repository.product_variant')->findOneBy([ + 'code' => $product->getCode(), + ]); $this->assertNotNull($productVariant); $this->assertEquals(self::$container->get('sylius.repository.channel')->count([]), $productVariant->getChannelPricings()->count()); @@ -125,7 +129,9 @@ public function testCreateSimpleProductsTask(): void } /** @var \Sylius\Component\Product\Model\ProductAttributeValueInterface $referenceEntityAttribute */ - $referenceEntityAttribute = $productAttributeRepository->findOneBy(['code' => 'test_entite_couleur']); + $referenceEntityAttribute = $productAttributeRepository->findOneBy([ + 'code' => 'test_entite_couleur', + ]); /** @var \Sylius\Component\Product\Model\ProductAttributeValueInterface $referenceEntityAttributeValue */ $referenceEntityAttributeValue = $productAttributeValueRepository->findOneBy([ @@ -136,7 +142,7 @@ public function testCreateSimpleProductsTask(): void $this->assertNotNull($referenceEntityAttributeValue); $this->assertSame( - \json_decode('{"code":"noir","attributes":{"label":"BLANC","image":"e\/b\/4\/d\/eb4d25582151b684acd7f18f68b1db5314786233_blanc.png","filtre_couleur_1":"noir"}}', true), + json_decode('{"code":"noir","attributes":{"label":"BLANC","image":"e\/b\/4\/d\/eb4d25582151b684acd7f18f68b1db5314786233_blanc.png","filtre_couleur_1":"noir"}}', true), $referenceEntityAttributeValue->getValue() ); } @@ -145,19 +151,19 @@ public function createSimpleProductsWithMultiSelectCheckboxDataProvider(): \Gene { yield [ '11834327', - CreateUpdateDeleteTask::AKENEO_PREFIX . 'legal_216_x_356_mm_', + CreateUpdateDeleteTask::AKENEO_PREFIX.'legal_216_x_356_mm_', [ - CreateUpdateDeleteTask::AKENEO_PREFIX . 'copy', - CreateUpdateDeleteTask::AKENEO_PREFIX . 'n', - CreateUpdateDeleteTask::AKENEO_PREFIX . 'scan', + CreateUpdateDeleteTask::AKENEO_PREFIX.'copy', + CreateUpdateDeleteTask::AKENEO_PREFIX.'n', + CreateUpdateDeleteTask::AKENEO_PREFIX.'scan', ], true, ]; yield [ '123456789', - CreateUpdateDeleteTask::AKENEO_PREFIX . 'legal_216_x_356_mm_', - [CreateUpdateDeleteTask::AKENEO_PREFIX . 'copy'], + CreateUpdateDeleteTask::AKENEO_PREFIX.'legal_216_x_356_mm_', + [CreateUpdateDeleteTask::AKENEO_PREFIX.'copy'], false, ]; } @@ -190,7 +196,9 @@ public function testCreateSimpleProductsWithMultiSelectCheckboxTask( $createSimpleProductEntitiesTask->__invoke($productPayload); /** @var \Sylius\Component\Core\Model\ProductInterface $product */ - $product = self::$container->get('sylius.repository.product')->findOneBy(['code' => $productId]); + $product = self::$container->get('sylius.repository.product')->findOneBy([ + 'code' => $productId, + ]); $this->assertNotNull($product); $this->assertNotEmpty($product->getAttributes()); @@ -212,12 +220,12 @@ public function testCreateSimpleProductsWithMultiSelectCheckboxTask( private function initializeProductWithMultiSelectAndCheckbox(): void { $this->server->setResponseOfPath( - '/' . sprintf(ProductApi::PRODUCTS_URI), + '/'.sprintf(ProductApi::PRODUCTS_URI), new Response($this->getFileContent('products_attributes_value_test.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(AttributeApi::ATTRIBUTES_URI), + '/'.sprintf(AttributeApi::ATTRIBUTES_URI), new Response($this->getFileContent('attributes_for_products_attributes_value_test.json'), [], HttpResponse::HTTP_OK) ); @@ -244,7 +252,9 @@ private function importCategories(): void $categories = ['master_accessories_bags', 'print_accessories', 'supplier_zaro']; foreach ($categories as $categoryCode) { - $category = self::$container->get('sylius.repository.taxon')->findOneBy(['code' => $categoryCode]); + $category = self::$container->get('sylius.repository.taxon')->findOneBy([ + 'code' => $categoryCode, + ]); if (!$category instanceof TaxonInterface) { /** @var Taxon $category */ @@ -263,27 +273,27 @@ private function importCategories(): void private function importReferenceEntities() { $this->server->setResponseOfPath( - '/' . sprintf(LocaleApi::LOCALES_URI), + '/'.sprintf(LocaleApi::LOCALES_URI), new Response($this->getFileContent('locales.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(ReferenceEntityRecordApi::REFERENCE_ENTITY_RECORDS_URI, 'couleur'), + '/'.sprintf(ReferenceEntityRecordApi::REFERENCE_ENTITY_RECORDS_URI, 'couleur'), new Response($this->getFileContent('entity_couleur_records.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(ReferenceEntityAttributeApi::REFERENCE_ENTITY_ATTRIBUTES_URI, 'couleur'), + '/'.sprintf(ReferenceEntityAttributeApi::REFERENCE_ENTITY_ATTRIBUTES_URI, 'couleur'), new Response($this->getFileContent('entity_couleur_attributes.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(ReferenceEntityAttributeOptionApi::REFERENCE_ENTITY_ATTRIBUTE_OPTIONS_URI, 'couleur', 'filtre_couleur_1'), + '/'.sprintf(ReferenceEntityAttributeOptionApi::REFERENCE_ENTITY_ATTRIBUTE_OPTIONS_URI, 'couleur', 'filtre_couleur_1'), new Response($this->getFileContent('entity_couleur_filtre_couleur_1_options.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(ReferenceEntityRecordApi::REFERENCE_ENTITY_RECORD_URI, 'couleur', 'noir'), + '/'.sprintf(ReferenceEntityRecordApi::REFERENCE_ENTITY_RECORD_URI, 'couleur', 'noir'), new Response($this->getFileContent('reference_entity_couleur_record_noir.json'), [], HttpResponse::HTTP_OK) ); } diff --git a/tests/PHPUnit/Task/Product/EnableDisableProductTaskTest.php b/tests/PHPUnit/Task/Product/EnableDisableProductTaskTest.php index 103cfb80..a26e111f 100644 --- a/tests/PHPUnit/Task/Product/EnableDisableProductTaskTest.php +++ b/tests/PHPUnit/Task/Product/EnableDisableProductTaskTest.php @@ -76,10 +76,14 @@ public function testEnableDisableProduct(): void $enableDisableProductTask->__invoke($simpleProductCreationPayload); /** @var \Sylius\Component\Core\Model\ProductInterface $product */ - $product = self::$container->get('sylius.repository.product')->findOneBy(['code' => '1111111171']); + $product = self::$container->get('sylius.repository.product')->findOneBy([ + 'code' => '1111111171', + ]); $this->assertCount(1, $product->getChannels()); - $channel = self::$container->get('sylius.repository.channel')->findOneBy(['code' => 'FASHION_WEB']); + $channel = self::$container->get('sylius.repository.channel')->findOneBy([ + 'code' => 'FASHION_WEB', + ]); $this->assertContains($channel, $product->getChannels()); } @@ -100,7 +104,9 @@ private function importCategories(): void $categories = ['master_accessories_bags', 'print_accessories', 'supplier_zaro']; foreach ($categories as $categoryCode) { - $category = self::$container->get('sylius.repository.taxon')->findOneBy(['code' => $categoryCode]); + $category = self::$container->get('sylius.repository.taxon')->findOneBy([ + 'code' => $categoryCode, + ]); if (!$category instanceof TaxonInterface) { /** @var Taxon $category */ diff --git a/tests/PHPUnit/Task/ProductModel/AbstractTaskTest.php b/tests/PHPUnit/Task/ProductModel/AbstractTaskTest.php index c2022db0..ee34d7d8 100644 --- a/tests/PHPUnit/Task/ProductModel/AbstractTaskTest.php +++ b/tests/PHPUnit/Task/ProductModel/AbstractTaskTest.php @@ -34,17 +34,17 @@ protected function setUp(): void $this->manager->flush(); $this->server->setResponseOfPath( - '/' . sprintf(AttributeApi::ATTRIBUTES_URI), + '/'.sprintf(AttributeApi::ATTRIBUTES_URI), new Response($this->getFileContent('attributes_options_apollon.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(ProductModelApi::PRODUCT_MODELS_URI), + '/'.sprintf(ProductModelApi::PRODUCT_MODELS_URI), new Response($this->getFileContent('product_models_apollon.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(LocaleApi::LOCALES_URI), + '/'.sprintf(LocaleApi::LOCALES_URI), new Response($this->getFileContent('locales.json'), [], HttpResponse::HTTP_OK) ); } @@ -90,20 +90,20 @@ protected function createProductConfiguration(): void protected function countTotalProducts(): int { - $query = $this->manager->getConnection()->prepare(\sprintf( + $query = $this->manager->getConnection()->prepare(sprintf( 'SELECT count(id) FROM `%s`', ProductModelPayload::TEMP_AKENEO_TABLE_NAME )); $query->execute(); - return (int) \current($query->fetch()); + return (int) current($query->fetch()); } protected function prepareSelectQuery( int $limit = ProductPayload::SELECT_PAGINATION_SIZE, int $offset = 0 ): Statement { - $query = $this->manager->getConnection()->prepare(\sprintf( + $query = $this->manager->getConnection()->prepare(sprintf( 'SELECT `values` FROM `%s` LIMIT :limit diff --git a/tests/PHPUnit/Task/ProductModel/AddFamilyVariationAxeTaskTest.php b/tests/PHPUnit/Task/ProductModel/AddFamilyVariationAxeTaskTest.php index c9c7ae30..0b3eee31 100644 --- a/tests/PHPUnit/Task/ProductModel/AddFamilyVariationAxeTaskTest.php +++ b/tests/PHPUnit/Task/ProductModel/AddFamilyVariationAxeTaskTest.php @@ -39,11 +39,11 @@ protected function setUp(): void $this->taskProvider = self::$container->get(AkeneoTaskProvider::class); $this->productGroupRepository = self::$container->get('akeneo.repository.product_group'); $this->server->setResponseOfPath( - '/' . sprintf(FamilyVariantApi::FAMILY_VARIANT_URI, 'clothing', 'clothing_color_size'), + '/'.sprintf(FamilyVariantApi::FAMILY_VARIANT_URI, 'clothing', 'clothing_color_size'), new Response($this->getFileContent('family_variant_clothing_color_size.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(ProductModelApi::PRODUCT_MODELS_URI), + '/'.sprintf(ProductModelApi::PRODUCT_MODELS_URI), new Response($this->getFileContent('product_models_caelus.json'), [], HttpResponse::HTTP_OK) ); @@ -64,7 +64,9 @@ public function testAddOrUpdateProductModelTask(): void $addProductGroupsTask = $this->taskProvider->get(AddProductGroupsTask::class); $productGroupsPayload = $addProductGroupsTask->__invoke($productsPayload); /** @var ProductGroup $productGroup */ - $productGroup = $this->productGroupRepository->findOneBy(['productParent' => 'caelus']); + $productGroup = $this->productGroupRepository->findOneBy([ + 'productParent' => 'caelus', + ]); Assert::assertInstanceOf(ProductGroup::class, $productGroup); /** @var AddFamilyVariationAxeTask $addFamilyVariationAxes */ @@ -74,14 +76,14 @@ public function testAddOrUpdateProductModelTask(): void Assert::assertNotEmpty($productGroup->getVariationAxes()); $this->server->setResponseOfPath( - '/' . sprintf(FamilyVariantApi::FAMILY_VARIANT_URI, 'clothing', 'clothing_color_size'), + '/'.sprintf(FamilyVariantApi::FAMILY_VARIANT_URI, 'clothing', 'clothing_color_size'), new ResponseStack( new Response($this->getFileContent('family_variant_clothing_color_size.json'), [], HttpResponse::HTTP_OK) ) ); $familyVariant = $productsPayload->getAkeneoPimClient()->getFamilyVariantApi()->get('clothing', 'clothing_color_size'); foreach ($familyVariant['variant_attribute_sets'] as $key => $variantAttributeSet) { - if (count($familyVariant['variant_attribute_sets']) !== $variantAttributeSet['level']) { + if (\count($familyVariant['variant_attribute_sets']) !== $variantAttributeSet['level']) { continue; } foreach ($variantAttributeSet['axes'] as $axe) { diff --git a/tests/PHPUnit/Task/ProductModel/AddOrUpdateProductModelTaskTest.php b/tests/PHPUnit/Task/ProductModel/AddOrUpdateProductModelTaskTest.php index d432aea5..6803b49a 100644 --- a/tests/PHPUnit/Task/ProductModel/AddOrUpdateProductModelTaskTest.php +++ b/tests/PHPUnit/Task/ProductModel/AddOrUpdateProductModelTaskTest.php @@ -67,7 +67,7 @@ public function testCreateUpdateTask(): void while ($results = $query->fetchAll()) { foreach ($results as $result) { - $resource = \json_decode($result['values'], true); + $resource = json_decode($result['values'], true); if (null === $resource['parent']) { continue; @@ -88,14 +88,18 @@ public function testCreateUpdateTask(): void Assert::assertInstanceOf(PipelinePayloadInterface::class, $result); /** @var Product $productFinal */ - $productFinal = $this->productRepository->findOneBy(['code' => $productBase['code']]); + $productFinal = $this->productRepository->findOneBy([ + 'code' => $productBase['code'], + ]); Assert::assertInstanceOf(Product::class, $productFinal); $this->assertGreaterThan(0, $productFinal->getImages()->count()); foreach ($productFinal->getImages() as $image) { - $this->assertFileExists(self::$kernel->getProjectDir() . '/public/media/image/' . $image->getPath()); + $this->assertFileExists(self::$kernel->getProjectDir().'/public/media/image/'.$image->getPath()); } - $productGroup = $this->productGroupRepository->findOneBy(['productParent' => $productBase['parent']]); + $productGroup = $this->productGroupRepository->findOneBy([ + 'productParent' => $productBase['parent'], + ]); Assert::assertInstanceOf(ProductGroup::class, $productGroup); } diff --git a/tests/PHPUnit/Task/ProductModel/EnableDisableProductModelTaskTest.php b/tests/PHPUnit/Task/ProductModel/EnableDisableProductModelTaskTest.php index b26b1b17..e92f6219 100644 --- a/tests/PHPUnit/Task/ProductModel/EnableDisableProductModelTaskTest.php +++ b/tests/PHPUnit/Task/ProductModel/EnableDisableProductModelTaskTest.php @@ -52,7 +52,7 @@ public function testEnableDisableProductModelTask(): void while ($results = $query->fetchAll()) { foreach ($results as $result) { - $resource = \json_decode($result['values'], true); + $resource = json_decode($result['values'], true); if (null === $resource['parent']) { continue; @@ -76,9 +76,13 @@ public function testEnableDisableProductModelTask(): void $enableDisableProductModelTask->__invoke($productModelPayload); /** @var Product $product */ - $product = self::$container->get('sylius.repository.product')->findOneBy(['code' => $productBase['code']]); + $product = self::$container->get('sylius.repository.product')->findOneBy([ + 'code' => $productBase['code'], + ]); $this->assertCount(1, $product->getChannels()); - $channel = self::$container->get('sylius.repository.channel')->findOneBy(['code' => 'FASHION_WEB']); + $channel = self::$container->get('sylius.repository.channel')->findOneBy([ + 'code' => 'FASHION_WEB', + ]); $this->assertContains($channel, $product->getChannels()); } } diff --git a/tests/PHPUnit/Task/ProductOption/AbstractTaskTest.php b/tests/PHPUnit/Task/ProductOption/AbstractTaskTest.php index 24899d75..5df8d58d 100644 --- a/tests/PHPUnit/Task/ProductOption/AbstractTaskTest.php +++ b/tests/PHPUnit/Task/ProductOption/AbstractTaskTest.php @@ -23,32 +23,32 @@ protected function setUp(): void $this->manager->beginTransaction(); $this->server->setResponseOfPath( - '/' . sprintf(AttributeApi::ATTRIBUTES_URI), + '/'.sprintf(AttributeApi::ATTRIBUTES_URI), new Response($this->getFileContent('attributes_for_options.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'clothing_size'), + '/'.sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'clothing_size'), new Response($this->getFileContent('attribute_options_clothing_size.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'collection'), + '/'.sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'collection'), new Response($this->getFileContent('attribute_options_collection.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'color'), + '/'.sprintf(AttributeOptionApi::ATTRIBUTE_OPTIONS_URI, 'color'), new Response($this->getFileContent('attribute_options_color.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . FamilyApi::FAMILIES_URI, + '/'.FamilyApi::FAMILIES_URI, new Response($this->getFileContent('families.json'), [], HttpResponse::HTTP_OK) ); $this->server->setResponseOfPath( - '/' . sprintf(FamilyVariantApi::FAMILY_VARIANTS_URI, 'clothing'), + '/'.sprintf(FamilyVariantApi::FAMILY_VARIANTS_URI, 'clothing'), new Response($this->getFileContent('family_clothing_variants.json'), [], HttpResponse::HTTP_OK) ); } diff --git a/tests/PHPUnit/Task/ProductOption/CreateUpdateTaskTest.php b/tests/PHPUnit/Task/ProductOption/CreateUpdateTaskTest.php index 889fa93e..8b56a14e 100644 --- a/tests/PHPUnit/Task/ProductOption/CreateUpdateTaskTest.php +++ b/tests/PHPUnit/Task/ProductOption/CreateUpdateTaskTest.php @@ -34,7 +34,7 @@ protected function setUp(): void $this->taskProvider = self::$container->get(AkeneoTaskProvider::class); $this->server->setResponseOfPath( - '/' . sprintf(LocaleApi::LOCALES_URI), + '/'.sprintf(LocaleApi::LOCALES_URI), new Response($this->getFileContent('locales.json'), [], HttpResponse::HTTP_OK) ); } @@ -61,7 +61,9 @@ public function testCreateUpdateTask(): void $productOptionRepository = self::$container->get('sylius.repository.product_option'); /** @var \Sylius\Component\Product\Model\ProductOptionInterface $productOption */ - $productOption = $productOptionRepository->findOneBy(['code' => 'color']); + $productOption = $productOptionRepository->findOneBy([ + 'code' => 'color', + ]); $this->assertNotNull($productOption); $this->assertProductOptionTranslations($productOption); @@ -93,23 +95,22 @@ private function assertProductOptionTranslations(ProductOption $productOption): private function assertProductOptionValues(ProductOption $productOption): void { $expectedValueCodes = [ - 'color_' . AbstractAttributeOptionTask::AKENEO_PREFIX . 'black', - 'color_' . AbstractAttributeOptionTask::AKENEO_PREFIX . 'blue', - 'color_' . AbstractAttributeOptionTask::AKENEO_PREFIX . 'brown', - 'color_' . AbstractAttributeOptionTask::AKENEO_PREFIX . 'green', - 'color_' . AbstractAttributeOptionTask::AKENEO_PREFIX . 'grey', - 'color_' . AbstractAttributeOptionTask::AKENEO_PREFIX . 'orange', - 'color_' . AbstractAttributeOptionTask::AKENEO_PREFIX . 'pink', - 'color_' . AbstractAttributeOptionTask::AKENEO_PREFIX . 'red', - 'color_' . AbstractAttributeOptionTask::AKENEO_PREFIX . 'white', - 'color_' . AbstractAttributeOptionTask::AKENEO_PREFIX . 'yellow', + 'color_'.AbstractAttributeOptionTask::AKENEO_PREFIX.'black', + 'color_'.AbstractAttributeOptionTask::AKENEO_PREFIX.'blue', + 'color_'.AbstractAttributeOptionTask::AKENEO_PREFIX.'brown', + 'color_'.AbstractAttributeOptionTask::AKENEO_PREFIX.'green', + 'color_'.AbstractAttributeOptionTask::AKENEO_PREFIX.'grey', + 'color_'.AbstractAttributeOptionTask::AKENEO_PREFIX.'orange', + 'color_'.AbstractAttributeOptionTask::AKENEO_PREFIX.'pink', + 'color_'.AbstractAttributeOptionTask::AKENEO_PREFIX.'red', + 'color_'.AbstractAttributeOptionTask::AKENEO_PREFIX.'white', + 'color_'.AbstractAttributeOptionTask::AKENEO_PREFIX.'yellow', ]; $values = $productOption->getValues(); /** @var \Sylius\Component\Product\Model\ProductOptionValue $value */ foreach ($values as $value) { - $this->assertEquals( - true, + $this->assertTrue( \in_array( $value->getCode(), $expectedValueCodes, @@ -128,11 +129,14 @@ private function assertProductOptionValuesTranslations(ProductOption $productOpt /** @var \Sylius\Component\Product\Model\ProductOptionValue $productOptionValue */ $productOptionValue = $productOptionValueRepository->findOneBy([ - 'code' => ProductOptionManager::getOptionValueCodeFromProductOption($productOption, AbstractAttributeOptionTask::AKENEO_PREFIX . 'black'), + 'code' => ProductOptionManager::getOptionValueCodeFromProductOption($productOption, AbstractAttributeOptionTask::AKENEO_PREFIX.'black'), 'option' => $productOption, ]); - $expectedTranslations = ['fr_FR' => 'Noir', 'en_US' => 'Black']; + $expectedTranslations = [ + 'fr_FR' => 'Noir', + 'en_US' => 'Black', + ]; foreach ($expectedTranslations as $locale => $translationValue) { $translation = $productOptionValueTranslationRepository->findOneBy([ diff --git a/tests/PHPUnit/Task/ProductOption/DeleteTaskTest.php b/tests/PHPUnit/Task/ProductOption/DeleteTaskTest.php index 4a1893a7..6f3d4091 100644 --- a/tests/PHPUnit/Task/ProductOption/DeleteTaskTest.php +++ b/tests/PHPUnit/Task/ProductOption/DeleteTaskTest.php @@ -46,7 +46,9 @@ public function testDeleteOptionTask(): void $productOptionRepository = self::$container->get('sylius.repository.product_option'); /** @var \Sylius\Component\Product\Model\ProductOptionInterface $productOption */ - $productOption = $productOptionRepository->findOneBy(['code' => 'fakeCode']); + $productOption = $productOptionRepository->findOneBy([ + 'code' => 'fakeCode', + ]); $this->assertNull($productOption); }