Skip to content

Conversation

@rajyan
Copy link
Contributor

@rajyan rajyan commented Mar 6, 2022

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this instead?

!(new ObjectType(\ArrayAccess))->isSuperTypeOf($scope->getType($stmt->expr)-)->no()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will make it not report a false positive for example array|null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I'll look into it.

@rajyan rajyan requested a review from ondrejmirtes March 6, 2022 08:12
@ondrejmirtes
Copy link
Member

Sorry, I used a wrong type in the review and fixed it myself :) 83e4284 (ArrayAccess has nothing to do with iteration).

Thank you.

@ondrejmirtes ondrejmirtes merged commit d32942a into phpstan:master Mar 6, 2022
@rajyan
Copy link
Contributor Author

rajyan commented Mar 6, 2022

@ondrejmirtes

ArrayAccess has nothing to do with iteration

Oh, you are right. Sorry that I couldn't notice it. I’m wondering why did the tests passed in local.

@ondrejmirtes
Copy link
Member

Because these objects might implement ArrayAccess in a subclass :) (They're not final.) So the assumption an exception might be thrown is still correct.

@rajyan
Copy link
Contributor Author

rajyan commented Mar 6, 2022

I see. Thank you for clarifying.

@rajyan rajyan deleted the fix/issue-5903 branch March 6, 2022 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False Positive: Dead Catch for exceptions thrown from \Traversable or \Iterator traversing

2 participants