File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
tests/PHPStan/Rules/Classes Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 1515class ExistingClassInInstanceOfRuleTest extends RuleTestCase
1616{
1717
18+ private bool $ shouldNarrowMethodScopeFromConstructor = true ;
19+
1820 protected function getRule (): Rule
1921 {
2022 $ reflectionProvider = $ this ->createReflectionProvider ();
@@ -31,7 +33,7 @@ protected function getRule(): Rule
3133
3234 public function shouldNarrowMethodScopeFromConstructor (): bool
3335 {
34- return true ;
36+ return $ this -> shouldNarrowMethodScopeFromConstructor ;
3537 }
3638
3739 public function testClassDoesNotExist (): void
@@ -86,6 +88,24 @@ public function testBug7720(): void
8688 ]);
8789 }
8890
91+ public function testRememberClassExistsFromConstructorDisabled (): void
92+ {
93+ $ this ->shouldNarrowMethodScopeFromConstructor = false ;
94+
95+ $ this ->analyse ([__DIR__ . '/data/remember-class-exists-from-constructor.php ' ], [
96+ [
97+ 'Class SomeUnknownClass not found. ' ,
98+ 19 ,
99+ 'Learn more at https://phpstan.org/user-guide/discovering-symbols ' ,
100+ ],
101+ [
102+ 'Class SomeUnknownInterface not found. ' ,
103+ 38 ,
104+ 'Learn more at https://phpstan.org/user-guide/discovering-symbols ' ,
105+ ],
106+ ]);
107+ }
108+
89109 public function testRememberClassExistsFromConstructor (): void
90110 {
91111 $ this ->analyse ([__DIR__ . '/data/remember-class-exists-from-constructor.php ' ], []);
You can’t perform that action at this time.
0 commit comments