Skip to content

Commit a6a33e1

Browse files
alongoszViniTou
andauthored
IBX-9727: Added missing type hints (#80)
* [Composer] Bumped PHPStan to ^2.0 * [Rector] Applied SetList::TYPE_DECLARATION built-in Rector set Applied Rectors: * Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector * Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector * Rector\TypeDeclaration\Rector\ClassMethod\BoolReturnTypeFromBooleanStrictReturnsRector * Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByMethodCallTypeRector * Rector\TypeDeclaration\Rector\ClassMethod\ReturnNullableTypeRector * Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnDirectArrayRector * Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector * Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector * Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNewArrayRector * Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector * Rector\TypeDeclaration\Rector\ClassMethod\StrictArrayParamDimFetchRector * Rector\TypeDeclaration\Rector\ClassMethod\StrictStringParamConcatRector * Rector\TypeDeclaration\Rector\ClassMethod\StringReturnTypeFromStrictScalarReturnsRector * Rector\TypeDeclaration\Rector\ClassMethod\StringReturnTypeFromStrictStringReturnsRector * Rector\TypeDeclaration\Rector\Class_\ReturnTypeFromStrictTernaryRector * Rector\TypeDeclaration\Rector\Closure\AddClosureVoidReturnTypeWhereNoReturnRector * Rector\TypeDeclaration\Rector\Closure\ClosureReturnTypeRector * Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector * Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector --------- Co-authored-by: Dawid Parafinski <[email protected]>
1 parent 08adf4d commit a6a33e1

File tree

116 files changed

+1656
-2205
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+1656
-2205
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
"mikey179/vfsstream": "^1.6",
4646
"overblog/graphiql-bundle": "^1.0",
4747
"phpspec/phpspec": "^7.1",
48-
"phpstan/phpstan": "^1.10",
49-
"phpstan/phpstan-phpunit": "^1.3",
50-
"phpstan/phpstan-symfony": "^1.3"
48+
"phpstan/phpstan": "^2.0",
49+
"phpstan/phpstan-phpunit": "^2.0",
50+
"phpstan/phpstan-symfony": "^2.0"
5151
},
5252
"autoload": {
5353
"psr-4": {

phpstan-baseline.neon

Lines changed: 614 additions & 1271 deletions
Large diffs are not rendered by default.

spec/InputMapper/SearchQueryMapperSpec.php

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,150 @@
11
<?php
22

3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
38
namespace spec\Ibexa\GraphQL\InputMapper;
49

10+
use Ibexa\Contracts\Core\Repository\Values\Content\Query;
511
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Subtree;
612
use Ibexa\GraphQL\InputMapper\ContentCollectionFilterBuilder;
713
use Ibexa\GraphQL\InputMapper\SearchQueryMapper;
8-
use Ibexa\Contracts\Core\Repository\Values\Content\Query;
914
use PhpSpec\ObjectBehavior;
1015

1116
class SearchQueryMapperSpec extends ObjectBehavior
1217
{
13-
function let(ContentCollectionFilterBuilder $filterBuilder)
18+
public function let(ContentCollectionFilterBuilder $filterBuilder): void
1419
{
1520
$this->beConstructedWith($filterBuilder);
1621

1722
$filterBuilder->buildFilter()->willReturn(new Subtree('/1/2/'));
1823
}
1924

20-
function it_is_initializable()
25+
public function it_is_initializable(): void
2126
{
2227
$this->shouldHaveType(SearchQueryMapper::class);
2328
}
2429

25-
public function it_maps_ContentTypeIdentifier_to_a_ContentTypeIdentifier_criterion()
30+
public function it_maps_ContentTypeIdentifier_to_a_ContentTypeIdentifier_criterion(): void
2631
{
2732
$this->mapInputToQuery(['ContentTypeIdentifier' => ['article']])->shouldFilterByContentType(['article']);
2833
}
2934

30-
public function it_maps_Text_to_a_FullText_criterion()
35+
public function it_maps_Text_to_a_FullText_criterion(): void
3136
{
3237
$this
3338
->mapInputToQuery(['Text' => 'graphql'])
3439
->shouldFilterByFullText('graphql');
3540
}
3641

37-
public function it_maps_Modified_before_to_a_created_lte_DateMetaData_criterion()
42+
public function it_maps_Modified_before_to_a_created_lte_DateMetaData_criterion(): void
3843
{
3944
$this
4045
->mapInputToQuery(['Modified' => ['before' => '1977/05/04']])
4146
->shouldFilterByDateModified(Query\Criterion\Operator::LTE, '1977/05/04');
4247
}
4348

44-
public function it_maps_Modified_on_to_a_created_eq_DateMetaData_criterion()
49+
public function it_maps_Modified_on_to_a_created_eq_DateMetaData_criterion(): void
4550
{
4651
$this
4752
->mapInputToQuery(['Modified' => ['on' => '1977/05/04']])
4853
->shouldFilterByDateModified(Query\Criterion\Operator::EQ, '1977/05/04');
4954
}
5055

51-
public function it_maps_Modified_after_to_a_created_gte_DateMetaData_criterion()
56+
public function it_maps_Modified_after_to_a_created_gte_DateMetaData_criterion(): void
5257
{
5358
$this
5459
->mapInputToQuery(['Modified' => ['after' => '1977/05/04']])
5560
->shouldFilterByDateModified(Query\Criterion\Operator::GTE, '1977/05/04');
5661
}
5762

58-
public function it_maps_Created_before_to_a_created_lte_DateMetaData_criterion()
63+
public function it_maps_Created_before_to_a_created_lte_DateMetaData_criterion(): void
5964
{
6065
$this
6166
->mapInputToQuery(['Created' => ['before' => '1977/05/04']])
6267
->shouldFilterByDateCreated(Query\Criterion\Operator::LTE, '1977/05/04');
6368
}
6469

65-
public function it_maps_Created_on_to_a_created_eq_DateMetaData_criterion()
70+
public function it_maps_Created_on_to_a_created_eq_DateMetaData_criterion(): void
6671
{
6772
$this
6873
->mapInputToQuery(['Created' => ['on' => '1977/05/04']])
6974
->shouldFilterByDateCreated(Query\Criterion\Operator::EQ, '1977/05/04');
7075
}
7176

72-
public function it_maps_Created_after_to_a_created_gte_DateMetaData_criterion()
77+
public function it_maps_Created_after_to_a_created_gte_DateMetaData_criterion(): void
7378
{
7479
$this
7580
->mapInputToQuery(['Created' => ['after' => '1977/05/04']])
7681
->shouldFilterByDateCreated(Query\Criterion\Operator::GTE, '1977/05/04');
7782
}
7883

79-
function it_maps_Field_to_a_Field_criterion()
84+
public function it_maps_Field_to_a_Field_criterion(): void
8085
{
8186
$this
8287
->mapInputToQuery(['Field' => ['target' => 'target_field', 'eq' => 'bar']])
8388
->shouldFilterByField('target_field');
8489
}
8590

86-
function it_maps_Field_target_to_the_Field_criterion_target()
91+
public function it_maps_Field_target_to_the_Field_criterion_target(): void
8792
{
8893
$this
8994
->mapInputToQuery(['Field' => ['target' => 'target_field', 'eq' => 'bar']])
9095
->shouldFilterByField('target_field', Query\Criterion\Operator::EQ, 'bar');
9196
}
9297

93-
function it_maps_Field_with_value_at_operator_key_to_the_Field_criterion_value()
98+
public function it_maps_Field_with_value_at_operator_key_to_the_Field_criterion_value(): void
9499
{
95100
$this
96101
->mapInputToQuery(['Field' => ['target' => 'target_field', 'eq' => 'bar']])
97102
->shouldFilterByField('target_field', null, 'bar');
98103
}
99104

100-
function it_maps_Field_operator_eq_to_Field_criterion_operator_EQ()
105+
public function it_maps_Field_operator_eq_to_Field_criterion_operator_EQ(): void
101106
{
102107
$this
103108
->mapInputToQuery(['Field' => ['target' => 'target_field', 'eq' => 'bar']])
104109
->shouldFilterByFieldWithOperator(Query\Criterion\Operator::EQ);
105110
}
106111

107-
function it_maps_Field_operator_in_to_Field_criterion_operator_IN()
112+
public function it_maps_Field_operator_in_to_Field_criterion_operator_IN(): void
108113
{
109114
$this
110115
->mapInputToQuery(['Field' => ['target' => 'target_field', 'eq' => 'bar']])
111116
->shouldFilterByFieldWithOperator(Query\Criterion\Operator::EQ);
112117
}
113118

114-
function it_maps_Field_operator_lt_to_Field_criterion_operator_LT()
119+
public function it_maps_Field_operator_lt_to_Field_criterion_operator_LT(): void
115120
{
116121
$this
117122
->mapInputToQuery(['Field' => ['target' => 'target_field', 'lt' => 'bar']])
118123
->shouldFilterByFieldWithOperator(Query\Criterion\Operator::LT);
119124
}
120125

121-
function it_maps_Field_operator_lte_to_Field_criterion_operator_LTE()
126+
public function it_maps_Field_operator_lte_to_Field_criterion_operator_LTE(): void
122127
{
123128
$this
124129
->mapInputToQuery(['Field' => ['target' => 'target_field', 'lte' => 'bar']])
125130
->shouldFilterByFieldWithOperator(Query\Criterion\Operator::LTE);
126131
}
127132

128-
function it_maps_Field_operator_gte_to_Field_criterion_operator_GTE()
133+
public function it_maps_Field_operator_gte_to_Field_criterion_operator_GTE(): void
129134
{
130135
$this
131136
->mapInputToQuery(['Field' => ['target' => 'target_field', 'gte' => 'bar']])
132137
->shouldFilterByFieldWithOperator(Query\Criterion\Operator::GTE);
133138
}
134139

135-
function it_maps_Field_operator_gt_to_Field_criterion_operator_GT()
140+
public function it_maps_Field_operator_gt_to_Field_criterion_operator_GT(): void
136141
{
137142
$this
138143
->mapInputToQuery(['Field' => ['target' => 'target_field', 'gt' => 'bar']])
139144
->shouldFilterByFieldWithOperator(Query\Criterion\Operator::GT);
140145
}
141146

142-
function it_maps_Field_operator_between_to_Field_criterion_operator_BETWEEN()
147+
public function it_maps_Field_operator_between_to_Field_criterion_operator_BETWEEN(): void
143148
{
144149
$this
145150
->mapInputToQuery(['Field' => ['target' => 'target_field', 'between' => [10, 20]]])
@@ -149,7 +154,7 @@ function it_maps_Field_operator_between_to_Field_criterion_operator_BETWEEN()
149154
public function getMatchers(): array
150155
{
151156
return [
152-
'filterByContentType' => function(Query $query, array $contentTypes) {
157+
'filterByContentType' => function (Query $query, array $contentTypes): bool {
153158
$criterion = $this->findCriterionInQueryFilter(
154159
$query,
155160
Query\Criterion\ContentTypeIdentifier::class
@@ -161,7 +166,7 @@ public function getMatchers(): array
161166

162167
return $criterion->value === $contentTypes;
163168
},
164-
'filterByFullText' => function(Query $query, $text) {
169+
'filterByFullText' => function (Query $query, $text): bool {
165170
$criterion = $this->findCriterionInQueryFilter(
166171
$query,
167172
Query\Criterion\FullText::class
@@ -173,7 +178,7 @@ public function getMatchers(): array
173178

174179
return $criterion->value === $text;
175180
},
176-
'filterByDateModified' => function(Query $query, $operator, $date) {
181+
'filterByDateModified' => function (Query $query, $operator, $date): bool {
177182
$criterion = $this->findCriterionInQueryFilter($query, Query\Criterion\DateMetadata::class);
178183

179184
if ($criterion === null) {
@@ -187,7 +192,7 @@ public function getMatchers(): array
187192
return $criterion->operator == $operator
188193
&& $criterion->value[0] == strtotime($date);
189194
},
190-
'filterByDateCreated' => function(Query $query, $operator, $date) {
195+
'filterByDateCreated' => function (Query $query, $operator, $date): bool {
191196
$criterion = $this->findCriterionInQueryFilter($query, Query\Criterion\DateMetadata::class);
192197

193198
if ($criterion === null) {
@@ -201,7 +206,7 @@ public function getMatchers(): array
201206
return $criterion->operator == $operator
202207
&& $criterion->value[0] == strtotime($date);
203208
},
204-
'filterByField' => function(Query $query, $field, $operator = null, $value = null) {
209+
'filterByField' => function (Query $query, $field, $operator = null, $value = null): bool {
205210
$criterion = $this->findCriterionInQueryFilter($query, Query\Criterion\Field::class);
206211

207212
if ($criterion === null) {
@@ -215,20 +220,21 @@ public function getMatchers(): array
215220
if ($operator !== null && $criterion->operator != $operator) {
216221
return false;
217222
}
218-
return ($value === null || $criterion->value == $value);
223+
224+
return $value === null || $criterion->value == $value;
219225
},
220-
'filterByFieldWithOperator' => function(Query $query, $operator) {
226+
'filterByFieldWithOperator' => function (Query $query, $operator): bool {
221227
$criterion = $this->findCriterionInQueryFilter($query, Query\Criterion\Field::class);
222228
if ($criterion === null) {
223229
return false;
224230
}
225231

226232
return $criterion->operator == $operator;
227-
}
233+
},
228234
];
229235
}
230236

231-
private function findCriterionInQueryFilter(Query $query, $searchedCriterionClass)
237+
private function findCriterionInQueryFilter(Query $query, string $searchedCriterionClass)
232238
{
233239
if ($query->filter instanceof Query\Criterion\LogicalOperator) {
234240
return $this->findCriterionInCriterion($query->filter, $searchedCriterionClass);

0 commit comments

Comments
 (0)