Skip to content

Commit fa5599e

Browse files
committed
test narrowMethodScopeFromConstructor can be disabled
1 parent 01aee6d commit fa5599e

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

Diff for: tests/PHPStan/Rules/Classes/ExistingClassInInstanceOfRuleTest.php

+21-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
class 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'], []);

0 commit comments

Comments
 (0)