File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
tests/PHPStan/Rules/Variables Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -1389,6 +1389,10 @@ public function testBug14117(): void
13891389 'Variable $value might not be defined. ' ,
13901390 49 ,
13911391 ],
1392+ [
1393+ 'Undefined variable: $value ' ,
1394+ 65
1395+ ]
13921396 ]);
13931397 }
13941398
Original file line number Diff line number Diff line change @@ -46,6 +46,22 @@ function baz(): void {
4646 }
4747
4848 if ($ key === 3 ) {
49- echo $ value ; // this one SHOULD report "might not be defined" because $key === 3 doesn't guarantee either earlier block ran
49+ echo $ value ; // SHOULD report "is not defined"
50+ }
51+ }
52+
53+ function boo (): void {
54+ $ key = rand (0 , 2 );
55+
56+ if ($ key === 1 ) {
57+ $ value = 'test ' ;
58+ }
59+
60+ if ($ key === 1 ) {
61+ unset($ value );
62+ }
63+
64+ if ($ key === 1 ) {
65+ echo $ value ;
5066 }
5167}
You can’t perform that action at this time.
0 commit comments