Skip to content

Commit 62712f6

Browse files
authored
EnforceNativeReturnTypehintRule: minor cleanup (#153)
1 parent b88557b commit 62712f6

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed

src/Rule/EnforceNativeReturnTypehintRule.php

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
namespace ShipMonk\PHPStan\Rule;
44

55
use Generator;
6-
use LogicException;
76
use PhpParser\Node;
87
use PhpParser\Node\Stmt\Throw_;
98
use PHPStan\Analyser\Scope;
10-
use PHPStan\Node\ClosureReturnStatementsNode;
11-
use PHPStan\Node\FunctionReturnStatementsNode;
12-
use PHPStan\Node\MethodReturnStatementsNode;
139
use PHPStan\Node\ReturnStatementsNode;
1410
use PHPStan\Php\PhpVersion;
1511
use PHPStan\Rules\Rule;
@@ -74,7 +70,7 @@ public function processNode(Node $node, Scope $scope): array
7470
return [];
7571
}
7672

77-
if ($this->hasNativeReturnTypehint($node)) {
73+
if ($node->hasNativeReturnTypehint()) {
7874
return [];
7975
}
8076

@@ -202,26 +198,6 @@ private function getTypeOfReturnStatements(ReturnStatementsNode $node): Type
202198
return TypeCombinator::union(...$types);
203199
}
204200

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-
225201
private function getPhpDocReturnType(Node $node, Scope $scope): ?Type
226202
{
227203
$docComment = $node->getDocComment();

0 commit comments

Comments
 (0)