Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong assignation to intersection including ArrayAccess not being reported #843

Closed
wants to merge 1 commit into from

Conversation

julienfalque
Copy link

Ref.: phpstan/phpstan#6184

In OffsetAccessValueAssignmentRule.php

$resultType = $arrayType->setOffsetValueType(new MixedType(), $assignedValueType);

The error is reported when $resultType is an instance of ErrorType.

In the case that works, $arrayType is a GenericObjectType and calling setOffsetValueType() on it returns an ErrorType, so the issue is reported correctly.

But in the failing case, $arrayType is an IntersectionType containing the GenericObjectType. When calling setOffsetValueType(), it will internally forward the call to the inner types, pass the results (including the ErrorType) to TypeCombinator::intersect() that returns a new IntersectionType (without ErrorType), so the issue is not reported.

I don't know the codebase very well and couldn't figure out a proper fix yet. Can someone help me please?

@julienfalque
Copy link
Author

Issue is fixed.

@julienfalque julienfalque deleted the fix-6184 branch January 13, 2022 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant