Skip to content

Commit 41cf381

Browse files
phpstan-botclaude
andcommitted
Broaden write-only property check to all objects, not just ArrayAccess
Objects like Threaded support array operations without implementing ArrayAccess. Use isObject() instead of checking for ArrayAccess specifically, so that appending to any object property via array syntax is correctly treated as a read. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 579d38f commit 41cf381

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

src/Node/ClassStatementsGatherer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use PHPStan\Node\Property\PropertyWrite;
2121
use PHPStan\Reflection\ClassReflection;
2222
use PHPStan\ShouldNotHappenException;
23-
use PHPStan\Type\ObjectType;
2423
use PHPStan\Type\TypeUtils;
2524
use ReflectionProperty;
2625
use function count;
@@ -209,7 +208,7 @@ private function gatherNodes(Node $node, Scope $scope): void
209208
$propertyType = $scope->getType($propertyFetch);
210209
if (
211210
!$propertyType->isArray()->yes()
212-
&& (new ObjectType(\ArrayAccess::class))->isSuperTypeOf($propertyType)->yes()
211+
&& $propertyType->isObject()->yes()
213212
) {
214213
$this->propertyUsages[] = new PropertyRead($propertyFetch, $scope);
215214
}

0 commit comments

Comments
 (0)