Skip to content

Commit

Permalink
[TypeDeclaration] Clean up never type check on AddNeverReturnType (#6304
Browse files Browse the repository at this point in the history
)
  • Loading branch information
samsonasik authored Sep 15, 2024
1 parent dd93b38 commit 5da2f33
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions rules/TypeDeclaration/NodeManipulator/AddNeverReturnType.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public function add(ClassMethod|Function_|Closure $node, Scope $scope): ClassMet

private function shouldSkip(ClassMethod | Function_ | Closure $node, Scope $scope): bool
{
// already has return type, and non-void
// it can be "never" return itself, or other return type
if ($node->returnType instanceof Node && ! $this->nodeNameResolver->isName($node->returnType, 'void')) {
return true;
}
Expand All @@ -69,14 +71,10 @@ private function shouldSkip(ClassMethod | Function_ | Closure $node, Scope $scop
}

// skip as most likely intentional
if (! $this->classModifierChecker->isInsideFinalClass($node) && $this->nodeNameResolver->isName(
return ! $this->classModifierChecker->isInsideFinalClass($node) && $this->nodeNameResolver->isName(
$node->returnType,
'void'
)) {
return true;
}

return $this->nodeNameResolver->isName($node->returnType, 'never');
);
}

private function hasReturnOrYields(ClassMethod|Function_|Closure $node): bool
Expand Down

0 comments on commit 5da2f33

Please sign in to comment.