Skip to content

Commit 0e6f8e2

Browse files
committed
Added PHPStan
1 parent 87920d7 commit 0e6f8e2

File tree

3 files changed

+22
-87
lines changed

3 files changed

+22
-87
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,6 @@ parameters:
285285
count: 1
286286
path: src/contracts/Input/Handler.php
287287

288-
-
289-
message: "#^Method Ibexa\\\\Contracts\\\\Rest\\\\Input\\\\Parser\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
290-
count: 1
291-
path: src/contracts/Input/Parser.php
292-
293288
-
294289
message: "#^Cannot access offset mixed on Ibexa\\\\Contracts\\\\Rest\\\\Input\\\\Parser\\.$#"
295290
count: 2
@@ -2165,31 +2160,16 @@ parameters:
21652160
count: 1
21662161
path: src/lib/Server/Input/Parser/Aggregation/AbstractRangeAggregationParser.php
21672162

2168-
-
2169-
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Aggregation\\\\AbstractRangeAggregationParser\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
2170-
count: 1
2171-
path: src/lib/Server/Input/Parser/Aggregation/AbstractRangeAggregationParser.php
2172-
21732163
-
21742164
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Aggregation\\\\AbstractRangeAggregationParser\\:\\:parseAggregation\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
21752165
count: 1
21762166
path: src/lib/Server/Input/Parser/Aggregation/AbstractRangeAggregationParser.php
21772167

2178-
-
2179-
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Aggregation\\\\AbstractStatsAggregationParser\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
2180-
count: 1
2181-
path: src/lib/Server/Input/Parser/Aggregation/AbstractStatsAggregationParser.php
2182-
21832168
-
21842169
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Aggregation\\\\AbstractStatsAggregationParser\\:\\:parseAggregation\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
21852170
count: 1
21862171
path: src/lib/Server/Input/Parser/Aggregation/AbstractStatsAggregationParser.php
21872172

2188-
-
2189-
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Aggregation\\\\AbstractTermAggregationParser\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
2190-
count: 1
2191-
path: src/lib/Server/Input/Parser/Aggregation/AbstractTermAggregationParser.php
2192-
21932173
-
21942174
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Aggregation\\\\AbstractTermAggregationParser\\:\\:parseAggregation\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
21952175
count: 1
@@ -2290,11 +2270,6 @@ parameters:
22902270
count: 1
22912271
path: src/lib/Server/Input/Parser/Aggregation/ObjectStateTermAggregationParser.php
22922272

2293-
-
2294-
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Aggregation\\\\Range\\\\AbstractRangeParser\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
2295-
count: 1
2296-
path: src/lib/Server/Input/Parser/Aggregation/Range/AbstractRangeParser.php
2297-
22982273
-
22992274
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Aggregation\\\\Range\\\\AbstractRangeParser\\:\\:visitRangeValue\\(\\) has no return type specified\\.$#"
23002275
count: 1
@@ -2465,16 +2440,6 @@ parameters:
24652440
count: 1
24662441
path: src/lib/Server/Input/Parser/Criterion/FullText.php
24672442

2468-
-
2469-
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Criterion\\\\IsUserBased\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
2470-
count: 1
2471-
path: src/lib/Server/Input/Parser/Criterion/IsUserBased.php
2472-
2473-
-
2474-
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Criterion\\\\IsUserEnabled\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
2475-
count: 1
2476-
path: src/lib/Server/Input/Parser/Criterion/IsUserEnabled.php
2477-
24782443
-
24792444
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Criterion\\\\LanguageCode\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
24802445
count: 1
@@ -2545,11 +2510,6 @@ parameters:
25452510
count: 1
25462511
path: src/lib/Server/Input/Parser/Criterion/ObjectStateId.php
25472512

2548-
-
2549-
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Criterion\\\\ObjectStateIdentifier\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
2550-
count: 1
2551-
path: src/lib/Server/Input/Parser/Criterion/ObjectStateIdentifier.php
2552-
25532513
-
25542514
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Criterion\\\\Operator\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
25552515
count: 1
@@ -2575,41 +2535,16 @@ parameters:
25752535
count: 1
25762536
path: src/lib/Server/Input/Parser/Criterion/SectionId.php
25772537

2578-
-
2579-
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Criterion\\\\SectionIdentifier\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
2580-
count: 1
2581-
path: src/lib/Server/Input/Parser/Criterion/SectionIdentifier.php
2582-
2583-
-
2584-
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Criterion\\\\Sibling\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
2585-
count: 1
2586-
path: src/lib/Server/Input/Parser/Criterion/Sibling.php
2587-
25882538
-
25892539
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Criterion\\\\Subtree\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
25902540
count: 1
25912541
path: src/lib/Server/Input/Parser/Criterion/Subtree.php
25922542

2593-
-
2594-
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Criterion\\\\UserEmail\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
2595-
count: 1
2596-
path: src/lib/Server/Input/Parser/Criterion/UserEmail.php
2597-
2598-
-
2599-
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Criterion\\\\UserId\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
2600-
count: 1
2601-
path: src/lib/Server/Input/Parser/Criterion/UserId.php
2602-
26032543
-
26042544
message: "#^Parameter \\#1 \\$value of class Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\Criterion\\\\UserId constructor expects array\\<int\\>\\|int, array\\<int, string\\> given\\.$#"
26052545
count: 1
26062546
path: src/lib/Server/Input/Parser/Criterion/UserId.php
26072547

