File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
tests/PHPStan/Rules/Variables Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -492,4 +492,16 @@ public function testIssetAfterRememberedConstructor(): void
492
492
]);
493
493
}
494
494
495
+ public function testPr4374 (): void
496
+ {
497
+ $ this ->treatPhpDocTypesAsCertain = true ;
498
+
499
+ $ this ->analyse ([__DIR__ . '/data/pr-4374.php ' ], [
500
+ [
501
+ 'Offset string on array<PR4374\Foo> in isset() always exists and is not nullable. ' ,
502
+ 23 ,
503
+ ],
504
+ ]);
505
+ }
506
+
495
507
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace PR4374 ;
4
+
5
+ class Foo {}
6
+
7
+ final class AnnotationsMethodsClassReflectionExtension
8
+ {
9
+
10
+ /** @var Foo[][] */
11
+ private array $ methods = [];
12
+
13
+ public function hasMethod (string $ cacheKey , string $ methodName ): bool
14
+ {
15
+ if (!isset ($ this ->methods [$ cacheKey ][$ methodName ])) {
16
+ $ method = $ this ->findClassReflectionWithMethod ();
17
+ if ($ method === null ) {
18
+ return false ;
19
+ }
20
+ $ this ->methods [$ cacheKey ][$ methodName ] = $ method ;
21
+ }
22
+
23
+ return isset ($ this ->methods [$ cacheKey ][$ methodName ]);
24
+ }
25
+
26
+ private function findClassReflectionWithMethod (
27
+ ): ?Foo
28
+ {
29
+ if (rand (0 ,1 )) {
30
+ return new Foo ();
31
+ }
32
+ return null ;
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments