Skip to content

Commit 3e39f17

Browse files
committed
IBX-9727: Added type-hints and adapted codebase to PHP8+
1 parent 2c4bfe6 commit 3e39f17

32 files changed

+317
-397
lines changed

phpstan-baseline.neon

Lines changed: 3 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,19 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: '#^Parameter \#1 \$locationId of method Ibexa\\Contracts\\Core\\Repository\\LocationService\:\:loadLocation\(\) expects int, int\|null given\.$#'
5-
identifier: argument.type
6-
count: 1
7-
path: src/bundle/Controller/QueryFieldRestController.php
8-
9-
-
10-
message: '#^Parameter \#1 \$uri of method Ibexa\\Contracts\\Rest\\UriParser\\UriParserInterface\:\:getAttributeFromUri\(\) expects string, string\|null given\.$#'
11-
identifier: argument.type
12-
count: 1
13-
path: src/bundle/Controller/QueryFieldRestController.php
14-
15-
-
16-
message: '#^Argument of an invalid type array\|bool\|float\|int\|string\|null supplied for foreach, only iterables are supported\.$#'
4+
message: '#^Argument of an invalid type array\|bool\|float\|int\|string supplied for foreach, only iterables are supported\.$#'
175
identifier: foreach.nonIterable
186
count: 1
197
path: src/bundle/DependencyInjection/Compiler/FieldDefinitionIdentifierViewMatcherPass.php
208

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

2715
-
28-
message: '#^Parameter \#2 \$callback of function array_filter expects \(callable\(int\|string\)\: bool\)\|null, Closure\(mixed\)\: \(0\|1\|false\) given\.$#'
16+
message: '#^Parameter \#2 \$callback of function array_filter expects \(callable\(int\|string\)\: bool\)\|null, Closure\(string\)\: \(0\|1\|false\) given\.$#'
2917
identifier: argument.type
3018
count: 1
3119
path: src/bundle/DependencyInjection/Compiler/FieldDefinitionIdentifierViewMatcherPass.php
@@ -36,36 +24,6 @@ parameters:
3624
count: 1
3725
path: src/bundle/DependencyInjection/Compiler/QueryTypesListPass.php
3826

39-
-
40-
message: '#^Parameter \#1 \$input of static method Symfony\\Component\\Yaml\\Yaml\:\:parse\(\) expects string, string\|false given\.$#'
41-
identifier: argument.type
42-
count: 1
43-
path: src/bundle/DependencyInjection/IbexaFieldTypeQueryExtension.php
44-
45-
-
46-
message: '#^Method Ibexa\\FieldTypeQuery\\ContentView\\QueryResultsInjector\:\:__construct\(\) has parameter \$views with no value type specified in iterable type array\.$#'
47-
identifier: missingType.iterableValue
48-
count: 1
49-
path: src/lib/ContentView/QueryResultsInjector.php
50-
51-
-
52-
message: '#^Property Ibexa\\FieldTypeQuery\\ContentView\\QueryResultsInjector\:\:\$queryFieldService \(Ibexa\\Contracts\\FieldTypeQuery\\QueryFieldLocationService&Ibexa\\Contracts\\FieldTypeQuery\\QueryFieldServiceInterface\) does not accept Ibexa\\Contracts\\FieldTypeQuery\\QueryFieldServiceInterface\.$#'
53-
identifier: assign.propertyType
54-
count: 1
55-
path: src/lib/ContentView/QueryResultsInjector.php
56-
57-
-
58-
message: '#^Property Ibexa\\FieldTypeQuery\\ContentView\\QueryResultsInjector\:\:\$views type has no value type specified in iterable type array\.$#'
59-
identifier: missingType.iterableValue
60-
count: 1
61-
path: src/lib/ContentView/QueryResultsInjector.php
62-
63-
-
64-
message: '#^Property Ibexa\\FieldTypeQuery\\ExceptionSafeQueryFieldService\:\:\$inner \(Ibexa\\Contracts\\FieldTypeQuery\\QueryFieldLocationService&Ibexa\\Contracts\\FieldTypeQuery\\QueryFieldServiceInterface\) does not accept Ibexa\\Contracts\\FieldTypeQuery\\QueryFieldServiceInterface\.$#'
65-
identifier: assign.propertyType
66-
count: 1
67-
path: src/lib/ExceptionSafeQueryFieldService.php
68-
6927
-
7028
message: '#^Generator expects key type string, string\|null given\.$#'
7129
identifier: generator.keyType
@@ -78,38 +36,8 @@ parameters:
7836
count: 1
7937
path: src/lib/Persistence/Legacy/Content/FieldValue/Converter/QueryConverter.php
8038

