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