Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
"ibexa/search": "~5.0.x-dev",
"ibexa/user": "~5.0.x-dev",
"phpspec/phpspec": "^7.1",
"phpstan/phpstan": "^1.12",
"phpstan/phpstan-phpunit": "^1.4",
"phpstan/phpstan-symfony": "^1.4"
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-symfony": "^2.0"
},
"scripts": {
"fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots",
Expand Down
62 changes: 38 additions & 24 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,101 +1,115 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$locationId of method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\LocationService\\:\\:loadLocation\\(\\) expects int, int\\|null given\\.$#"
message: '#^Parameter \#1 \$locationId of method Ibexa\\Contracts\\Core\\Repository\\LocationService\:\:loadLocation\(\) expects int, int\|null given\.$#'
identifier: argument.type
count: 1
path: src/bundle/Controller/QueryFieldRestController.php

-
message: "#^Parameter \\#1 \\$uri of method Ibexa\\\\Contracts\\\\Rest\\\\UriParser\\\\UriParserInterface\\:\\:getAttributeFromUri\\(\\) expects string, string\\|null given\\.$#"
message: '#^Parameter \#1 \$uri of method Ibexa\\Contracts\\Rest\\UriParser\\UriParserInterface\:\:getAttributeFromUri\(\) expects string, string\|null given\.$#'
identifier: argument.type
count: 1
path: src/bundle/Controller/QueryFieldRestController.php

-
message: "#^Argument of an invalid type array\\|bool\\|float\\|int\\|string\\|null supplied for foreach, only iterables are supported\\.$#"
message: '#^Argument of an invalid type array\|bool\|float\|int\|string\|null supplied for foreach, only iterables are supported\.$#'
identifier: foreach.nonIterable
count: 1
path: src/bundle/DependencyInjection/Compiler/FieldDefinitionIdentifierViewMatcherPass.php

-
message: "#^Cannot access offset \\(int\\|string\\) on non\\-empty\\-array\\|bool\\|float\\|int\\|string\\|null\\.$#"
message: '#^Cannot access offset \(int\|string\) on non\-empty\-array\|bool\|float\|int\|string\|null\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/bundle/DependencyInjection/Compiler/FieldDefinitionIdentifierViewMatcherPass.php

-
message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(int\\|string\\)\\: bool\\)\\|null, Closure\\(mixed\\)\\: \\(0\\|1\\|false\\) given\\.$#"
message: '#^Parameter \#2 \$callback of function array_filter expects \(callable\(int\|string\)\: bool\)\|null, Closure\(mixed\)\: \(0\|1\|false\) given\.$#'
identifier: argument.type
count: 1
path: src/bundle/DependencyInjection/Compiler/FieldDefinitionIdentifierViewMatcherPass.php

-
message: "#^Parameter \\#1 \\$queryTypeIdentifier of method Ibexa\\\\Bundle\\\\FieldTypeQuery\\\\DependencyInjection\\\\Compiler\\\\QueryTypesListPass\\:\\:buildQueryTypeName\\(\\) expects string, int\\|string given\\.$#"
message: '#^Parameter \#1 \$queryTypeIdentifier of method Ibexa\\Bundle\\FieldTypeQuery\\DependencyInjection\\Compiler\\QueryTypesListPass\:\:buildQueryTypeName\(\) expects string, int\|string given\.$#'
identifier: argument.type
count: 1
path: src/bundle/DependencyInjection/Compiler/QueryTypesListPass.php

-
message: "#^Parameter \\#1 \\$input of static method Symfony\\\\Component\\\\Yaml\\\\Yaml\\:\\:parse\\(\\) expects string, string\\|false given\\.$#"
message: '#^Parameter \#1 \$input of static method Symfony\\Component\\Yaml\\Yaml\:\:parse\(\) expects string, string\|false given\.$#'
identifier: argument.type
count: 1
path: src/bundle/DependencyInjection/IbexaFieldTypeQueryExtension.php

-
message: "#^Method Ibexa\\\\FieldTypeQuery\\\\ContentView\\\\QueryResultsInjector\\:\\:__construct\\(\\) has parameter \\$views with no value type specified in iterable type array\\.$#"
message: '#^Method Ibexa\\FieldTypeQuery\\ContentView\\QueryResultsInjector\:\:__construct\(\) has parameter \$views with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/ContentView/QueryResultsInjector.php

