File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
tests/PHPStan/Rules/Comparison Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -179,4 +179,10 @@ public function testBug4864(): void
179179 $ this ->analyse ([__DIR__ . '/data/bug-4864.php ' ], []);
180180 }
181181
182+ public function testBug8926 (): void
183+ {
184+ $ this ->treatPhpDocTypesAsCertain = true ;
185+ $ this ->analyse ([__DIR__ . '/data/bug-8926.php ' ], []);
186+ }
187+
182188}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Bug8926 ;
4+
5+ class Foo {
6+ private bool $ test ;
7+
8+ /** @param int[] $arr */
9+ function success (array $ arr ) : void {
10+ $ test = false ;
11+ (function ($ arr ) use (&$ test ) {
12+ $ test = count ($ arr ) == 1 ;
13+ })($ arr );
14+
15+ if ($ test ) {
16+ echo "... \n" ;
17+ }
18+ }
19+
20+ /** @param int[] $arr */
21+ function error (array $ arr ) : void {
22+ $ this ->test = false ;
23+ (function ($ arr ) {
24+ $ this ->test = count ($ arr ) == 1 ;
25+ })($ arr );
26+
27+
28+ if ($ this ->test ) {
29+ echo "... \n" ;
30+ }
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments