Skip to content

Commit

Permalink
making changes to the edited code during refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
patryk authored and christopherhero committed Aug 22, 2022
1 parent 4394ca4 commit 09fd0da
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ parameters:
reportUnmatchedIgnoredErrors: false
checkMissingIterableValueType: false

excludes_analyse:
excludePaths:
# Makes PHPStan crash
- 'src/DependencyInjection/Configuration.php'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private function serviceImplementsInterface(
if (is_null($objectOrClass)) {
return false;
}
/** @phpstan-ignore-next-line */
return isset(class_implements($objectOrClass)[$ruleInterface]);
}

Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/Compiler/CatalogSortChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ private function serviceImplementsInterface(
return false;
}

/** @phpstan-ignore-next-line */
return isset(class_implements($objectOrClass)[$sortInterface]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Catalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Catalog implements CatalogInterface

protected ?string $connectingRules;

/** @var CatalogRuleInterface[]|Collection<int, CatalogRuleInterface> */
/* @phpstan-ignore-next-line Property is a type Collection*/
protected $productAssociationRules;

protected string $productAssociationConnectingRules;
Expand Down
1 change: 1 addition & 0 deletions src/Form/Type/AbstractConfigurableCatalogElementType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
8 changes: 7 additions & 1 deletion src/QueryBuilder/ProductQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,11 +29,16 @@ public function __construct(ServiceRegistry $serviceRegistry, QueryBuilderInterf
$this->hasChannelQueryBuilder = $hasChannelQueryBuilder;
}

/**
* @param string $connectingRules
* @param Collection<int, CatalogRuleInterface> $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();
Expand Down
9 changes: 8 additions & 1 deletion src/QueryBuilder/ProductQueryBuilderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, CatalogRuleInterface> $rules
* @return BoolQuery
*/
public function findMatchingProductsQuery(string $connectingRules, Collection $rules): BoolQuery;
}
1 change: 0 additions & 1 deletion src/Resolver/CatalogsForProductResolverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@

interface CatalogsForProductResolverInterface
{
/** @return CatalogInterface[] */
public function resolveProductCatalogs(ProductInterface $product, \DateTimeImmutable $dataTime): array;
}
4 changes: 1 addition & 3 deletions src/Resolver/CompleteCatalogsForProductResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ public function __construct(
}


/**
* @return array|CatalogInterface[]
*/

public function resolveProductCatalogs(ProductInterface $product, \DateTimeImmutable $dataTime): array
{
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 09fd0da

Please sign in to comment.