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

Template type gets lost when using key-of and extending ArrayAccess #7652

Closed
ondrejmirtes opened this issue Jul 18, 2022 · 4 comments · Fixed by phpstan/phpstan-src#1523
Closed
Labels
Milestone

Comments

@ondrejmirtes
Copy link
Member

Bug report

https://phpstan.org/r/2fb146c6-12dc-4a17-bb28-e13d93e820ea

/cc @rvanvelzen From the error messages:

 Parameter #1 $offset (key-of<TArray of array>) of method Options::offsetExists() should be contravariant with parameter $offset (key-of<array>) of method ArrayAccess<key-of<TArray of array>,value-of<TArray of array>>::offsetExists()

It looks like the generic-ness gets lost ($offset (key-of<array>)).

I don't think the example should report these messages. Could you please look into it?

This PR depends on the code to pass :) phpstan/phpstan-symfony#294

Thanks.

@alexander-schranz
Copy link

I'm not sure if related but it looks like I have a problem when accessing ArrayAccess with another array structure in it: https://phpstan.org/r/4901b911-ddd4-449a-a417-2a1ec41badaa

@rvanvelzen
Copy link
Contributor

That is unrelated - anonymous functions don't support docblocks.

@alexander-schranz
Copy link

@rvanvelzen okay interesting thought then it would also report allow_delete but seems like it doesn't. Do you know if there exist any issue about that?

@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 Aug 20, 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.

3 participants