-
message: "#^Property Ibexa\\\\FieldTypeQuery\\\\ContentView\\\\QueryResultsInjector\\:\\:\\$queryFieldService \\(Ibexa\\\\Contracts\\\\FieldTypeQuery\\\\QueryFieldLocationService&Ibexa\\\\Contracts\\\\FieldTypeQuery\\\\QueryFieldServiceInterface\\) does not accept Ibexa\\\\Contracts\\\\FieldTypeQuery\\\\QueryFieldServiceInterface\\.$#"
message: '#^Property Ibexa\\FieldTypeQuery\\ContentView\\QueryResultsInjector\:\:\$queryFieldService \(Ibexa\\Contracts\\FieldTypeQuery\\QueryFieldLocationService&Ibexa\\Contracts\\FieldTypeQuery\\QueryFieldServiceInterface\) does not accept Ibexa\\Contracts\\FieldTypeQuery\\QueryFieldServiceInterface\.$#'
identifier: assign.propertyType
count: 1
path: src/lib/ContentView/QueryResultsInjector.php

-
message: "#^Property Ibexa\\\\FieldTypeQuery\\\\ContentView\\\\QueryResultsInjector\\:\\:\\$views type has no value type specified in iterable type array\\.$#"
message: '#^Property Ibexa\\FieldTypeQuery\\ContentView\\QueryResultsInjector\:\:\$views type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/ContentView/QueryResultsInjector.php

-
message: "#^Property Ibexa\\\\FieldTypeQuery\\\\ExceptionSafeQueryFieldService\\:\\:\\$inner \\(Ibexa\\\\Contracts\\\\FieldTypeQuery\\\\QueryFieldLocationService&Ibexa\\\\Contracts\\\\FieldTypeQuery\\\\QueryFieldServiceInterface\\) does not accept Ibexa\\\\Contracts\\\\FieldTypeQuery\\\\QueryFieldServiceInterface\\.$#"
message: '#^Property Ibexa\\FieldTypeQuery\\ExceptionSafeQueryFieldService\:\:\$inner \(Ibexa\\Contracts\\FieldTypeQuery\\QueryFieldLocationService&Ibexa\\Contracts\\FieldTypeQuery\\QueryFieldServiceInterface\) does not accept Ibexa\\Contracts\\FieldTypeQuery\\QueryFieldServiceInterface\.$#'
identifier: assign.propertyType
count: 1
path: src/lib/ExceptionSafeQueryFieldService.php

-
message: "#^Generator expects key type string, string\\|null given\\.$#"
message: '#^Generator expects key type string, string\|null given\.$#'
identifier: generator.keyType
count: 1
path: src/lib/FieldType/Mapper/QueryFormMapper.php

-
message: "#^Property Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageFieldValue\\:\\:\\$dataText \\(string\\) does not accept array\\|bool\\|float\\|int\\|string\\|null\\.$#"
message: '#^Property Ibexa\\Core\\Persistence\\Legacy\\Content\\StorageFieldValue\:\:\$dataText \(string\) does not accept array\|bool\|float\|int\|string\|null\.$#'
identifier: assign.propertyType
count: 1
path: src/lib/Persistence/Legacy/Content/FieldValue/Converter/QueryConverter.php

-
message: "#^Method Ibexa\\\\FieldTypeQuery\\\\QueryFieldService\\:\\:isExpression\\(\\) has parameter \\$expression with no type specified\\.$#"
message: '#^Method Ibexa\\FieldTypeQuery\\QueryFieldService\:\:isExpression\(\) has parameter \$expression with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: src/lib/QueryFieldService.php

-
message: "#^Method Ibexa\\\\FieldTypeQuery\\\\QueryFieldService\\:\\:prepareQuery\\(\\) has parameter \\$extraParameters with no value type specified in iterable type array\\.$#"
message: '#^Method Ibexa\\FieldTypeQuery\\QueryFieldService\:\:prepareQuery\(\) has parameter \$extraParameters with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/QueryFieldService.php

-
message: "#^Method Ibexa\\\\FieldTypeQuery\\\\QueryFieldService\\:\\:resolveExpression\\(\\) has no return type specified\\.$#"
message: '#^Method Ibexa\\FieldTypeQuery\\QueryFieldService\:\:resolveExpression\(\) has parameter \$variables with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/QueryFieldService.php

