1: | <?php declare(strict_types = 1); |
2: | |
3: | namespace PHPStan\Node; |
4: | |
5: | use PhpParser\Node; |
6: | use PhpParser\Node\Expr\Closure; |
7: | use PhpParser\Node\Expr\Yield_; |
8: | use PhpParser\Node\Expr\YieldFrom; |
9: | use PhpParser\NodeAbstract; |
10: | use PHPStan\Analyser\StatementResult; |
11: | use function count; |
12: | |
13: | |
14: | class ClosureReturnStatementsNode extends NodeAbstract implements ReturnStatementsNode |
15: | { |
16: | |
17: | private Node\Expr\Closure $closureExpr; |
18: | |
19: | |
20: | |
21: | |
22: | |
23: | |
24: | public function __construct( |
25: | Closure $closureExpr, |
26: | private array $returnStatements, |
27: | private array $yieldStatements, |
28: | private StatementResult $statementResult, |
29: | private array $executionEnds, |
30: | ) |
31: | { |
32: | parent::__construct($closureExpr->getAttributes()); |
33: | $this->closureExpr = $closureExpr; |
34: | } |
35: | |
36: | public function getClosureExpr(): Closure |
37: | { |
38: | return $this->closureExpr; |
39: | } |
40: | |
41: | public function hasNativeReturnTypehint(): bool |
42: | { |
43: | return $this->closureExpr->returnType !== null; |
44: | } |
45: | |
46: | public function getReturnStatements(): array |
47: | { |
48: | return $this->returnStatements; |
49: | } |
50: | |
51: | public function getExecutionEnds(): array |
52: | { |
53: | return $this->executionEnds; |
54: | } |
55: | |
56: | public function getYieldStatements(): array |
57: | { |
58: | return $this->yieldStatements; |
59: | } |
60: | |
61: | public function isGenerator(): bool |
62: | { |
63: | return count($this->yieldStatements) > 0; |
64: | } |
65: | |
66: | public function getStatementResult(): StatementResult |
67: | { |
68: | return $this->statementResult; |
69: | } |
70: | |
71: | public function returnsByRef(): bool |
72: | { |
73: | return $this->closureExpr->byRef; |
74: | } |
75: | |
76: | public function getType(): string |
77: | { |
78: | return 'PHPStan_Node_ClosureReturnStatementsNode'; |
79: | } |
80: | |
81: | |
82: | |
83: | |
84: | public function getSubNodeNames(): array |
85: | { |
86: | return []; |
87: | } |
88: | |
89: | } |
90: | |