Skip to content

Commit

Permalink
fix ecs
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGrimmChester committed Jul 26, 2021
1 parent 94a52a0 commit 8c82911
Show file tree
Hide file tree
Showing 109 changed files with 533 additions and 375 deletions.
13 changes: 8 additions & 5 deletions ruleset/ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
8 changes: 5 additions & 3 deletions src/Controller/AttributesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/ProductsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]);
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/DependencyInjection/SynoliaSyliusAkeneoExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/ApiConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/Entity/ProductConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, ChannelInterface>
* @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;
Expand Down
8 changes: 4 additions & 4 deletions src/Entity/ProductFiltersRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Entity/ProductGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
24 changes: 15 additions & 9 deletions src/Filter/ProductFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down Expand Up @@ -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())) {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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(),
]
);
Expand Down
4 changes: 2 additions & 2 deletions src/Form/DataTransformer/ReferenceEntityDataTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand All @@ -22,6 +22,6 @@ public function transform($value): string

public function reverseTransform($value): ?array
{
return \json_decode($value, true);
return json_decode($value, true);
}
}
8 changes: 6 additions & 2 deletions src/Form/Type/ApiConfigurationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
])
;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Type/AttributeCodeChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
4 changes: 3 additions & 1 deletion src/Form/Type/AttributeTypeChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]));
}

/**
Expand Down
Loading

0 comments on commit 8c82911

Please sign in to comment.