2608-
-
2609-
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Criterion\\\\UserLogin\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
2610-
count: 1
2611-
path: src/lib/Server/Input/Parser/Criterion/UserLogin.php
2612-
26132548
-
26142549
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Criterion\\\\UserMetadata\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
26152550
count: 1
@@ -2680,11 +2615,6 @@ parameters:
26802615
count: 1
26812616
path: src/lib/Server/Input/Parser/FieldDefinitionUpdate.php
26822617

2683-
-
2684-
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\JWTInput\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
2685-
count: 1
2686-
path: src/lib/Server/Input/Parser/JWTInput.php
2687-
26882618
-
26892619
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Limitation\\\\PathStringRouteBasedLimitationParser\\:\\:parseIdFromHref\\(\\) has parameter \\$limitationValue with no type specified\\.$#"
26902620
count: 1
@@ -6675,16 +6605,6 @@ parameters:
66756605
count: 2
66766606
path: tests/bundle/Functional/UserTest.php
66776607

6678-
-
6679-
message: "#^Method Ibexa\\\\Tests\\\\Bundle\\\\Rest\\\\Functional\\\\ViewTest\\:\\:testViewRequestWithAndStatement\\(\\) has no return type specified\\.$#"
6680-
count: 1
6681-
path: tests/bundle/Functional/ViewTest.php
6682-
6683-
-
6684-
message: "#^Method Ibexa\\\\Tests\\\\Bundle\\\\Rest\\\\Functional\\\\ViewTest\\:\\:testViewRequestWithOrStatement\\(\\) has no return type specified\\.$#"
6685-
count: 1
6686-
path: tests/bundle/Functional/ViewTest.php
6687-
66886608
-
66896609
message: "#^Method Ibexa\\\\Tests\\\\Bundle\\\\Rest\\\\RequestParser\\\\RouterTest\\:\\:getRouterMock\\(\\) should return PHPUnit\\\\Framework\\\\MockObject\\\\MockObject&Symfony\\\\Component\\\\Routing\\\\RouterInterface but returns Symfony\\\\Component\\\\Routing\\\\RouterInterface\\.$#"
66906610
count: 1

src/contracts/Input/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ abstract class Parser
1414
/**
1515
* Parse input structure.
1616
*
17-
* @param array $data
17+
* @param array<mixed> $data
1818
* @param \Ibexa\Contracts\Rest\Input\ParsingDispatcher $parsingDispatcher
1919
*
2020
* @return \Ibexa\Contracts\Core\Repository\Values\ValueObject|object

tests/bundle/Functional/ViewTest.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,36 +95,51 @@ public function provideForViewTest(): iterable
9595
);
9696

9797
yield $template(self::CRITERION_LOCATION_DEPTH, self::OPERATOR_EQUALITY, self::FORMAT_XML) => [
98-
file_get_contents(__DIR__ . '/_input/search/LocationDepth.eq.xml'),
98+
$this->loadFile(__DIR__ . '/_input/search/LocationDepth.eq.xml'),
9999
self::FORMAT_XML,
100100
];
101101

102102
yield $template(self::CRITERION_LOCATION_DEPTH, self::OPERATOR_EQUALITY, self::FORMAT_JSON) => [
103-
file_get_contents(__DIR__ . '/_input/search/LocationDepth.eq.json'),
103+
$this->loadFile(__DIR__ . '/_input/search/LocationDepth.eq.json'),
104104
self::FORMAT_JSON,
105105
];
106106

107107
yield $template(self::CRITERION_LOCATION_DEPTH, self::OPERATOR_IN, self::FORMAT_XML) => [
108-
file_get_contents(__DIR__ . '/_input/search/LocationDepth.in.xml'),
108+
$this->loadFile(__DIR__ . '/_input/search/LocationDepth.in.xml'),
109109
self::FORMAT_XML,
110110
];
111111

112112
yield $template(self::CRITERION_LOCATION_DEPTH, self::OPERATOR_IN, self::FORMAT_JSON) => [
113-
file_get_contents(__DIR__ . '/_input/search/LocationDepth.in.json'),
113+
$this->loadFile(__DIR__ . '/_input/search/LocationDepth.in.json'),
114114
self::FORMAT_JSON,
115115
];
116116

117117
yield $template(self::CRITERION_IS_MAIN_LOCATION, self::OPERATOR_EQUALITY, self::FORMAT_XML) => [
118-
file_get_contents(__DIR__ . '/_input/search/IsMainLocation.xml'),
118+
$this->loadFile(__DIR__ . '/_input/search/IsMainLocation.xml'),
119119
self::FORMAT_XML,
120120
];
121121

122122
yield $template(self::CRITERION_IS_MAIN_LOCATION, self::OPERATOR_EQUALITY, self::FORMAT_JSON) => [
123-
file_get_contents(__DIR__ . '/_input/search/IsMainLocation.json'),
123+
$this->loadFile(__DIR__ . '/_input/search/IsMainLocation.json'),
124124
self::FORMAT_JSON,
125125
];
126126
}
127127

128+
private function loadFile(string $filepath): string
129+
{
130+
$data = file_get_contents($filepath);
131+
132+
if ($data === false) {
133+
throw new \RuntimeException(sprintf(
134+
'Unable to get contents for file: "%s". Ensure it exists and is readable.',
135+
$filepath,
136+
));
137+
}
138+
139+
return $data;
140+
}
141+
142+
128143
/**
129144
* Covers POST /views.
130145
*

0 commit comments

Comments
 (0)