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\ClassMethod; |
9: | use PhpParser\NodeAbstract; |
10: | use PHPStan\Analyser\ImpurePoint; |
11: | use PHPStan\Analyser\StatementResult; |
12: | use PHPStan\Reflection\ClassReflection; |
13: | use PHPStan\Reflection\Php\PhpMethodFromParserNodeReflection; |
14: | use function count; |
15: | |
16: | |
17: | |
18: | |
19: | final class MethodReturnStatementsNode extends NodeAbstract implements ReturnStatementsNode |
20: | { |
21: | |
22: | private ClassMethod $classMethod; |
23: | |
24: | |
25: | |
26: | |
27: | |
28: | |
29: | |
30: | public function __construct( |
31: | ClassMethod $method, |
32: | private array $returnStatements, |
33: | private array $yieldStatements, |
34: | private StatementResult $statementResult, |
35: | private array $executionEnds, |
36: | private array $impurePoints, |
37: | private ClassReflection $classReflection, |
38: | private PhpMethodFromParserNodeReflection $methodReflection, |
39: | ) |
40: | { |
41: | parent::__construct($method->getAttributes()); |
42: | $this->classMethod = $method; |
43: | } |
44: | |
45: | public function getReturnStatements(): array |
46: | { |
47: | return $this->returnStatements; |
48: | } |
49: | |
50: | public function getStatementResult(): StatementResult |
51: | { |
52: | return $this->statementResult; |
53: | } |
54: | |
55: | public function getExecutionEnds(): array |
56: | { |
57: | return $this->executionEnds; |
58: | } |
59: | |
60: | public function getImpurePoints(): array |
61: | { |
62: | return $this->impurePoints; |
63: | } |
64: | |
65: | public function returnsByRef(): bool |
66: | { |
67: | return $this->classMethod->byRef; |
68: | } |
69: | |
70: | public function hasNativeReturnTypehint(): bool |
71: | { |
72: | return $this->classMethod->returnType !== null; |
73: | } |
74: | |
75: | public function getMethodName(): string |
76: | { |
77: | return $this->classMethod->name->toString(); |
78: | } |
79: | |
80: | public function getYieldStatements(): array |
81: | { |
82: | return $this->yieldStatements; |
83: | } |
84: | |
85: | public function getClassReflection(): ClassReflection |
86: | { |
87: | return $this->classReflection; |
88: | } |
89: | |
90: | public function getMethodReflection(): PhpMethodFromParserNodeReflection |
91: | { |
92: | return $this->methodReflection; |
93: | } |
94: | |
95: | |
96: | |
97: | |
98: | public function getStatements(): array |
99: | { |
100: | $stmts = $this->classMethod->getStmts(); |
101: | if ($stmts === null) { |
102: | return []; |
103: | } |
104: | |
105: | return $stmts; |
106: | } |
107: | |
108: | public function isGenerator(): bool |
109: | { |
110: | return count($this->yieldStatements) > 0; |
111: | } |
112: | |
113: | public function getType(): string |
114: | { |
115: | return 'PHPStan_Node_MethodReturnStatementsNode'; |
116: | } |
117: | |
118: | |
119: | |
120: | |
121: | public function getSubNodeNames(): array |
122: | { |
123: | return []; |
124: | } |
125: | |
126: | } |
127: | |