Skip to content

Commit

Permalink
OP-352 - Fix PHPDoc annotations to resolve build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
SzymonKostrubiec committed Jul 10, 2024
1 parent c0863ec commit 31b0760
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 26 deletions.
11 changes: 3 additions & 8 deletions src/QueryBuilder/FormQueryBuilder/SiteWideFacetsQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder\FormQueryBuilder;

use BitBag\SyliusElasticsearchPlugin\Facet\RegistryInterface;
use BitBag\SyliusElasticsearchPlugin\Model\Search;
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;
use Elastica\Query;
use Symfony\Component\Form\FormEvent;
use Webmozart\Assert\Assert;

final class SiteWideFacetsQueryBuilder implements SiteWideFacetsQueryBuilderInterface
{
Expand All @@ -28,18 +26,15 @@ public function __construct(

public function getQuery(FormEvent $event): Query
{
/** @var Search $data */
/** @var array $data */
$data = $event->getData();
$box = $data->getBox();

Assert::notNull($box);

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

foreach ($data->getFacets() as $facetId => $selectedBuckets) {
foreach ($data['facets'] ?? [] as $facetId => $selectedBuckets) {
if (!$selectedBuckets) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/OrderItemRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(

public function countByVariant(ProductVariantInterface $variant, array $orderStates = []): int
{
if ([] === $orderStates) {
if ([] !== $orderStates) {
$orderStates = [OrderInterface::STATE_CANCELLED, OrderInterface::STATE_CART];
}

Expand Down
14 changes: 7 additions & 7 deletions src/Repository/ProductAttributeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@
class ProductAttributeRepository implements ProductAttributeRepositoryInterface
{
public function __construct(
private RepositoryInterface|EntityRepository $productAttributeRepository
private RepositoryInterface $productAttributeRepository
) {
}

public function getAttributeTypeByName(string $attributeName): string
{
/** @var EntityRepository $productAttributeRepository */
$productAttributeRepository = $this->productAttributeRepository;

$queryBuilder = $productAttributeRepository->createQueryBuilder('p');
/** @var EntityRepository $queryBuilder */
$queryBuilder = $this->productAttributeRepository;

$result = $queryBuilder
->createQueryBuilder('p')
->select('p.type')
->where('p.code = :code')
->setParameter(':code', $attributeName)
Expand All @@ -44,12 +43,13 @@ public function findAllWithTranslations(?string $locale): array
/** @var EntityRepository $productAttributeRepository */
$productAttributeRepository = $this->productAttributeRepository;

$queryBuilder = $productAttributeRepository->createQueryBuilder('p');
$queryBuilder = $productAttributeRepository->createQueryBuilder('o');

if (null !== $locale) {
$queryBuilder
->addSelect('translation')
->leftJoin('o.translations', 'ot')
/** @phpstan-ignore-next-line phpstan can't read relationship correctly */
->leftJoin('o.translations', 'translation', 'ot')
->andWhere('translation.locale = :locale')
->setParameter('locale', $locale)
;
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/ProductAttributeValueRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class ProductAttributeValueRepository implements ProductAttributeValueRepositoryInterface
{
public function __construct(
private BaseAttributeValueRepositoryInterface|EntityRepository $baseAttributeValueRepository,
private BaseAttributeValueRepositoryInterface $baseAttributeValueRepository,
private bool $includeAllDescendants
) {
}
Expand Down
13 changes: 7 additions & 6 deletions src/Repository/ProductOptionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,28 @@
class ProductOptionRepository implements ProductOptionRepositoryInterface
{
public function __construct(
private RepositoryInterface|EntityRepository $productOptionRepository
private RepositoryInterface $productOptionRepository
) {
}

public function findAllWithTranslations(?string $locale): array
{
/** @var EntityRepository $productOptionRepository */
$productOptionRepository = $this->productOptionRepository;

$queryBuilder = $productOptionRepository->createQueryBuilder('o');
/** @var EntityRepository $queryBuilder */
$queryBuilder = $this->productOptionRepository;

if (null !== $locale) {
$queryBuilder
->createQueryBuilder('o')
->addSelect('translation')
->leftJoin('o.translations', 'ot')
/** @phpstan-ignore-next-line phpstan can't read relationship correctly */
->leftJoin('o.translations', 'translation', 'ot')
->andWhere('translation.locale = :locale')
->setParameter('locale', $locale)
;
}

return $queryBuilder
->createQueryBuilder('o')
->getQuery()
->getResult()
;
Expand Down
6 changes: 4 additions & 2 deletions src/Repository/ProductVariantRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public function findOneByOptionValue(ProductOptionValueInterface $productOptionV
/** @var EntityRepository $baseProductVariantRepository */
$baseProductVariantRepository = $this->baseProductVariantRepository;

return $baseProductVariantRepository->createQueryBuilder('o')
return $baseProductVariantRepository
->createQueryBuilder('o')
->where(':optionValue MEMBER OF o.optionValues')
->setParameter('optionValue', $productOptionValue)
->getQuery()
Expand All @@ -43,7 +44,8 @@ public function findByOptionValue(ProductOptionValueInterface $productOptionValu
/** @var EntityRepository $baseProductVariantRepository */
$baseProductVariantRepository = $this->baseProductVariantRepository;

return $baseProductVariantRepository->createQueryBuilder('o')
return $baseProductVariantRepository
->createQueryBuilder('o')
->where(':optionValue MEMBER OF o.optionValues')
->setParameter('optionValue', $productOptionValue)
->getQuery()
Expand Down
3 changes: 2 additions & 1 deletion src/Repository/TaxonRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public function getTaxonsByAttributeViaProduct(AttributeInterface $attribute): a
->leftJoin($this->productTaxonEntityClass, 'pt', Join::WITH, 'pt.taxon = t.id')
->where(
'pt.product IN(' .
$productRepository->createQueryBuilder('p')
$productRepository
->createQueryBuilder('p')
->leftJoin($this->productAttributeEntityClass, 'pav', Join::WITH, 'pav.subject = p.id')
->where('pav.attribute = :attribute')
->getQuery()
Expand Down

0 comments on commit 31b0760

Please sign in to comment.