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