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: /**
39: * @return ReturnStatement[]
40: */
41: public function getReturnStatements(): array
42: {
43: return $this->returnStatements;
44: }
45:
46: /**
47: * @return array<int, Yield_|YieldFrom>
48: */
49: public function getYieldStatements(): array
50: {
51: return $this->yieldStatements;
52: }
53:
54: public function getStatementResult(): StatementResult
55: {
56: return $this->statementResult;
57: }
58:
59: public function returnsByRef(): bool
60: {
61: return $this->closureExpr->byRef;
62: }
63:
64: public function getType(): string
65: {
66: return 'PHPStan_Node_ClosureReturnStatementsNode';
67: }
68:
69: /**
70: * @return string[]
71: */
72: public function getSubNodeNames(): array
73: {
74: return [];
75: }
76:
77: }
78: