Skip to content

Commit

Permalink
Add fix for phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon Kostrubiec committed Jul 9, 2024
1 parent 5f7581f commit a36f7c4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;
use Elastica\Query;
use Symfony\Component\Form\FormEvent;
use Webmozart\Assert\Assert;

final class SiteWideFacetsQueryBuilder implements SiteWideFacetsQueryBuilderInterface
{
Expand All @@ -29,12 +30,16 @@ public function getQuery(FormEvent $event): Query
{
/** @var Search $data */
$data = $event->getData();
$box = $data->getBox();

Assert::notNull($box);

/** @var Query\BoolQuery $boolQuery */
$boolQuery = $this->queryBuilder->buildQuery([
'query' => $data['box']['query'] ?? '',
'query' => $box->getQuery() ?? '',
]);

foreach ($data['facets'] ?? [] as $facetId => $selectedBuckets) {
foreach ($data->getFacets() as $facetId => $selectedBuckets) {
if (!$selectedBuckets) {
continue;
}
Expand Down
1 change: 1 addition & 0 deletions src/Repository/ProductAttributeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function findAllWithTranslations(?string $locale): array
if (null !== $locale) {
$queryBuilder
->addSelect('translation')
/** @phpstan-ignore-next-line */
->leftJoin('o.translations', 'translation', 'ot')
->andWhere('translation.locale = :locale')
->setParameter('locale', $locale)
Expand Down
7 changes: 5 additions & 2 deletions src/Repository/ProductAttributeValueRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace BitBag\SyliusElasticsearchPlugin\Repository;

use Doctrine\ORM\EntityRepository;
use Sylius\Component\Attribute\Model\AttributeInterface;
use Sylius\Component\Product\Repository\ProductAttributeValueRepositoryInterface as BaseAttributeValueRepositoryInterface;
use Sylius\Component\Taxonomy\Model\Taxon;
Expand All @@ -26,8 +27,10 @@ public function __construct(

public function getUniqueAttributeValues(AttributeInterface $productAttribute, Taxon $taxon): array
{
/** @phpstan-ignore-next-line */
$queryBuilder = $this->baseAttributeValueRepository->createQueryBuilder('o');
/** @var EntityRepository $baseAttributeValueRepository */
$baseAttributeValueRepository = $this->baseAttributeValueRepository;

$queryBuilder = $baseAttributeValueRepository->createQueryBuilder('o');

/** @var string|null $storageType */
$storageType = $productAttribute->getStorageType();
Expand Down

0 comments on commit a36f7c4

Please sign in to comment.