Skip to content

Commit 3ee6c73

Browse files
committed
fix unset on stdClass
1 parent a53d242 commit 3ee6c73

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Rules/Variables/UnsetRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private function canBeUnset(Node $node, Scope $scope): ?IdentifierRuleError
8989
->build();
9090
}
9191

92-
if (!$classReflection->hasProperty($node->name->name)) {
92+
if (!$classReflection->hasNativeProperty($node->name->name)) {
9393
continue;
9494
}
9595

tests/PHPStan/Rules/Variables/data/bug-12421.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,9 @@ function doFoo() {
9393
$x = new PhpdocImmutableClass();
9494
unset($x->y);
9595
var_dump($x->y);
96+
97+
$x = new \stdClass();
98+
unset($x->y);
99+
96100
}
97101

0 commit comments

Comments
 (0)