Skip to content

Commit

Permalink
Added typehint to Query::query
Browse files Browse the repository at this point in the history
  • Loading branch information
ViniTou committed Nov 28, 2024
1 parent d544a90 commit d4e89d8
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 16 deletions.
14 changes: 2 additions & 12 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -21532,7 +21532,7 @@ parameters:

-
message: "#^Cannot access offset 0 on array\\<bool\\|float\\|int\\|string\\>\\|bool\\|float\\|int\\|string\\.$#"
count: 2
count: 1
path: src/lib/Search/Legacy/Content/Location/Gateway/CriterionHandler/Location/IsMainLocation.php

-
Expand Down Expand Up @@ -21592,7 +21592,7 @@ parameters:

-
message: "#^Cannot access offset 0 on array\\<bool\\|float\\|int\\|string\\>\\|bool\\|float\\|int\\|string\\.$#"
count: 2
count: 1
path: src/lib/Search/Legacy/Content/Location/Gateway/CriterionHandler/Visibility.php

-
Expand Down Expand Up @@ -46120,11 +46120,6 @@ parameters:
count: 1
path: tests/lib/Pagination/ContentSearchHitAdapterTest.php

-
message: "#^Property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\:\\:\\$query \\(Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\Criterion\\) does not accept Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\CriterionInterface&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\.$#"
count: 1
path: tests/lib/Pagination/ContentSearchHitAdapterTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Pagination\\\\LocationSearchAdapterTest\\:\\:getAdapter\\(\\) has parameter \\$languageFilter with no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -46155,11 +46150,6 @@ parameters:
count: 1
path: tests/lib/Pagination/LocationSearchHitAdapterTest.php

-
message: "#^Property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\:\\:\\$query \\(Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\Criterion\\) does not accept Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\CriterionInterface&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\.$#"
count: 1
path: tests/lib/Pagination/LocationSearchHitAdapterTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Cache\\\\AbstractBaseHandlerTest\\:\\:getCacheItem\\(\\) has parameter \\$key with no type specified\\.$#"
count: 1
Expand Down
4 changes: 1 addition & 3 deletions src/contracts/Repository/Values/Content/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ class Query extends ValueObject
*
* Can contain multiple criterion, as items of a logical one (by default
* AND). Defaults to MatchAll.
*
* @var \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion
*/
public $query;
public ?CriterionInterface $query = null;

/**
* Query sorting clauses.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Repository/SearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ protected function internalFindContentInfo(Query $query, array $languageFilter =
$query = clone $query;
$query->filter = $query->filter ?: new Criterion\MatchAll();

$this->validateContentCriteria([$query->query], '$query');
$this->validateContentCriteria($query->query ? [$query->query] : [], '$query');
$this->validateContentCriteria([$query->filter], '$query');
$this->validateContentSortClauses($query);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ public function testQueryModifiedField()
'sortClauses' => [new SortClause\ContentId()],
]
);
self::assertInstanceOf(Criterion::class, $query->query);
$query->query->setCustomField('user', 'first_name', 'custom_field');

$this->assertQueryFixture(
Expand Down
1 change: 1 addition & 0 deletions tests/integration/Core/Repository/SearchServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2930,6 +2930,7 @@ public function testQueryModifiedField()
'sortClauses' => [new SortClause\ContentId()],
]
);
self::assertInstanceOf(Criterion::class, $query->query);
$query->query->setCustomField('user', 'first_name', 'custom_field');

$this->assertQueryFixture(
Expand Down

0 comments on commit d4e89d8

Please sign in to comment.