81-
-
82-
message: '#^Method Ibexa\\FieldTypeQuery\\QueryFieldService\:\:isExpression\(\) has parameter \$expression with no type specified\.$#'
83-
identifier: missingType.parameter
84-
count: 1
85-
path: src/lib/QueryFieldService.php
86-
87-
-
88-
message: '#^Method Ibexa\\FieldTypeQuery\\QueryFieldService\:\:prepareQuery\(\) has parameter \$extraParameters with no value type specified in iterable type array\.$#'
89-
identifier: missingType.iterableValue
90-
count: 1
91-
path: src/lib/QueryFieldService.php
92-
9339
-
9440
message: '#^Method Ibexa\\FieldTypeQuery\\QueryFieldService\:\:resolveExpression\(\) has parameter \$variables with no value type specified in iterable type array\.$#'
9541
identifier: missingType.iterableValue
9642
count: 1
9743
path: src/lib/QueryFieldService.php
98-
99-
-
100-
message: '#^Method Ibexa\\FieldTypeQuery\\QueryFieldService\:\:resolveParameters\(\) has parameter \$expressions with no value type specified in iterable type array\.$#'
101-
identifier: missingType.iterableValue
102-
count: 1
103-
path: src/lib/QueryFieldService.php
104-
105-
-
106-
message: '#^Method Ibexa\\FieldTypeQuery\\QueryFieldService\:\:resolveParameters\(\) has parameter \$variables with no value type specified in iterable type array\.$#'
107-
identifier: missingType.iterableValue
108-
count: 1
109-
path: src/lib/QueryFieldService.php
110-
111-
-
112-
message: '#^Method Ibexa\\FieldTypeQuery\\QueryFieldService\:\:resolveParameters\(\) return type has no value type specified in iterable type array\.$#'
113-
identifier: missingType.iterableValue
114-
count: 1
115-
path: src/lib/QueryFieldService.php

spec/ContentView/FieldDefinitionIdentifierMatcherSpec.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
* @copyright Copyright (C) Ibexa AS. All rights reserved.
55
* @license For full copyright and license information view LICENSE file distributed with this source code.
66
*/
7+
declare(strict_types=1);
78

8-
namespace spec\Ibexa\FieldTypeQuery\ContentView;
9+
namespace spec\Ibexa\FieldTypeQuery\spec\ContentView;
910

1011
use Ibexa\Contracts\Core\Repository\ContentTypeService;
1112
use Ibexa\Contracts\Core\Repository\Repository;
@@ -20,15 +21,15 @@
2021
use Ibexa\FieldTypeQuery\ContentView\FieldDefinitionIdentifierMatcher;
2122
use PhpSpec\ObjectBehavior;
2223

