Skip to content

Commit 3315f5d

Browse files
authored
test(phpstan): Enable PHPstan level 5 (#1123)
1 parent 668b413 commit 3315f5d

File tree

5 files changed

+9
-5
lines changed

5 files changed

+9
-5
lines changed

phpstan.neon

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ parameters:
88
# PHPStan cannot find files in this test directory automatically.
99
scanDirectories:
1010
- ../../core/tests/Drupal/Tests
11-
level: 4
11+
level: 5
1212
customRulesetUsed: true
1313
paths:
1414
- .
@@ -30,6 +30,8 @@ parameters:
3030
- "#deprecated class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent#"
3131
- "#^Method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch\\(\\) invoked with 2 parameters, 1 required\\.$#"
3232
- "#deprecated interface Symfony\\\\Component\\\\HttpFoundation\\\\File\\\\MimeType\\\\MimeTypeGuesserInterface#"
33+
- "#^Parameter .+ of class Symfony\\\\Component\\\\HttpFoundation\\\\File\\\\UploadedFile constructor expects .+ given\\.$#"
34+
- "#^Parameter \\#1 \\$event of method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch\\(\\) expects object, string given\\.$#"
3335
# Drupal allows object property access to custom fields, so we cannot fix
3436
# that.
3537
- "#^Property Drupal\\\\.+ \\(Drupal\\\\Core\\\\Field\\\\FieldItemListInterface\\) does not accept .+\\.$#"
@@ -38,3 +40,4 @@ parameters:
3840
message: "#^Method Drupal\\\\graphql\\\\Plugin\\\\LanguageNegotiation\\\\OperationLanguageNegotiation\\:\\:getLangcode\\(\\) should return string but returns false\\.$#"
3941
count: 1
4042
path: src/Plugin/LanguageNegotiation/OperationLanguageNegotiation.php
43+
- "#^Parameter .+ of method Drupal\\\\Core\\\\Entity\\\\Query\\\\QueryInterface\\:\\:range\\(\\) expects null, int given\\.$#"

src/GraphQL/Buffers/EntityBuffer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(EntityTypeManagerInterface $entityTypeManager) {
2828
*
2929
* @param string $type
3030
* The entity type of the given entity ids.
31-
* @param array|int $id
31+
* @param array|int|string $id
3232
* The entity id(s) to load.
3333
*
3434
* @return \Closure

tests/src/Kernel/Framework/UploadFileServiceTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ public function testLockReleased() {
222222
protected function getUploadedFile(
223223
int $error_status,
224224
int $size = 0,
225-
string $name = 'test.txt'): UploadedFile {
225+
string $name = 'test.txt'
226+
): UploadedFile {
226227

227228
list($version) = explode('.', \Drupal::VERSION, 2);
228229
switch ($version) {

tests/src/Traits/HttpRequestTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected function query($query, $server = NULL, array $variables = [], array $e
5757
/**
5858
* Simulate batched queries over http.
5959
*
60-
* @param string[] $queries
60+
* @param array[] $queries
6161
* A set of queries to be executed in one go.
6262
* @param \Drupal\graphql\Entity\ServerInterface $server
6363
* The server instance.

tests/src/Traits/QueryResultAssertionTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ private function assertResultErrors(ExecutionResult $result, array $expected) {
161161
while ($error = array_pop($errors)) {
162162
$match = FALSE;
163163
foreach ($expected as $pattern) {
164-
if (@preg_match($pattern, NULL) === FALSE) {
164+
if (@preg_match($pattern, $error) === FALSE) {
165165
$match = $match || $pattern == $error;
166166
$matchCount[$pattern]++;
167167
}

0 commit comments

Comments
 (0)