-
message: "#^Method Ibexa\\\\FieldTypeQuery\\\\QueryFieldService\\:\\:resolveExpression\\(\\) has parameter \\$variables with no value type specified in iterable type array\\.$#"
message: '#^Method Ibexa\\FieldTypeQuery\\QueryFieldService\:\:resolveParameters\(\) has parameter \$expressions with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/QueryFieldService.php

-
message: "#^Method Ibexa\\\\FieldTypeQuery\\\\QueryFieldService\\:\\:resolveParameters\\(\\) has parameter \\$expressions with no value type specified in iterable type array\\.$#"
message: '#^Method Ibexa\\FieldTypeQuery\\QueryFieldService\:\:resolveParameters\(\) has parameter \$variables with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/QueryFieldService.php

-
message: "#^Method Ibexa\\\\FieldTypeQuery\\\\QueryFieldService\\:\\:resolveParameters\\(\\) has parameter \\$variables with no value type specified in iterable type array\\.$#"
count: 1
path: src/lib/QueryFieldService.php

-
message: "#^Method Ibexa\\\\FieldTypeQuery\\\\QueryFieldService\\:\\:resolveParameters\\(\\) return type has no value type specified in iterable type array\\.$#"
message: '#^Method Ibexa\\FieldTypeQuery\\QueryFieldService\:\:resolveParameters\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/lib/QueryFieldService.php
10 changes: 5 additions & 5 deletions spec/ContentView/FieldDefinitionIdentifierMatcherSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class FieldDefinitionIdentifierMatcherSpec extends ObjectBehavior

public const FIELD_DEFINITION_IDENTIFIER = 'field_definition';

public function it_is_initializable()
public function it_is_initializable(): void
{
$this->shouldHaveType(FieldDefinitionIdentifierMatcher::class);
$this->shouldHaveType(ViewMatcherInterface::class);
Expand All @@ -45,27 +45,27 @@ public static function initialize(Repository $repository, array $matchingConfig)
return $matcher;
}

public function let(Repository $repository, ContentTypeService $contentTypeService)
public function let(Repository $repository, ContentTypeService $contentTypeService): void
{
$repository->getContentTypeService()->willReturn($contentTypeService);
$contentTypeService->loadContentType(self::CONTENT_TYPE_ID_WITHOUT_FIELD_DEFINITION)->willReturn($this->createContentTypeWithoutFieldDefinition());
$contentTypeService->loadContentType(self::CONTENT_TYPE_ID_WITH_FIELD_DEFINITION)->willReturn($this->createMatchingContentTypeWithFieldDefinition());
$this->beConstructedThrough([$this, 'initialize'], [$repository, [self::FIELD_DEFINITION_IDENTIFIER]]);
}

public function it_does_not_match_if_field_definition_identifier_does_not_exist()
public function it_does_not_match_if_field_definition_identifier_does_not_exist(): void
{
$view = $this->buildView(self::CONTENT_TYPE_ID_WITHOUT_FIELD_DEFINITION);
$this->match($view)->shouldBe(false);
}

public function it_matches_if_field_definition_identifier_matches()
public function it_matches_if_field_definition_identifier_matches(): void
{
$view = $this->buildView(self::CONTENT_TYPE_ID_WITH_FIELD_DEFINITION);
$this->match($view)->shouldBe(true);
}

