|
3 | 3 | namespace ShipMonk\PHPStan\Rule;
|
4 | 4 |
|
5 | 5 | use Generator;
|
6 |
| -use LogicException; |
7 | 6 | use PhpParser\Node;
|
8 | 7 | use PhpParser\Node\Stmt\Throw_;
|
9 | 8 | use PHPStan\Analyser\Scope;
|
10 |
| -use PHPStan\Node\ClosureReturnStatementsNode; |
11 |
| -use PHPStan\Node\FunctionReturnStatementsNode; |
12 |
| -use PHPStan\Node\MethodReturnStatementsNode; |
13 | 9 | use PHPStan\Node\ReturnStatementsNode;
|
14 | 10 | use PHPStan\Php\PhpVersion;
|
15 | 11 | use PHPStan\Rules\Rule;
|
@@ -74,7 +70,7 @@ public function processNode(Node $node, Scope $scope): array
|
74 | 70 | return [];
|
75 | 71 | }
|
76 | 72 |
|
77 |
| - if ($this->hasNativeReturnTypehint($node)) { |
| 73 | + if ($node->hasNativeReturnTypehint()) { |
78 | 74 | return [];
|
79 | 75 | }
|
80 | 76 |
|
@@ -202,26 +198,6 @@ private function getTypeOfReturnStatements(ReturnStatementsNode $node): Type
|
202 | 198 | return TypeCombinator::union(...$types);
|
203 | 199 | }
|
204 | 200 |
|
205 |
| - /** |
206 |
| - * To be removed once we bump phpstan version to 1.9.5+ (https://github.com/phpstan/phpstan-src/pull/2141) |
207 |
| - */ |
208 |
| - private function hasNativeReturnTypehint(ReturnStatementsNode $node): bool |
209 |
| - { |
210 |
| - if ($node instanceof MethodReturnStatementsNode) { // @phpstan-ignore-line ignore bc warning |
211 |
| - return $node->hasNativeReturnTypehint(); |
212 |
| - } |
213 |
| - |
214 |
| - if ($node instanceof FunctionReturnStatementsNode) { // @phpstan-ignore-line ignore bc warning |
215 |
| - return $node->hasNativeReturnTypehint(); |
216 |
| - } |
217 |
| - |
218 |
| - if ($node instanceof ClosureReturnStatementsNode) { // @phpstan-ignore-line ignore bc warning |
219 |
| - return $node->getClosureExpr()->returnType !== null; |
220 |
| - } |
221 |
| - |
222 |
| - throw new LogicException('Unexpected subtype'); |
223 |
| - } |
224 |
| - |
225 | 201 | private function getPhpDocReturnType(Node $node, Scope $scope): ?Type
|
226 | 202 | {
|
227 | 203 | $docComment = $node->getDocComment();
|
|
0 commit comments