1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Node;
4:
5: use PhpParser\Node\Expr;
6: use PHPStan\Analyser\Scope;
7: use PHPStan\Turbo\ReferencedByTurboExtension;
8:
9: /**
10: * A single non-default `case` of a `switch`, paired with the scope captured
11: * right after the case condition was processed (which already excludes the
12: * values matched by earlier terminating cases).
13: *
14: * @api
15: */
16: #[ReferencedByTurboExtension(key: 'switchConditionArm')]
17: final class SwitchConditionArm
18: {
19:
20: public function __construct(
21: private Expr $caseCondition,
22: private Scope $scope,
23: private int $line,
24: private bool $isLast,
25: )
26: {
27: }
28:
29: public function getCaseCondition(): Expr
30: {
31: return $this->caseCondition;
32: }
33:
34: public function getScope(): Scope
35: {
36: return $this->scope;
37: }
38:
39: public function getLine(): int
40: {
41: return $this->line;
42: }
43:
44: /**
45: * Whether this is the last non-default `case` of the `switch` (only a
46: * `default` may follow it), in which case an always-true comparison is fine
47: * because it does not make any subsequent `case` unreachable. A trailing
48: * `default` is not considered a `case` it would make unreachable.
49: */
50: public function isLast(): bool
51: {
52: return $this->isLast;
53: }
54:
55: }
56: