1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Node;
4:
5: use PhpParser\Node\Stmt\ClassMethod;
6: use PhpParser\NodeAbstract;
7: use PHPStan\Analyser\StatementResult;
8:
9: /** @api */
10: class MethodReturnStatementsNode extends NodeAbstract implements ReturnStatementsNode
11: {
12:
13: private ClassMethod $classMethod;
14:
15: /**
16: * @param ReturnStatement[] $returnStatements
17: * @param ExecutionEndNode[] $executionEnds
18: */
19: public function __construct(
20: ClassMethod $method,
21: private array $returnStatements,
22: private StatementResult $statementResult,
23: private array $executionEnds,
24: )
25: {
26: parent::__construct($method->getAttributes());
27: $this->classMethod = $method;
28: }
29:
30: /**
31: * @return ReturnStatement[]
32: */
33: public function getReturnStatements(): array
34: {
35: return $this->returnStatements;
36: }
37:
38: public function getStatementResult(): StatementResult
39: {
40: return $this->statementResult;
41: }
42:
43: /**
44: * @return ExecutionEndNode[]
45: */
46: public function getExecutionEnds(): array
47: {
48: return $this->executionEnds;
49: }
50:
51: public function returnsByRef(): bool
52: {
53: return $this->classMethod->byRef;
54: }
55:
56: public function hasNativeReturnTypehint(): bool
57: {
58: return $this->classMethod->returnType !== null;
59: }
60:
61: public function getType(): string
62: {
63: return 'PHPStan_Node_MethodReturnStatementsNode';
64: }
65:
66: /**
67: * @return string[]
68: */
69: public function getSubNodeNames(): array
70: {
71: return [];
72: }
73:
74: }
75: