Skip to content

[TypeDeclaration] Skip property fetch on array dim fetch in StrictArrayParamDimFetchRector#8140

Merged
TomasVotruba merged 1 commit into
mainfrom
fix-strict-array-param-property-fetch
Jul 3, 2026
Merged

[TypeDeclaration] Skip property fetch on array dim fetch in StrictArrayParamDimFetchRector#8140
TomasVotruba merged 1 commit into
mainfrom
fix-strict-array-param-property-fetch

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Fix false positive: property fetch on $param[0]->$key means the param holds an object, not an array itself, so no array type should be added.

/**
 * @param object $object
 */
private function getDataForObject($object): mixed
{
    foreach ($object as $key => $value) {
        if (0 === $key) {
            continue;
        }

        $object[0]->$key = $value;
    }

    return $object[0];
}

Guard added in shouldStop(): stops when a PropertyFetch/StaticPropertyFetch targets $param[...].

@TomasVotruba TomasVotruba merged commit 62e4045 into main Jul 3, 2026
65 checks passed
@TomasVotruba TomasVotruba deleted the fix-strict-array-param-property-fetch branch July 3, 2026 12:47
@TomasVotruba

Copy link
Copy Markdown
Member Author

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant