File tree 1 file changed +21
-1
lines changed
tests/PHPStan/Rules/Classes
1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 15
15
class ExistingClassInInstanceOfRuleTest extends RuleTestCase
16
16
{
17
17
18
+ private bool $ shouldNarrowMethodScopeFromConstructor = true ;
19
+
18
20
protected function getRule (): Rule
19
21
{
20
22
$ reflectionProvider = $ this ->createReflectionProvider ();
@@ -31,7 +33,7 @@ protected function getRule(): Rule
31
33
32
34
public function shouldNarrowMethodScopeFromConstructor (): bool
33
35
{
34
- return true ;
36
+ return $ this -> shouldNarrowMethodScopeFromConstructor ;
35
37
}
36
38
37
39
public function testClassDoesNotExist (): void
@@ -86,6 +88,24 @@ public function testBug7720(): void
86
88
]);
87
89
}
88
90
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
+
89
109
public function testRememberClassExistsFromConstructor (): void
90
110
{
91
111
$ this ->analyse ([__DIR__ . '/data/remember-class-exists-from-constructor.php ' ], []);
You can’t perform that action at this time.
0 commit comments