Skip to content

Commit

Permalink
fix unset on stdClass
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Feb 15, 2025
1 parent a53d242 commit 3ee6c73
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Rules/Variables/UnsetRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private function canBeUnset(Node $node, Scope $scope): ?IdentifierRuleError
->build();
}

if (!$classReflection->hasProperty($node->name->name)) {
if (!$classReflection->hasNativeProperty($node->name->name)) {
continue;
}

Expand Down
4 changes: 4 additions & 0 deletions tests/PHPStan/Rules/Variables/data/bug-12421.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,9 @@ function doFoo() {
$x = new PhpdocImmutableClass();
unset($x->y);
var_dump($x->y);

$x = new \stdClass();
unset($x->y);

}

0 comments on commit 3ee6c73

Please sign in to comment.