1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Node;
4:
5: use Override;
6: use PhpParser\Node\Expr;
7: use PhpParser\Node\Stmt\Switch_;
8: use PhpParser\NodeAbstract;
9: use PHPStan\Turbo\ReferencedByTurboExtension;
10:
11: /**
12: * Virtual node emitted once per `switch` statement. It pairs the switch subject
13: * with each non-default `case` condition so rules can inspect the loose `==`
14: * comparison the `switch` performs, using the scope captured at each case
15: * (which already excludes the values matched by earlier cases).
16: *
17: * @api
18: */
19: #[ReferencedByTurboExtension(key: 'switchConditionNode')]
20: final class SwitchConditionNode extends NodeAbstract implements VirtualNode
21: {
22:
23: /**
24: * @param SwitchConditionArm[] $arms
25: */
26: public function __construct(
27: private Expr $subject,
28: private array $arms,
29: Switch_ $originalNode,
30: )
31: {
32: parent::__construct($originalNode->getAttributes());
33: }
34:
35: public function getSubject(): Expr
36: {
37: return $this->subject;
38: }
39:
40: /**
41: * @return SwitchConditionArm[]
42: */
43: public function getArms(): array
44: {
45: return $this->arms;
46: }
47:
48: #[Override]
49: public function getType(): string
50: {
51: return 'PHPStan_Node_SwitchCondition';
52: }
53:
54: /**
55: * @return string[]
56: */
57: #[Override]
58: public function getSubNodeNames(): array
59: {
60: return [];
61: }
62:
63: }
64: