File tree Expand file tree Collapse file tree 4 files changed +34
-0
lines changed
tests/PHPStan/Rules/TooWideTypehints Expand file tree Collapse file tree 4 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 170170 'DateTimeImmutable::getTimestamp ' => ['hasSideEffects ' => false ],
171171 'DateTimeImmutable::getTimezone ' => ['hasSideEffects ' => false ],
172172
173+ // affects isConnected()
174+ 'Redis::connect ' => ['hasSideEffects ' => true ],
175+ 'Redis::pconnect ' => ['hasSideEffects ' => true ],
176+
173177 'SplDoublyLinkedList::pop ' => ['hasSideEffects ' => true ],
174178 'SplDoublyLinkedList::shift ' => ['hasSideEffects ' => true ],
175179
Original file line number Diff line number Diff line change 452452 'NumberFormatter::getPattern ' => ['hasSideEffects ' => false ],
453453 'NumberFormatter::getSymbol ' => ['hasSideEffects ' => false ],
454454 'NumberFormatter::getTextAttribute ' => ['hasSideEffects ' => false ],
455+ 'Redis::connect ' => ['hasSideEffects ' => true ],
456+ 'Redis::pconnect ' => ['hasSideEffects ' => true ],
455457 'ReflectionAttribute::getArguments ' => ['hasSideEffects ' => false ],
456458 'ReflectionAttribute::getName ' => ['hasSideEffects ' => false ],
457459 'ReflectionAttribute::getTarget ' => ['hasSideEffects ' => false ],
Original file line number Diff line number Diff line change @@ -106,4 +106,10 @@ public function testBug13384bOff(): void
106106 $ this ->analyse ([__DIR__ . '/data/bug-13384b.php ' ], []);
107107 }
108108
109+ public function testBugPR4318 ()
110+ {
111+ $ this ->reportTooWideBool = true ;
112+ $ this ->analyse ([__DIR__ . '/data/bug-pr-4318.php ' ], []);
113+ }
114+
109115}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace BugPR4318 ;
4+
5+ class Client
6+ {
7+ private bool $ isConnected = false ;
8+
9+ public function connect (): void
10+ {
11+ $ driver = new \Redis ();
12+
13+ if ($ driver ->isConnected ()) {
14+ return ;
15+ }
16+
17+ $ driver ->connect ('' );
18+ $ this ->isConnected = $ driver ->isConnected ();
19+ echo $ this ->isConnected ;
20+ }
21+
22+ }
You can’t perform that action at this time.
0 commit comments