From eeb1ed9211ac9a2e0dd63ea3c3593da1c74b38e8 Mon Sep 17 00:00:00 2001 From: Maxime Huran Date: Sat, 13 Jul 2024 14:35:53 +0200 Subject: [PATCH] Fix PHP CS --- dist/src/Search/Automapper/TaxonMapperConfiguration.php | 4 ++-- generated/Normalizer/ChannelDTONormalizer.php | 2 -- generated/Normalizer/ImageDTONormalizer.php | 2 -- generated/Normalizer/JaneObjectNormalizer.php | 6 ++---- generated/Normalizer/PricingDTONormalizer.php | 2 -- generated/Normalizer/ProductAttributeDTONormalizer.php | 2 -- generated/Normalizer/ProductTaxonDTONormalizer.php | 2 -- generated/Normalizer/TaxonDTONormalizer.php | 2 -- src/AutoMapper/ProductAttributeValueConfiguration.php | 3 ++- .../ProductAttributeValueReader/DateTimeReader.php | 3 ++- src/Checker/ElasticsearchChecker.php | 3 ++- src/Index/Indexer.php | 5 +++-- src/Message/ProductReindexFromTaxon.php | 2 +- src/MessageHandler/ProductReindexFromTaxonHandler.php | 2 +- src/Model/Documentable/Documentable.php | 1 - src/Normalizer/Product/ProductDTONormalizer.php | 1 - src/Repository/ProductAttributeRepository.php | 2 +- src/Repository/ProductOptionRepository.php | 2 +- src/Search/Request/Aggregation/MainTaxonAggregation.php | 2 +- src/Search/Request/Aggregation/PriceAggregation.php | 2 +- src/Search/Request/Aggregation/ProductOptionAggregation.php | 4 ++-- src/Search/Request/Aggregation/TaxonsAggregation.php | 2 +- 22 files changed, 22 insertions(+), 34 deletions(-) diff --git a/dist/src/Search/Automapper/TaxonMapperConfiguration.php b/dist/src/Search/Automapper/TaxonMapperConfiguration.php index a9647679..1ef28fd0 100644 --- a/dist/src/Search/Automapper/TaxonMapperConfiguration.php +++ b/dist/src/Search/Automapper/TaxonMapperConfiguration.php @@ -113,9 +113,9 @@ private function getRealTaxonEntity(TaxonInterface $taxon): TaxonInterface { if ($taxon instanceof Proxy) { // Clear the entity manager to detach the proxy object - $this->entityManager->clear(\get_class($taxon)); + $this->entityManager->clear($taxon::class); // Retrieve the original class name - $entityClassName = ClassUtils::getRealClass(\get_class($taxon)); + $entityClassName = ClassUtils::getRealClass($taxon::class); // Find the object in repository from the ID /** @var ?TaxonInterface $taxon */ $taxon = $this->entityManager->find($entityClassName, $taxon->getId()); diff --git a/generated/Normalizer/ChannelDTONormalizer.php b/generated/Normalizer/ChannelDTONormalizer.php index c5b96b76..2ede3929 100644 --- a/generated/Normalizer/ChannelDTONormalizer.php +++ b/generated/Normalizer/ChannelDTONormalizer.php @@ -25,9 +25,7 @@ class ChannelDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { use CheckArray; - use DenormalizerAwareTrait; - use NormalizerAwareTrait; public function supportsDenormalization($data, $type, $format = null) diff --git a/generated/Normalizer/ImageDTONormalizer.php b/generated/Normalizer/ImageDTONormalizer.php index 6b2acde5..910779c0 100644 --- a/generated/Normalizer/ImageDTONormalizer.php +++ b/generated/Normalizer/ImageDTONormalizer.php @@ -25,9 +25,7 @@ class ImageDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { use CheckArray; - use DenormalizerAwareTrait; - use NormalizerAwareTrait; public function supportsDenormalization($data, $type, $format = null) diff --git a/generated/Normalizer/JaneObjectNormalizer.php b/generated/Normalizer/JaneObjectNormalizer.php index 48f7047c..e9ce3c27 100644 --- a/generated/Normalizer/JaneObjectNormalizer.php +++ b/generated/Normalizer/JaneObjectNormalizer.php @@ -24,9 +24,7 @@ class JaneObjectNormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { use CheckArray; - use DenormalizerAwareTrait; - use NormalizerAwareTrait; protected $normalizers = ['MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\ImageDTO' => 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Normalizer\\ImageDTONormalizer', 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\ChannelDTO' => 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Normalizer\\ChannelDTONormalizer', 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\ProductTaxonDTO' => 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Normalizer\\ProductTaxonDTONormalizer', 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\TaxonDTO' => 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Normalizer\\TaxonDTONormalizer', 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\ProductAttributeDTO' => 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Normalizer\\ProductAttributeDTONormalizer', 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Model\\PricingDTO' => 'MonsieurBiz\\SyliusSearchPlugin\\Generated\\Normalizer\\PricingDTONormalizer', '\\Jane\\Component\\JsonSchemaRuntime\\Reference' => '\\MonsieurBiz\\SyliusSearchPlugin\\Generated\\Runtime\\Normalizer\\ReferenceNormalizer']; @@ -40,12 +38,12 @@ public function supportsDenormalization($data, $type, $format = null) public function supportsNormalization($data, $format = null) { - return \is_object($data) && \array_key_exists(\get_class($data), $this->normalizers); + return \is_object($data) && \array_key_exists($data::class, $this->normalizers); } public function normalize($object, $format = null, array $context = []) { - $normalizerClass = $this->normalizers[\get_class($object)]; + $normalizerClass = $this->normalizers[$object::class]; $normalizer = $this->getNormalizer($normalizerClass); return $normalizer->normalize($object, $format, $context); diff --git a/generated/Normalizer/PricingDTONormalizer.php b/generated/Normalizer/PricingDTONormalizer.php index b556b93b..69183914 100644 --- a/generated/Normalizer/PricingDTONormalizer.php +++ b/generated/Normalizer/PricingDTONormalizer.php @@ -25,9 +25,7 @@ class PricingDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { use CheckArray; - use DenormalizerAwareTrait; - use NormalizerAwareTrait; public function supportsDenormalization($data, $type, $format = null) diff --git a/generated/Normalizer/ProductAttributeDTONormalizer.php b/generated/Normalizer/ProductAttributeDTONormalizer.php index 7936b408..f101084a 100644 --- a/generated/Normalizer/ProductAttributeDTONormalizer.php +++ b/generated/Normalizer/ProductAttributeDTONormalizer.php @@ -25,9 +25,7 @@ class ProductAttributeDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { use CheckArray; - use DenormalizerAwareTrait; - use NormalizerAwareTrait; public function supportsDenormalization($data, $type, $format = null) diff --git a/generated/Normalizer/ProductTaxonDTONormalizer.php b/generated/Normalizer/ProductTaxonDTONormalizer.php index c9831949..2201b2ea 100644 --- a/generated/Normalizer/ProductTaxonDTONormalizer.php +++ b/generated/Normalizer/ProductTaxonDTONormalizer.php @@ -25,9 +25,7 @@ class ProductTaxonDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { use CheckArray; - use DenormalizerAwareTrait; - use NormalizerAwareTrait; public function supportsDenormalization($data, $type, $format = null) diff --git a/generated/Normalizer/TaxonDTONormalizer.php b/generated/Normalizer/TaxonDTONormalizer.php index c7ac195c..95e88f37 100644 --- a/generated/Normalizer/TaxonDTONormalizer.php +++ b/generated/Normalizer/TaxonDTONormalizer.php @@ -25,9 +25,7 @@ class TaxonDTONormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { use CheckArray; - use DenormalizerAwareTrait; - use NormalizerAwareTrait; public function supportsDenormalization($data, $type, $format = null) diff --git a/src/AutoMapper/ProductAttributeValueConfiguration.php b/src/AutoMapper/ProductAttributeValueConfiguration.php index e9030893..546be708 100644 --- a/src/AutoMapper/ProductAttributeValueConfiguration.php +++ b/src/AutoMapper/ProductAttributeValueConfiguration.php @@ -22,6 +22,7 @@ use Psr\Log\NullLogger; use RuntimeException; use Sylius\Component\Product\Model\ProductAttributeValueInterface; +use Traversable; final class ProductAttributeValueConfiguration implements MapperConfigurationInterface, LoggerAwareInterface { @@ -38,7 +39,7 @@ public function __construct(ConfigurationInterface $configuration, iterable $pro { $this->logger = new NullLogger(); $this->configuration = $configuration; - $this->productAttributeValueReaders = $productAttributeValueReaders instanceof \Traversable + $this->productAttributeValueReaders = $productAttributeValueReaders instanceof Traversable ? iterator_to_array($productAttributeValueReaders) : $productAttributeValueReaders; } diff --git a/src/AutoMapper/ProductAttributeValueReader/DateTimeReader.php b/src/AutoMapper/ProductAttributeValueReader/DateTimeReader.php index bb6e6786..70540f73 100644 --- a/src/AutoMapper/ProductAttributeValueReader/DateTimeReader.php +++ b/src/AutoMapper/ProductAttributeValueReader/DateTimeReader.php @@ -13,6 +13,7 @@ namespace MonsieurBiz\SyliusSearchPlugin\AutoMapper\ProductAttributeValueReader; +use DateTime; use Sylius\Component\Product\Model\ProductAttributeValueInterface; class DateTimeReader implements ReaderInterface @@ -26,7 +27,7 @@ public function getValue(ProductAttributeValueInterface $productAttribute) } $productAttributeValue = $productAttribute->getValue(); - if ($productAttributeValue instanceof \DateTime) { + if ($productAttributeValue instanceof DateTime) { $productAttributeValue = $productAttributeValue->format($this->defaultFormat); } diff --git a/src/Checker/ElasticsearchChecker.php b/src/Checker/ElasticsearchChecker.php index 2e46dd7d..94a2d3a0 100644 --- a/src/Checker/ElasticsearchChecker.php +++ b/src/Checker/ElasticsearchChecker.php @@ -13,6 +13,7 @@ namespace MonsieurBiz\SyliusSearchPlugin\Checker; +use Exception; use JoliCode\Elastically\Factory; class ElasticsearchChecker implements ElasticsearchCheckerInterface @@ -34,7 +35,7 @@ public function check(): bool // Check client response try { $client->getStatus()->getResponse(); - } catch (\Exception $e) { + } catch (Exception $e) { $this->isAvailable = false; return $this->isAvailable; diff --git a/src/Index/Indexer.php b/src/Index/Indexer.php index 7e731a6b..d686f2b1 100644 --- a/src/Index/Indexer.php +++ b/src/Index/Indexer.php @@ -221,9 +221,10 @@ private function getRealEntity($entity) } // Clear the entity manager to detach the proxy object - $this->entityManager->clear(\get_class($entity)); /** @phpstan-ignore-line */ + $this->entityManager->clear($entity::class); /** @phpstan-ignore-line */ // Retrieve the original class name - $entityClassName = $this->entityManager->getClassMetadata(\get_class($entity))->rootEntityName; + $entityClassName = $this->entityManager->getClassMetadata($entity::class)->rootEntityName; + // Find the object in repository from the ID return $this->entityManager->find($entityClassName, $entity->getId()); } diff --git a/src/Message/ProductReindexFromTaxon.php b/src/Message/ProductReindexFromTaxon.php index 7b2af22f..0d1de880 100644 --- a/src/Message/ProductReindexFromTaxon.php +++ b/src/Message/ProductReindexFromTaxon.php @@ -15,7 +15,7 @@ class ProductReindexFromTaxon { - //todo rename to ProductReindexFromTaxonId + // todo rename to ProductReindexFromTaxonId private int $taxonId; diff --git a/src/MessageHandler/ProductReindexFromTaxonHandler.php b/src/MessageHandler/ProductReindexFromTaxonHandler.php index a2a3f636..097f6f4d 100644 --- a/src/MessageHandler/ProductReindexFromTaxonHandler.php +++ b/src/MessageHandler/ProductReindexFromTaxonHandler.php @@ -50,7 +50,7 @@ public function __invoke(ProductReindexFromTaxon $message): void ->innerJoin('o.productTaxons', 'productTaxon') ->andWhere('productTaxon.taxon = :taxonId') ->setParameter('taxonId', $message->getTaxonId())->getQuery()->getResult() - ; + ; $this->indexer->indexByDocuments( $documentable, diff --git a/src/Model/Documentable/Documentable.php b/src/Model/Documentable/Documentable.php index 43fccfff..eb050a56 100644 --- a/src/Model/Documentable/Documentable.php +++ b/src/Model/Documentable/Documentable.php @@ -18,7 +18,6 @@ class Documentable implements PrefixedDocumentableInterface { use DocumentableDatasourceTrait; - use DocumentableMappingProviderTrait; private string $indexCode; diff --git a/src/Normalizer/Product/ProductDTONormalizer.php b/src/Normalizer/Product/ProductDTONormalizer.php index 394f5569..fa0924fa 100644 --- a/src/Normalizer/Product/ProductDTONormalizer.php +++ b/src/Normalizer/Product/ProductDTONormalizer.php @@ -31,7 +31,6 @@ final class ProductDTONormalizer extends ObjectNormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface { use DenormalizerAwareTrait; - use NormalizerAwareTrait; private Configuration $automapperConfiguration; diff --git a/src/Repository/ProductAttributeRepository.php b/src/Repository/ProductAttributeRepository.php index 814bbabb..bc90ffdd 100644 --- a/src/Repository/ProductAttributeRepository.php +++ b/src/Repository/ProductAttributeRepository.php @@ -32,6 +32,6 @@ public function findIsSearchableOrFilterable(): array ->orWhere('o.filterable = true') ->getQuery() ->getResult() - ; + ; } } diff --git a/src/Repository/ProductOptionRepository.php b/src/Repository/ProductOptionRepository.php index 07aa25e5..45f2f000 100644 --- a/src/Repository/ProductOptionRepository.php +++ b/src/Repository/ProductOptionRepository.php @@ -32,6 +32,6 @@ public function findIsSearchableOrFilterable(): array ->orWhere('o.filterable = true') ->getQuery() ->getResult() - ; + ; } } diff --git a/src/Search/Request/Aggregation/MainTaxonAggregation.php b/src/Search/Request/Aggregation/MainTaxonAggregation.php index c8750d97..1ea903b7 100644 --- a/src/Search/Request/Aggregation/MainTaxonAggregation.php +++ b/src/Search/Request/Aggregation/MainTaxonAggregation.php @@ -54,7 +54,7 @@ public function build($aggregation, array $filters) ) ) ) - ; + ; } /** diff --git a/src/Search/Request/Aggregation/PriceAggregation.php b/src/Search/Request/Aggregation/PriceAggregation.php index 4df477a9..4bd38c80 100644 --- a/src/Search/Request/Aggregation/PriceAggregation.php +++ b/src/Search/Request/Aggregation/PriceAggregation.php @@ -63,7 +63,7 @@ public function build($aggregation, array $filters) ) ) ) - ; + ; } /** diff --git a/src/Search/Request/Aggregation/ProductOptionAggregation.php b/src/Search/Request/Aggregation/ProductOptionAggregation.php index 70684f12..0457d1c9 100644 --- a/src/Search/Request/Aggregation/ProductOptionAggregation.php +++ b/src/Search/Request/Aggregation/ProductOptionAggregation.php @@ -43,9 +43,9 @@ public function build($aggregation, array $filters) $filters = array_filter($filters, function (AbstractQuery $filter) use ($aggregation): bool { return !$filter->hasParam('path') || ( - false !== strpos($filter->getParam('path'), 'options.') + false !== strpos($filter->getParam('path'), 'options.') && 'options.' . $aggregation->getCode() . '.values' !== $filter->getParam('path') - ); + ); }); $filterQuery = $qb->query()->bool(); diff --git a/src/Search/Request/Aggregation/TaxonsAggregation.php b/src/Search/Request/Aggregation/TaxonsAggregation.php index 79acc0b9..85d12177 100644 --- a/src/Search/Request/Aggregation/TaxonsAggregation.php +++ b/src/Search/Request/Aggregation/TaxonsAggregation.php @@ -61,7 +61,7 @@ public function build($aggregation, array $filters) ) ) ) - ; + ; } /**