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