File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed
tests/PHPStan/Rules/Comparison Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -503,4 +503,18 @@ public function testBug11852(): void
503
503
$ this ->analyse ([__DIR__ . '/data/bug-11852.php ' ], []);
504
504
}
505
505
506
+ public function testPropertyHooks (): void
507
+ {
508
+ if (PHP_VERSION_ID < 80400 ) {
509
+ $ this ->markTestSkipped ('Test requires PHP 8.4. ' );
510
+ }
511
+
512
+ $ this ->analyse ([__DIR__ . '/data/match-expr-property-hooks.php ' ], [
513
+ [
514
+ 'Match expression does not handle remaining value: 3 ' ,
515
+ 13 ,
516
+ ],
517
+ ]);
518
+ }
519
+
506
520
}
Original file line number Diff line number Diff line change
1
+ <?php // lint >= 8.4
2
+
3
+ namespace MatchExprPropertyHooks ;
4
+
5
+ use UnhandledMatchError ;
6
+
7
+ class Foo
8
+ {
9
+
10
+ /** @var 1|2|3 */
11
+ public int $ i {
12
+ get {
13
+ return match ($ this ->i ) {
14
+ 1 => 'foo ' ,
15
+ 2 => 'bar ' ,
16
+ };
17
+ }
18
+ }
19
+
20
+ /**
21
+ * @var 1|2|3
22
+ */
23
+ public int $ j {
24
+ /** @throws UnhandledMatchError */
25
+ get {
26
+ return match ($ this ->j ) {
27
+ 1 => 10 ,
28
+ 2 => 20 ,
29
+ };
30
+ }
31
+ }
32
+
33
+ }
You can’t perform that action at this time.
0 commit comments