Skip to content

Commit 0b1bcb9

Browse files
committed
better message
1 parent 8138e93 commit 0b1bcb9

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/Rules/Classes/ClassAttributesRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function processNode(Node $node, Scope $scope): array
4141
$classReflection = $scope->getClassReflection();
4242
if ($classReflection !== null && $classReflection->isReadOnly()) {
4343
if (count($classReflection->getNativeReflection()->getAttributes('AllowDynamicProperties')) > 0) {
44-
$errors[] = RuleErrorBuilder::message(sprintf('Cannot apply #[AllowDynamicProperties] to readonly class %s.', $classReflection->getName()))
44+
$errors[] = RuleErrorBuilder::message(sprintf('Attribute class AllowDynamicProperties cannot be used with readonly classes.', $classReflection->getName()))
4545
->identifier('class.allowDynamicPropertiesReadonly')
4646
->build();
4747
}

tests/PHPStan/Rules/Classes/ClassAttributesRuleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public function testBug12281(): void
178178
$this->checkImplicitMixed = true;
179179
$this->analyse([__DIR__ . '/data/bug-12281.php'], [
180180
[
181-
'Cannot apply #[AllowDynamicProperties] to readonly class Bug12281\BlogData.',
181+
'Attribute class AllowDynamicProperties cannot be used with readonly classes.',
182182
05,
183183
],
184184
]);

tests/PHPStan/Rules/Classes/data/bug-12281.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,12 @@
88
/** @readonly */
99
#[\AllowDynamicProperties]
1010
class BlogDataPhpdoc { /* … */ }
11+
12+
#[\AllowDynamicProperties]
13+
enum BlogDataEnum { /* … */ }
14+
15+
#[\AllowDynamicProperties]
16+
interface BlogDataInterface { /* … */ }
17+
18+
#[\AllowDynamicProperties]
19+
trait BlogDataTrait { /* … */ }

0 commit comments

Comments
 (0)