File tree Expand file tree Collapse file tree 3 files changed +51
-0
lines changed
tests/PHPStan/Rules/Properties Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -882,6 +882,20 @@ public function testBug13438e(): void
882
882
]);
883
883
}
884
884
885
+ public function testBug7880 (): void
886
+ {
887
+ $ this ->checkExplicitMixed = true ;
888
+ $ this ->analyse ([__DIR__ . '/data/bug-7880.php ' ], []);
889
+ }
890
+
891
+ #[RequiresPhp('>= 8.1 ' )]
892
+ public function testBug7880b (): void
893
+ {
894
+ $ this ->checkExplicitMixed = true ;
895
+ $ this ->checkImplicitMixed = true ;
896
+ $ this ->analyse ([__DIR__ . '/data/bug-7880b.php ' ], []);
897
+ }
898
+
885
899
public function testBug13438f (): void
886
900
{
887
901
$ this ->checkExplicitMixed = true ;
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Bug7880 ;
4
+
5
+ class C {
6
+ /** @var array{a: string, b: string}|null */
7
+ private $ a = null ;
8
+
9
+ public function foo (): void {
10
+ if ($ this ->a !== null ) {
11
+ $ this ->a ['b ' ] = "baz " ;
12
+ }
13
+ }
14
+ }
Original file line number Diff line number Diff line change
1
+ <?php // lint >= 8.1
2
+
3
+ namespace Bug7880b ;
4
+
5
+ enum Undefined: string
6
+ {
7
+ case VALUE = '!@#$~~UNDEFINED~~$#@! ' ;
8
+ }
9
+
10
+ class Test1 {}
11
+
12
+ class Test {
13
+ /**
14
+ * @var Undefined|array<Test1>
15
+ */
16
+ public array |Undefined $ property = Undefined::VALUE ;
17
+ }
18
+
19
+ function (): void {
20
+ $ a = new Test ();
21
+ $ a ->property = [];
22
+ $ a ->property [] = new Test1 ();
23
+ };
You can’t perform that action at this time.
0 commit comments