Skip to content

Commit 27e0f91

Browse files
committed
ExecutionEndNode always has a statement
1 parent f1abacd commit 27e0f91

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,14 @@ public function processStmtNodes(
394394
if ($stmtCount === 0 && $shouldCheckLastStatement) {
395395
/** @var Node\Stmt\Function_|Node\Stmt\ClassMethod|Expr\Closure $parentNode */
396396
$parentNode = $parentNode;
397+
$returnTypeNode = $parentNode->returnType;
398+
if ($parentNode instanceof Expr\Closure) {
399+
$parentNode = new Node\Stmt\Expression($parentNode, $parentNode->getAttributes());
400+
}
397401
$nodeCallback(new ExecutionEndNode(
398402
$parentNode,
399403
$statementResult,
400-
$parentNode->returnType !== null,
404+
$returnTypeNode !== null,
401405
), $scope);
402406
}
403407

src/Node/ExecutionEndNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ class ExecutionEndNode extends NodeAbstract implements VirtualNode
1111
{
1212

1313
public function __construct(
14-
private Node $node,
14+
private Node\Stmt $node,
1515
private StatementResult $statementResult,
1616
private bool $hasNativeReturnTypehint,
1717
)
1818
{
1919
parent::__construct($node->getAttributes());
2020
}
2121

22-
public function getNode(): Node
22+
public function getNode(): Node\Stmt
2323
{
2424
return $this->node;
2525
}

0 commit comments

Comments
 (0)