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