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

Cannot unset offset 'Review' on array{User: mixed}. #8113

Closed
gemal opened this issue Oct 4, 2022 · 10 comments · Fixed by phpstan/phpstan-src#1987
Closed

Cannot unset offset 'Review' on array{User: mixed}. #8113

gemal opened this issue Oct 4, 2022 · 10 comments · Fixed by phpstan/phpstan-src#1987
Labels
Milestone

Comments

@gemal
Copy link

gemal commented Oct 4, 2022

https://phpstan.org/r/f6f1e028-bcfa-4914-8189-82afd1e99de4

this seems like a bug in the latest version 1.8.6

@ondrejmirtes
Copy link
Member

The type gets broken after the unset on line 37: https://phpstan.org/r/f3a3a3dd-3e92-4fb7-bddf-70e088850ed0

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Oct 5, 2022
@mk-wieland
Copy link

mk-wieland commented Oct 5, 2022

this seems like a bug in the latest version 1.8.6

The bug is only in 1.8.7 and above though, right? For me, it's working in 1.8.6.

@ahmedash95
Copy link

@ondrejmirtes could it be related to phpstan/phpstan-src#1791?

@ondrejmirtes
Copy link
Member

I don't think so, but you can always verify that by reproducing the bug and reverting your fix 😎

@gemal
Copy link
Author

gemal commented Oct 6, 2022

this seems like a bug in the latest version 1.8.6

The bug is only in 1.8.7 though, right? For me, it's working in 1.8.6.

I tested only in 1.8.7. But also present in 1.8.8

@paulijar
Copy link

paulijar commented Nov 6, 2022

Here is another similar but even simpler case: https://phpstan.org/r/0f640c5d-beb7-4c90-8b8b-142dd8ffebbc
Dectected on v1.9.1. Do you think this is the same bug or should it be reported separately?

@rvanvelzen
Copy link
Contributor

@paulijar your case is not exactly the same because offset c definitely doesn't exist and it's handled poorly: https://phpstan.org/r/99b671b2-06b7-429d-b1b5-12525bb045c1

@paulijar
Copy link

paulijar commented Nov 8, 2022

your case is not exactly the same because offset c definitely doesn't exist

True. However, in my real-life case the array was actually parsed from a file so PhpStan had no chance to know its full contents, and I still got the same error message. And the code should be totally correct regardless of if c exists or not. But it's possible that my example doesn't accurately reflect the same problem as I saw on my real source code.

@paulijar
Copy link

Indeed the issue with my real-life code got fixed by Phpstan 1.9.2. 👍

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants