diff --git a/phpstan.neon b/phpstan.neon index eb5b39b..724e474 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,7 +2,7 @@ parameters: reportUnmatchedIgnoredErrors: false checkMissingIterableValueType: false - excludes_analyse: + excludePaths: # Makes PHPStan crash - 'src/DependencyInjection/Configuration.php' diff --git a/src/DependencyInjection/Compiler/CatalogRuleCheckersPass.php b/src/DependencyInjection/Compiler/CatalogRuleCheckersPass.php index 808a3bf..fc369f8 100644 --- a/src/DependencyInjection/Compiler/CatalogRuleCheckersPass.php +++ b/src/DependencyInjection/Compiler/CatalogRuleCheckersPass.php @@ -39,6 +39,7 @@ private function serviceImplementsInterface( if (is_null($objectOrClass)) { return false; } + /** @phpstan-ignore-next-line */ return isset(class_implements($objectOrClass)[$ruleInterface]); } diff --git a/src/DependencyInjection/Compiler/CatalogSortChecker.php b/src/DependencyInjection/Compiler/CatalogSortChecker.php index 7fc9825..1d11257 100644 --- a/src/DependencyInjection/Compiler/CatalogSortChecker.php +++ b/src/DependencyInjection/Compiler/CatalogSortChecker.php @@ -40,6 +40,7 @@ private function serviceImplementsInterface( return false; } + /** @phpstan-ignore-next-line */ return isset(class_implements($objectOrClass)[$sortInterface]); } diff --git a/src/Entity/Catalog.php b/src/Entity/Catalog.php index e212bd1..295d4a4 100644 --- a/src/Entity/Catalog.php +++ b/src/Entity/Catalog.php @@ -34,7 +34,7 @@ class Catalog implements CatalogInterface protected ?string $connectingRules; - /** @var CatalogRuleInterface[]|Collection */ + /* @phpstan-ignore-next-line Property is a type Collection*/ protected $productAssociationRules; protected string $productAssociationConnectingRules; diff --git a/src/Form/Type/AbstractConfigurableCatalogElementType.php b/src/Form/Type/AbstractConfigurableCatalogElementType.php index 894d64a..eac058e 100644 --- a/src/Form/Type/AbstractConfigurableCatalogElementType.php +++ b/src/Form/Type/AbstractConfigurableCatalogElementType.php @@ -91,6 +91,7 @@ protected function addConfigurationFields(FormInterface $form, string $configura ]); } + /* @phpstan-ignore-next-line Parameter $data is mixed type */ protected function getRegistryIdentifier(FormInterface $form, $data = null): ?string { if ($data instanceof ConfigurableCatalogElementInterface && null !== $data->getType()) { diff --git a/src/QueryBuilder/ProductQueryBuilder.php b/src/QueryBuilder/ProductQueryBuilder.php index c261f66..78cb4e7 100644 --- a/src/QueryBuilder/ProductQueryBuilder.php +++ b/src/QueryBuilder/ProductQueryBuilder.php @@ -11,6 +11,7 @@ namespace BitBag\SyliusCatalogPlugin\QueryBuilder; use BitBag\SyliusCatalogPlugin\Checker\Rule\Elasticsearch\RuleInterface; +use BitBag\SyliusCatalogPlugin\Entity\CatalogRuleInterface; use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface; use Doctrine\Common\Collections\Collection; use Elastica\Query\BoolQuery; @@ -28,11 +29,16 @@ public function __construct(ServiceRegistry $serviceRegistry, QueryBuilderInterf $this->hasChannelQueryBuilder = $hasChannelQueryBuilder; } + /** + * @param string $connectingRules + * @param Collection $rules + * @return BoolQuery + */ public function findMatchingProductsQuery(string $connectingRules, Collection $rules): BoolQuery { $subQueries = $this->getQueries($rules->toArray()); - if (empty($subQueries)) { + if (0 === count($subQueries)) { return new BoolQuery(); } $query = new BoolQuery(); diff --git a/src/QueryBuilder/ProductQueryBuilderInterface.php b/src/QueryBuilder/ProductQueryBuilderInterface.php index e6f5f5f..942b6eb 100644 --- a/src/QueryBuilder/ProductQueryBuilderInterface.php +++ b/src/QueryBuilder/ProductQueryBuilderInterface.php @@ -10,9 +10,16 @@ namespace BitBag\SyliusCatalogPlugin\QueryBuilder; +use BitBag\SyliusCatalogPlugin\Entity\CatalogRuleInterface; use Doctrine\Common\Collections\Collection; +use Elastica\Query\BoolQuery; interface ProductQueryBuilderInterface { - public function findMatchingProductsQuery(string $connectingRules, Collection $rules): array; + /** + * @param string $connectingRules + * @param Collection $rules + * @return BoolQuery + */ + public function findMatchingProductsQuery(string $connectingRules, Collection $rules): BoolQuery; } diff --git a/src/Resolver/CatalogsForProductResolverInterface.php b/src/Resolver/CatalogsForProductResolverInterface.php index 392f476..7b0c9f1 100644 --- a/src/Resolver/CatalogsForProductResolverInterface.php +++ b/src/Resolver/CatalogsForProductResolverInterface.php @@ -15,6 +15,5 @@ interface CatalogsForProductResolverInterface { - /** @return CatalogInterface[] */ public function resolveProductCatalogs(ProductInterface $product, \DateTimeImmutable $dataTime): array; } diff --git a/src/Resolver/CompleteCatalogsForProductResolver.php b/src/Resolver/CompleteCatalogsForProductResolver.php index 89b43f4..bd43f14 100644 --- a/src/Resolver/CompleteCatalogsForProductResolver.php +++ b/src/Resolver/CompleteCatalogsForProductResolver.php @@ -28,9 +28,7 @@ public function __construct( } - /** - * @return array|CatalogInterface[] - */ + public function resolveProductCatalogs(ProductInterface $product, \DateTimeImmutable $dataTime): array { return diff --git a/src/Resolver/Elasticsearch/ProductsInsideCatalogResolver.php b/src/Resolver/Elasticsearch/ProductsInsideCatalogResolver.php index 63bb031..36f2d08 100644 --- a/src/Resolver/Elasticsearch/ProductsInsideCatalogResolver.php +++ b/src/Resolver/Elasticsearch/ProductsInsideCatalogResolver.php @@ -46,12 +46,12 @@ public function findMatchingProducts(CatalogInterface $catalog): array } if ((bool) $catalog->getRules()->count()) { - /** @var BoolQuery $query */ $query = $this->productQueryBuilder->findMatchingProductsQuery($catalog->getConnectingRules(), $catalog->getRules()); } /** @var SortInterface $sortChecker */ $sortChecker = $this->sortServiceRegistry->get($catalog->getSortingType()); + /** @phpstan-ignore-next-line */ $query = $sortChecker->modifyQueryBuilder($query); $products = $this->productFinder->find($query, $catalog->getDisplayProducts());