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