Skip to content

Commit

Permalink
ExecutionEndNode always has a statement
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jul 20, 2024
1 parent f1abacd commit 27e0f91
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,14 @@ public function processStmtNodes(
if ($stmtCount === 0 && $shouldCheckLastStatement) {
/** @var Node\Stmt\Function_|Node\Stmt\ClassMethod|Expr\Closure $parentNode */
$parentNode = $parentNode;
$returnTypeNode = $parentNode->returnType;
if ($parentNode instanceof Expr\Closure) {
$parentNode = new Node\Stmt\Expression($parentNode, $parentNode->getAttributes());
}
$nodeCallback(new ExecutionEndNode(
$parentNode,
$statementResult,
$parentNode->returnType !== null,
$returnTypeNode !== null,
), $scope);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Node/ExecutionEndNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ class ExecutionEndNode extends NodeAbstract implements VirtualNode
{

public function __construct(
private Node $node,
private Node\Stmt $node,
private StatementResult $statementResult,
private bool $hasNativeReturnTypehint,
)
{
parent::__construct($node->getAttributes());
}

public function getNode(): Node
public function getNode(): Node\Stmt
{
return $this->node;
}
Expand Down

0 comments on commit 27e0f91

Please sign in to comment.