diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 3c8d6eb251..743a55d423 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -12226,11 +12226,6 @@ parameters: count: 1 path: tests/lib/Pagination/Pagerfanta/TrashItemAdapterTest.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: 2 - path: tests/lib/Pagination/Pagerfanta/TrashItemAdapterTest.php - - message: "#^Property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\:\\:\\$sortClauses \\(array\\\\) does not accept Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\SortClause&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\.$#" count: 2 diff --git a/src/bundle/Controller/AssetController.php b/src/bundle/Controller/AssetController.php index 21d9161f69..f4d99e178d 100644 --- a/src/bundle/Controller/AssetController.php +++ b/src/bundle/Controller/AssetController.php @@ -83,7 +83,7 @@ public function uploadImageAction(Request $request): Response $content = $this->imageAssetMapper->createAsset( $file->getClientOriginalName(), new ImageValue([ - 'path' => $file->getRealPath(), + 'inputUri' => $file->getRealPath(), 'fileSize' => $file->getSize(), 'fileName' => $file->getClientOriginalName(), 'alternativeText' => $file->getClientOriginalName(), diff --git a/src/bundle/Controller/Content/ContentTreeController.php b/src/bundle/Controller/Content/ContentTreeController.php index a26174c1db..50142ab94b 100644 --- a/src/bundle/Controller/Content/ContentTreeController.php +++ b/src/bundle/Controller/Content/ContentTreeController.php @@ -23,7 +23,6 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Content; use Ibexa\Contracts\Core\Repository\Values\Content\Location; use Ibexa\Contracts\Core\Repository\Values\Content\Query; -use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\User\Limitation; use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; use Ibexa\Rest\Message; @@ -79,7 +78,7 @@ public function loadChildrenAction( int $parentLocationId, int $limit, int $offset, - ?Criterion $filter + ?Query\CriterionInterface $filter ): Node { $location = $this->locationService->loadLocation($parentLocationId); $loadSubtreeRequestNode = new LoadSubtreeRequestNode($parentLocationId, $limit, $offset); diff --git a/src/bundle/ControllerArgumentResolver/ContentTreeChildrenQueryArgumentResolver.php b/src/bundle/ControllerArgumentResolver/ContentTreeChildrenQueryArgumentResolver.php index 752a420fd0..463dbb0ce4 100644 --- a/src/bundle/ControllerArgumentResolver/ContentTreeChildrenQueryArgumentResolver.php +++ b/src/bundle/ControllerArgumentResolver/ContentTreeChildrenQueryArgumentResolver.php @@ -8,8 +8,8 @@ namespace Ibexa\Bundle\AdminUi\ControllerArgumentResolver; -use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalAnd; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Rest\Input\Parser\Query\Criterion\CriterionProcessorInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; @@ -34,12 +34,16 @@ public function __construct( public function supports(Request $request, ArgumentMetadata $argument): bool { - return Criterion::class === $argument->getType() + if ($argument->getType() === null) { + return false; + } + + return is_a($argument->getType(), CriterionInterface::class, true) && 'filter' === $argument->getName(); } /** - * @return iterable<\Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion|null> + * @return iterable<\Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface|null> * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ @@ -56,7 +60,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable } /** - * @return array<\Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion> + * @return array<\Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface> */ private function processFilterQueryCriteria(Request $request): array { diff --git a/src/lib/REST/Input/Parser/ContentTree/LoadSubtreeRequest.php b/src/lib/REST/Input/Parser/ContentTree/LoadSubtreeRequest.php index 7b6b995148..692511d9dd 100644 --- a/src/lib/REST/Input/Parser/ContentTree/LoadSubtreeRequest.php +++ b/src/lib/REST/Input/Parser/ContentTree/LoadSubtreeRequest.php @@ -10,6 +10,7 @@ use Ibexa\AdminUi\REST\Value\ContentTree\LoadSubtreeRequest as LoadSubtreeRequestValue; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Rest\Exceptions; use Ibexa\Contracts\Rest\Input\ParsingDispatcher; use Ibexa\Rest\Server\Input\Parser\Criterion as CriterionParser; @@ -45,7 +46,7 @@ public function parse(array $data, ParsingDispatcher $parsingDispatcher): LoadSu * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidCriterionArgumentException */ - private function processCriteriaArray(array $criteriaArray, ParsingDispatcher $parsingDispatcher): ?Criterion + private function processCriteriaArray(array $criteriaArray, ParsingDispatcher $parsingDispatcher): ?CriterionInterface { if (count($criteriaArray) === 0) { return null; diff --git a/src/lib/REST/Value/ContentTree/LoadSubtreeRequest.php b/src/lib/REST/Value/ContentTree/LoadSubtreeRequest.php index 6fa02bf834..d949b4ce5b 100644 --- a/src/lib/REST/Value/ContentTree/LoadSubtreeRequest.php +++ b/src/lib/REST/Value/ContentTree/LoadSubtreeRequest.php @@ -8,7 +8,7 @@ namespace Ibexa\AdminUi\REST\Value\ContentTree; -use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Rest\Value as RestValue; class LoadSubtreeRequest extends RestValue @@ -16,12 +16,12 @@ class LoadSubtreeRequest extends RestValue /** @var \Ibexa\AdminUi\REST\Value\ContentTree\LoadSubtreeRequestNode[] */ public array $nodes; - public ?Criterion $filter; + public ?CriterionInterface $filter; /** * @param array $nodes */ - public function __construct(array $nodes = [], ?Criterion $filter = null) + public function __construct(array $nodes = [], ?CriterionInterface $filter = null) { $this->nodes = $nodes; $this->filter = $filter; diff --git a/src/lib/UI/Module/ContentTree/NodeFactory.php b/src/lib/UI/Module/ContentTree/NodeFactory.php index ec5733dc8e..1169718f7a 100644 --- a/src/lib/UI/Module/ContentTree/NodeFactory.php +++ b/src/lib/UI/Module/ContentTree/NodeFactory.php @@ -20,6 +20,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery; use Ibexa\Contracts\Core\Repository\Values\Content\Query; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause; use Ibexa\Contracts\Core\Repository\Values\Content\Search\AggregationResult\TermAggregationResult; use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult; @@ -96,7 +97,7 @@ public function createNode( int $depth = 0, ?string $sortClause = null, string $sortOrder = Query::SORT_ASC, - ?Criterion $requestFilter = null + ?Query\CriterionInterface $requestFilter = null ): Node { $uninitializedContentInfoList = []; $containerLocations = []; @@ -150,7 +151,7 @@ private function findSubitems( int $offset = 0, ?string $sortClause = null, string $sortOrder = Query::SORT_ASC, - ?Criterion $requestFilter = null + ?CriterionInterface $requestFilter = null ): SearchResult { $searchQuery = $this->getSearchQuery($parentLocation->getId(), $requestFilter); @@ -164,7 +165,7 @@ private function findSubitems( /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location $parentLocation */ - private function getSearchQuery(int $parentLocationId, ?Criterion $requestFilter = null): LocationQuery + private function getSearchQuery(int $parentLocationId, ?CriterionInterface $requestFilter = null): LocationQuery { $searchQuery = new LocationQuery(); $searchQuery->filter = new Criterion\ParentLocationId($parentLocationId); @@ -206,7 +207,7 @@ private function findChild(int $locationId, LoadSubtreeRequestNode $loadSubtreeR /** * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ - private function countSubitems(int $parentLocationId, ?Criterion $requestFilter = null): int + private function countSubitems(int $parentLocationId, ?CriterionInterface $requestFilter = null): int { $searchQuery = $this->getSearchQuery($parentLocationId, $requestFilter); @@ -223,7 +224,7 @@ private function countSubitems(int $parentLocationId, ?Criterion $requestFilter * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidCriterionArgumentException */ - private function countAggregatedSubitems(array $containerLocations, ?Criterion $requestFilter): array + private function countAggregatedSubitems(array $containerLocations, ?CriterionInterface $requestFilter): array { if (empty($containerLocations)) { return []; @@ -338,7 +339,7 @@ private function buildNode( ?string $sortClause = null, string $sortOrder = Query::SORT_ASC, array $bookmarkLocations = [], - ?Criterion $requestFilter = null + ?CriterionInterface $requestFilter = null ): Node { $contentInfo = $location->getContentInfo(); $contentId = $location->getContentId(); @@ -443,7 +444,7 @@ private function supplyTranslatedContentName(Node $node, array $versionInfoById) private function supplyChildrenCount( Node $node, ?array $aggregationResult = null, - ?Criterion $requestFilter = null + ?CriterionInterface $requestFilter = null ): void { if ($node->isContainer) { if ($aggregationResult !== null) { diff --git a/tests/bundle/ControllerArgumentResolver/ContentTreeChildrenQueryArgumentResolverTest.php b/tests/bundle/ControllerArgumentResolver/ContentTreeChildrenQueryArgumentResolverTest.php index 0a65bdbfb8..77a1b6a819 100644 --- a/tests/bundle/ControllerArgumentResolver/ContentTreeChildrenQueryArgumentResolverTest.php +++ b/tests/bundle/ControllerArgumentResolver/ContentTreeChildrenQueryArgumentResolverTest.php @@ -14,6 +14,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ContentTypeIdentifier; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalAnd; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Rest\Input\Parser\Query\Criterion\CriterionProcessorInterface; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; @@ -106,7 +107,7 @@ public function provideDataForTestSupports(): iterable * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ public function testResolve( - Criterion $expected, + CriterionInterface $expected, Request $request, Traversable $expectedCriteria, array $criteriaToProcess = [] @@ -133,9 +134,9 @@ public function testResolve( /** * @return iterable, + * \Traversable<\Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface>, * 3?: array, * }> *