23-
class FieldDefinitionIdentifierMatcherSpec extends ObjectBehavior
24+
final class FieldDefinitionIdentifierMatcherSpec extends ObjectBehavior
2425
{
25-
private const CONTENT_TYPE_ID_WITHOUT_FIELD_DEFINITION = 2;
26-
private const CONTENT_TYPE_IDENTIFIER_WITHOUT_FIELD_DEFINITION = 'type_matching_without_field_def';
26+
private const int CONTENT_TYPE_ID_WITHOUT_FIELD_DEFINITION = 2;
27+
private const string CONTENT_TYPE_IDENTIFIER_WITHOUT_FIELD_DEFINITION = 'type_matching_without_field_def';
2728

28-
private const CONTENT_TYPE_ID_WITH_FIELD_DEFINITION = 3;
29-
private const CONTENT_TYPE_IDENTIFIER_WITH_FIELD_DEFINITION = 'type_matching_with_field_def';
29+
private const int CONTENT_TYPE_ID_WITH_FIELD_DEFINITION = 3;
30+
private const string CONTENT_TYPE_IDENTIFIER_WITH_FIELD_DEFINITION = 'type_matching_with_field_def';
3031

31-
public const FIELD_DEFINITION_IDENTIFIER = 'field_definition';
32+
public const string FIELD_DEFINITION_IDENTIFIER = 'field_definition';
3233

3334
public function it_is_initializable(): void
3435
{

spec/ContentView/QueryResultsInjectorSpec.php

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @copyright Copyright (C) Ibexa AS. All rights reserved.
55
* @license For full copyright and license information view LICENSE file distributed with this source code.
66
*/
7+
declare(strict_types=1);
78

89
namespace spec\Ibexa\FieldTypeQuery\ContentView;
910

@@ -12,21 +13,20 @@
1213
use Ibexa\Core\MVC\Symfony\View\Event\FilterViewParametersEvent;
1314
use Ibexa\Core\MVC\Symfony\View\ViewEvents;
1415
use Ibexa\Core\Repository\Values\Content\Content;
15-
use Ibexa\FieldTypeQuery\ContentView\QueryResultsInjector;
1616
use Pagerfanta\Pagerfanta;
1717
use PhpSpec\ObjectBehavior;
1818
use Prophecy\Argument;
1919
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
2020
use Symfony\Component\HttpFoundation\RequestStack;
2121
use Webmozart\Assert\Assert;
2222

23-
class QueryResultsInjectorSpec extends ObjectBehavior
23+
final class QueryResultsInjectorSpec extends ObjectBehavior
2424
{
25-
public const FIELD_VIEW = 'content_query_field';
26-
public const OTHER_VIEW = 'anything_else';
27-
public const ITEM_VIEW = 'line';
28-
public const VIEWS = ['field' => self::FIELD_VIEW, 'item' => self::ITEM_VIEW];
29-
public const FIELD_DEFINITION_IDENTIFIER = 'query_field';
25+
public const string FIELD_VIEW = 'content_query_field';
26+
public const string OTHER_VIEW = 'anything_else';
27+
public const string ITEM_VIEW = 'line';
28+
public const array VIEWS = ['field' => self::FIELD_VIEW, 'item' => self::ITEM_VIEW];
29+
public const string FIELD_DEFINITION_IDENTIFIER = 'query_field';
3030

3131
private ContentView $view;
3232

@@ -50,11 +50,6 @@ public function __construct()
5050
);
5151
}
5252

53-
public function it_is_initializable(): void
54-
{
55-
$this->shouldHaveType(QueryResultsInjector::class);
56-
}
57-
5853
public function let(
5954
QueryFieldServiceInterface $queryFieldService,
6055
FilterViewParametersEvent $event,
@@ -104,8 +99,9 @@ public function it_does_nothing_for_non_field_views(QueryFieldServiceInterface $
10499
$queryFieldService->getPaginationConfiguration(Argument::any())->shouldNotHaveBeenCalled();
105100
}
106101

107-
public function it_adds_the_query_results_for_the_field_view_without_pagination(QueryFieldServiceInterface $queryFieldService): void
108-
{
102+
public function it_adds_the_query_results_for_the_field_view_without_pagination(
103+
QueryFieldServiceInterface $queryFieldService
104+
): void {
109105
$content = $this->createContentItem();
110106

111107
$queryFieldService
@@ -128,6 +124,9 @@ public function it_adds_the_query_results_for_the_field_view_without_pagination(
128124
Assert::eq($parameters->get('items'), $this->getResults());
129125
}
130126

127+
/**
128+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
129+
*/
131130
public function it_adds_the_query_results_for_the_field_view_with_pagination(
132131
FilterViewParametersEvent $event,
133132
QueryFieldServiceInterface $queryFieldService
@@ -156,6 +155,9 @@ public function it_adds_the_query_results_for_the_field_view_with_pagination(
156155
Assert::isInstanceOf($parameters->get('items'), Pagerfanta::class);
157156
}
158157

158+
/**
159+
* @return array<string, callable>
160+
*/
159161
public function getMatchers(): array
160162
{
161163
return [
@@ -170,6 +172,9 @@ private function createContentItem(): Content
170172
return new Content();
171173
}
172174

175+
/**
176+
* @return \Ibexa\Core\Repository\Values\Content\Content[]
177+
*/
173178
private function getResults(): array
174179
{
175180
return [

spec/ExceptionSafeQueryFieldServiceSpec.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @copyright Copyright (C) Ibexa AS. All rights reserved.
55
* @license For full copyright and license information view LICENSE file distributed with this source code.
66
*/
7+
declare(strict_types=1);
78

89
namespace spec\Ibexa\FieldTypeQuery;
910

@@ -13,7 +14,7 @@
1314
use PhpSpec\ObjectBehavior;
1415
use Prophecy\Argument;
1516

16-
class ExceptionSafeQueryFieldServiceSpec extends ObjectBehavior
17+
final class ExceptionSafeQueryFieldServiceSpec extends ObjectBehavior
1718
{
1819
public function let(QueryFieldServiceInterface $queryFieldService): void
1920
{

spec/GraphQL/ContentQueryFieldDefinitionMapperSpec.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @copyright Copyright (C) Ibexa AS. All rights reserved.
55
* @license For full copyright and license information view LICENSE file distributed with this source code.
66
*/
7+
declare(strict_types=1);
78

89
namespace spec\Ibexa\FieldTypeQuery\GraphQL;
910

@@ -15,12 +16,12 @@
1516
use Ibexa\GraphQL\Schema\Domain\Content\NameHelper;
1617
use PhpSpec\ObjectBehavior;
1718

18-
class ContentQueryFieldDefinitionMapperSpec extends ObjectBehavior
19+
final class ContentQueryFieldDefinitionMapperSpec extends ObjectBehavior
1920
{
20-
public const FIELD_IDENTIFIER = 'test';
21-
public const FIELD_TYPE_IDENTIFIER = 'ibexa_content_query';
22-
public const RETURNED_CONTENT_TYPE_IDENTIFIER = 'folder';
23-
public const GRAPHQL_TYPE = 'FolderContent';
21+
public const string FIELD_IDENTIFIER = 'test';
22+
public const string FIELD_TYPE_IDENTIFIER = 'ibexa_content_query';
23+
public const string RETURNED_CONTENT_TYPE_IDENTIFIER = 'folder';
24+
public const string GRAPHQL_TYPE = 'FolderContent';
2425

2526
public function let(
2627
FieldDefinitionMapper $innerMapper,
@@ -100,11 +101,6 @@ public function it_maps_the_field_value_when_pagination_is_enabled(FieldDefiniti
100101
->shouldBe('@=resolver("QueryFieldValueConnection", [args, field, content])');
101102
}
102103

103-
/**
104-
* @param bool $enablePagination
105-
*
106-
* @return \Ibexa\Core\Repository\Values\ContentType\FieldDefinition
107-
*/
108104
private function fieldDefinition(bool $enablePagination = false): FieldDefinition
109105
{
110106
return new FieldDefinition([
@@ -117,9 +113,6 @@ private function fieldDefinition(bool $enablePagination = false): FieldDefinitio
117113
]);
118114
}
119115

120-
/**
121-
* @return \Ibexa\Core\Repository\Values\ContentType\FieldDefinition
122-
*/
123116
protected function getLambdaFieldDefinition(): FieldDefinition
124117
{
125118
return new FieldDefinition(['fieldTypeIdentifier' => 'lambda']);

spec/GraphQL/QueryFieldResolverSpec.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @copyright Copyright (C) Ibexa AS. All rights reserved.
55
* @license For full copyright and license information view LICENSE file distributed with this source code.
66
*/
7+
declare(strict_types=1);
78

89
namespace spec\Ibexa\FieldTypeQuery\GraphQL;
910

@@ -13,9 +14,9 @@
1314
use Ibexa\GraphQL\Value\Field;
1415
use PhpSpec\ObjectBehavior;
1516

16-
class QueryFieldResolverSpec extends ObjectBehavior
17+
final class QueryFieldResolverSpec extends ObjectBehavior
1718
{
18-
public const FIELD_DEFINITION_IDENTIFIER = 'test';
19+
public const string FIELD_DEFINITION_IDENTIFIER = 'test';
1920

2021
public function let(QueryFieldServiceInterface $queryFieldService): void
2122
{

spec/Persistence/Legacy/Content/FieldValue/Converter/QueryConverterSpec.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @copyright Copyright (C) Ibexa AS. All rights reserved.
55
* @license For full copyright and license information view LICENSE file distributed with this source code.
66
*/
7+
declare(strict_types=1);
78

89
namespace spec\Ibexa\FieldTypeQuery\Persistence\Legacy\Content\FieldValue\Converter;
910

@@ -13,13 +14,13 @@
1314
use PhpSpec\ObjectBehavior;
1415
use Webmozart\Assert\Assert;
1516

16-
class QueryConverterSpec extends ObjectBehavior
17+
final class QueryConverterSpec extends ObjectBehavior
1718
{
18-
public const PARAMETERS = ['param1' => 'value1', 'param2' => 'value2'];
19-
public const QUERY_TYPE = 'SomeQueryType';
20-
public const RETURNED_TYPE = 'folder';
21-
public const ENABLE_PAGINATION = true;
22-
public const ITEMS_PER_PAGE = 10;
19+
public const array PARAMETERS = ['param1' => 'value1', 'param2' => 'value2'];
20+
public const string QUERY_TYPE = 'SomeQueryType';
21+
public const string RETURNED_TYPE = 'folder';
22+
public const bool ENABLE_PAGINATION = true;
23+
public const int ITEMS_PER_PAGE = 10;
2324

2425
public function it_is_initializable(): void
2526
{

0 commit comments

Comments
 (0)