Skip to content

Commit 165497a

Browse files
committed
GetQueryReturnTypeExtension default return must be EntityQueryType
1 parent 49bdcfa commit 165497a

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/Type/EntityStorage/GetQueryReturnTypeExtension.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Drupal\Core\Entity\EntityStorageInterface;
88
use mglaman\PHPStanDrupal\Type\EntityQuery\ConfigEntityQueryType;
99
use mglaman\PHPStanDrupal\Type\EntityQuery\ContentEntityQueryType;
10+
use mglaman\PHPStanDrupal\Type\EntityQuery\EntityQueryType;
1011
use PhpParser\Node\Expr\MethodCall;
1112
use PHPStan\Analyser\Scope;
1213
use PHPStan\Reflection\MethodReflection;
@@ -56,6 +57,10 @@ public function getTypeFromMethodCall(
5657
$returnType->getClassReflection()
5758
);
5859
}
59-
return $returnType;
60+
return new EntityQueryType(
61+
$returnType->getClassName(),
62+
$returnType->getSubtractedType(),
63+
$returnType->getClassReflection()
64+
);
6065
}
6166
}

tests/src/Rules/EntityQueryHasAccessCheckRuleTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ public function cases(): \Generator
4545
],
4646
];
4747

48-
yield [
48+
yield 'bug-438.php' => [
4949
[__DIR__ . '/data/bug-438.php'],
5050
[]
5151
];
52-
yield [
52+
yield 'bug-396a.php' => [
5353
[__DIR__.'/data/bug-396a.php'],
5454
[
5555
[
@@ -59,11 +59,11 @@ public function cases(): \Generator
5959
]
6060
]
6161
];
62-
yield [
62+
yield 'bug-396b.php' => [
6363
[__DIR__ . '/data/bug-396b.php'],
6464
[]
6565
];
66-
yield [
66+
yield 'bug-396c.php' => [
6767
[__DIR__ . '/data/bug-396c.php'],
6868
[]
6969
];

0 commit comments

Comments
 (0)