Skip to content

Commit 446cebc

Browse files
committed
More tests
1 parent 53d44e6 commit 446cebc

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Diff for: tests/PHPStan/Rules/Constants/ConstantRuleTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ public function testRememberedConstructorScope(): void
9898
51,
9999
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
100100
],
101+
[
102+
'Constant REMEMBERED_FOO not found.',
103+
65,
104+
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
105+
],
101106
]);
102107
}
103108

Diff for: tests/PHPStan/Rules/Constants/data/remembered-constructor-scope.php

+16
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,19 @@ public function myFoo(): string
5151
return REMEMBERED_FOO; // should error, because this file cannot share the __constructor() scope with HelloWorld-class above.
5252
}
5353
}
54+
55+
class AnotherClassWithOwnConstructor {
56+
public function __construct()
57+
{
58+
if (!defined('ANOTHER_REMEMBERED_FOO')) {
59+
throw new LogicException();
60+
}
61+
}
62+
63+
public function myFoo(): void
64+
{
65+
echo REMEMBERED_FOO; // should error, because this file cannot share the __constructor() scope with HelloWorld-class above.
66+
67+
echo ANOTHER_REMEMBERED_FOO;
68+
}
69+
}

0 commit comments

Comments
 (0)