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