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