private function buildView($contentTypeId): ContentView
private function buildView(int $contentTypeId): ContentView
{
$view = new ContentView();
$view->setContent(
Expand Down
26 changes: 12 additions & 14 deletions spec/ContentView/QueryResultsInjectorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ class QueryResultsInjectorSpec extends ObjectBehavior
public const VIEWS = ['field' => self::FIELD_VIEW, 'item' => self::ITEM_VIEW];
public const FIELD_DEFINITION_IDENTIFIER = 'query_field';

/** @var \Ibexa\Core\MVC\Symfony\View\ContentView */
private $view;
private ContentView $view;

/** @var \Ibexa\Core\MVC\Symfony\View\Event\FilterViewParametersEvent */
private $event;
private FilterViewParametersEvent $event;

public function __construct()
{
Expand All @@ -52,7 +50,7 @@ public function __construct()
);
}

public function it_is_initializable()
public function it_is_initializable(): void
{
$this->shouldHaveType(QueryResultsInjector::class);
}
Expand All @@ -61,7 +59,7 @@ public function let(
QueryFieldServiceInterface $queryFieldService,
FilterViewParametersEvent $event,
RequestStack $requestStack
) {
): void {
$this->beConstructedWith($queryFieldService, self::VIEWS, $requestStack);
$event->getView()->willReturn($this->view);
$event->getBuilderParameters()->willReturn(
Expand All @@ -76,37 +74,37 @@ public function let(
public function it_throws_an_InvalidArgumentException_if_no_item_view_is_provided(
QueryFieldServiceInterface $queryFieldService,
RequestStack $requestStack
) {
): void {
$this->beConstructedWith($queryFieldService, ['field' => self::FIELD_VIEW], $requestStack);
$this->shouldThrow(\InvalidArgumentException::class)->duringInstantiation();
}

public function it_throws_an_InvalidArgumentException_if_no_field_view_is_provided(
QueryFieldServiceInterface $queryFieldService,
RequestStack $requestStack
) {
): void {
$this->beConstructedWith($queryFieldService, ['item' => 'field'], $requestStack);
$this->shouldThrow(\InvalidArgumentException::class)->duringInstantiation();
}

public function it_is_an_event_subscriber()
public function it_is_an_event_subscriber(): void
{
$this->shouldHaveType(EventSubscriberInterface::class);
}

public function it_subscribes_to_the_FILTER_VIEW_PARAMETERS_View_Event()
public function it_subscribes_to_the_FILTER_VIEW_PARAMETERS_View_Event(): void
{
$this->getSubscribedEvents()->shouldSubscribeTo(ViewEvents::FILTER_VIEW_PARAMETERS);
}

public function it_does_nothing_for_non_field_views(QueryFieldServiceInterface $queryFieldService)
public function it_does_nothing_for_non_field_views(QueryFieldServiceInterface $queryFieldService): void
{
$this->event->getView()->setViewType(self::OTHER_VIEW);
$this->injectQueryResults($this->event);
$queryFieldService->getPaginationConfiguration(Argument::any())->shouldNotHaveBeenCalled();
}

public function it_adds_the_query_results_for_the_field_view_without_pagination(QueryFieldServiceInterface $queryFieldService)
public function it_adds_the_query_results_for_the_field_view_without_pagination(QueryFieldServiceInterface $queryFieldService): void
{
$content = $this->createContentItem();

Expand All @@ -133,7 +131,7 @@ public function it_adds_the_query_results_for_the_field_view_without_pagination(
public function it_adds_the_query_results_for_the_field_view_with_pagination(
FilterViewParametersEvent $event,
QueryFieldServiceInterface $queryFieldService
) {
): void {
$content = $this->createContentItem();

$queryFieldService
Expand Down Expand Up @@ -161,7 +159,7 @@ public function it_adds_the_query_results_for_the_field_view_with_pagination(
public function getMatchers(): array
{
return [
'subscribeTo' => static function ($return, $event) {
'subscribeTo' => static function ($return, $event): bool {
return is_array($return) && isset($return[$event]);
},
];
Expand Down
10 changes: 5 additions & 5 deletions spec/ExceptionSafeQueryFieldServiceSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class ExceptionSafeQueryFieldServiceSpec extends ObjectBehavior
{
public function let(QueryFieldServiceInterface $queryFieldService)
public function let(QueryFieldServiceInterface $queryFieldService): void
{
$arguments = [
Argument::type(Content::class),
Expand All @@ -31,24 +31,24 @@ public function let(QueryFieldServiceInterface $queryFieldService)
$this->beConstructedWith($queryFieldService);
}

public function it_is_initializable()
public function it_is_initializable(): void
{
$this->shouldHaveType(ExceptionSafeQueryFieldService::class);
}

public function it_should_return_empty_results_on_count_content_items()
public function it_should_return_empty_results_on_count_content_items(): void
{
$result = $this->countContentItems(new Content([]), 'any');
$result->shouldBe(0);
}

public function it_should_return_empty_results_on_load_content_items()
public function it_should_return_empty_results_on_load_content_items(): void
{
$result = $this->loadContentItems(new Content([]), 'any');
$result->shouldBe([]);
}

public function it_should_return_empty_results_on_load_content_items_slice()
public function it_should_return_empty_results_on_load_content_items_slice(): void
{
$result = $this->loadContentItemsSlice(new Content([]), 'any', 0, 5);
$result->shouldBe([]);
Expand Down
Loading
Loading