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\Function_; |
8: | use PhpParser\NodeAbstract; |
9: | use PHPStan\Analyser\StatementResult; |
10: | use function count; |
11: | |
12: | |
13: | class FunctionReturnStatementsNode extends NodeAbstract implements ReturnStatementsNode |
14: | { |
15: | |
16: | |
17: | |
18: | |
19: | |
20: | |
21: | public function __construct( |
22: | private Function_ $function, |
23: | private array $returnStatements, |
24: | private array $yieldStatements, |
25: | private StatementResult $statementResult, |
26: | private array $executionEnds, |
27: | ) |
28: | { |
29: | parent::__construct($function->getAttributes()); |
30: | } |
31: | |
32: | public function getReturnStatements(): array |
33: | { |
34: | return $this->returnStatements; |
35: | } |
36: | |
37: | public function getStatementResult(): StatementResult |
38: | { |
39: | return $this->statementResult; |
40: | } |
41: | |
42: | public function getExecutionEnds(): array |
43: | { |
44: | return $this->executionEnds; |
45: | } |
46: | |
47: | public function returnsByRef(): bool |
48: | { |
49: | return $this->function->byRef; |
50: | } |
51: | |
52: | public function hasNativeReturnTypehint(): bool |
53: | { |
54: | return $this->function->returnType !== null; |
55: | } |
56: | |
57: | public function getYieldStatements(): array |
58: | { |
59: | return $this->yieldStatements; |
60: | } |
61: | |
62: | public function isGenerator(): bool |
63: | { |
64: | return count($this->yieldStatements) > 0; |
65: | } |
66: | |
67: | public function getType(): string |
68: | { |
69: | return 'PHPStan_Node_FunctionReturnStatementsNode'; |
70: | } |
71: | |
72: | |
73: | |
74: | |
75: | public function getSubNodeNames(): array |
76: | { |
77: | return []; |
78: | } |
79: | |
80: | } |
81: | |