Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix for ArrayAccess
  • Loading branch information
ondrejmirtes committed Mar 20, 2025
commit a4bf7cdc88fd6fc4032f83d5db2bafb4ca8fc735
28 changes: 22 additions & 6 deletions src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -5344,9 +5344,17 @@ private function processAssignVar(
$originalVar = $var;
$assignedPropertyExpr = $assignedExpr;
while ($var instanceof ArrayDimFetch) {
$varForSetOffsetValue = $var->var;
if ($varForSetOffsetValue instanceof PropertyFetch || $varForSetOffsetValue instanceof StaticPropertyFetch) {
$varForSetOffsetValue = new OriginalPropertyTypeExpr($varForSetOffsetValue);
if (
$var->var instanceof PropertyFetch
|| $var->var instanceof StaticPropertyFetch
) {
if (((new ObjectType(ArrayAccess::class))->isSuperTypeOf($scope->getType($var->var))->yes())) {
$varForSetOffsetValue = $var->var;
} else {
$varForSetOffsetValue = new OriginalPropertyTypeExpr($var->var);
}
} else {
$varForSetOffsetValue = $var->var;
}
$assignedPropertyExpr = new SetOffsetValueTypeExpr(
$varForSetOffsetValue,
Expand Down Expand Up @@ -5682,9 +5690,17 @@ static function (): void {
$dimFetchStack = [];
$assignedPropertyExpr = $assignedExpr;
while ($var instanceof ExistingArrayDimFetch) {
$varForSetOffsetValue = $var->getVar();
if ($varForSetOffsetValue instanceof PropertyFetch || $varForSetOffsetValue instanceof StaticPropertyFetch) {
$varForSetOffsetValue = new OriginalPropertyTypeExpr($varForSetOffsetValue);
if (
$var->getVar() instanceof PropertyFetch
|| $var->getVar() instanceof StaticPropertyFetch
) {
if (((new ObjectType(ArrayAccess::class))->isSuperTypeOf($scope->getType($var->getVar()))->yes())) {
$varForSetOffsetValue = $var->getVar();
} else {
$varForSetOffsetValue = new OriginalPropertyTypeExpr($var->getVar());
}
} else {
$varForSetOffsetValue = $var->getVar();
}
$assignedPropertyExpr = new SetExistingOffsetValueTypeExpr(
$varForSetOffsetValue,
Expand Down