Skip to content

Commit 31eb5d6

Browse files
committed
Yennefer of Vengerberg ;)
1 parent c4c7b8c commit 31eb5d6

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/Rules/Variables/UnsetRule.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,12 @@ private function canBeUnset(Node $node, Scope $scope): ?IdentifierRuleError
9191
}
9292

9393
if ($propertyReflection->isReadOnly() || $propertyReflection->isReadOnlyByPhpDoc()) {
94-
$type = $scope->getType($node->var);
95-
9694
return RuleErrorBuilder::message(
9795
sprintf(
98-
'Cannot unset %s property %s of %s.',
96+
'Cannot unset %s %s::$%s property.',
9997
$propertyReflection->isReadOnly() ? 'readonly' : '@readonly',
100-
$node->name->name,
101-
$type->describe(VerbosityLevel::value()),
98+
$propertyReflection->getDeclaringClass()->getDisplayName(),
99+
$foundPropertyReflection->getName()
102100
),
103101
)
104102
->line($node->getStartLine())

tests/PHPStan/Rules/Variables/UnsetRuleTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,27 +96,27 @@ public function testBug12421(): void
9696
{
9797
$this->analyse([__DIR__ . '/data/bug-12421.php'], [
9898
[
99-
'Cannot unset readonly property y of Bug12421\NativeReadonlyClass.',
99+
'Cannot unset readonly Bug12421\NativeReadonlyClass::$y property.',
100100
11,
101101
],
102102
[
103-
'Cannot unset readonly property y of Bug12421\NativeReadonlyProperty.',
103+
'Cannot unset readonly Bug12421\NativeReadonlyProperty::$y property.',
104104
15,
105105
],
106106
[
107-
'Cannot unset @readonly property y of Bug12421\PhpdocReadonlyClass.',
107+
'Cannot unset @readonly Bug12421\PhpdocReadonlyClass::$y property.',
108108
19,
109109
],
110110
[
111-
'Cannot unset @readonly property y of Bug12421\PhpdocReadonlyProperty.',
111+
'Cannot unset @readonly Bug12421\PhpdocReadonlyProperty::$y property.',
112112
23,
113113
],
114114
[
115-
'Cannot unset @readonly property y of Bug12421\PhpdocImmutableClass.',
115+
'Cannot unset @readonly Bug12421\PhpdocImmutableClass::$y property.',
116116
27,
117117
],
118118
[
119-
'Cannot unset readonly property y of Bug12421\NativeReadonlyPropertySubClass.',
119+
'Cannot unset readonly Bug12421\NativeReadonlyProperty::$y property.',
120120
34,
121121
],
122122
]);

0 commit comments

Comments
 (0)