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

ArrayAccess mixed contravariant false positive #4854

Closed
soullivaneuh opened this issue Apr 14, 2021 · 4 comments
Closed

ArrayAccess mixed contravariant false positive #4854

soullivaneuh opened this issue Apr 14, 2021 · 4 comments
Labels
Milestone

Comments

@soullivaneuh
Copy link
Contributor

Bug report

I use @extends keyword on ArrayAccess to have a better type checking with PHPStan.

It looks to recognize it, but want the parameters to be contravariant with the native ArrayAccess native class methods.

However, if this not a bug, I don't see how this should be resolved. 🤔

Code snippet that reproduces the problem

https://phpstan.org/r/f3a9c0d9-96b4-4b97-8c00-d908147465c3

Expected output

No error?

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Apr 15, 2021
@sgc-fireball
Copy link

@ondrejmirtes
Copy link
Member

@sgc-fireball Yours is a completely different problem, please open a separate issue for that, thanks.

@phpstan-bot
Copy link
Contributor

@soullivaneuh After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-36: Parameter #1 $offset (int|null) of method App\Registrar\DomainsAvailability\AbstractDomainsAvailability::offsetSet() should be contravariant with parameter $offset (mixed) of method ArrayAccess<mixed,mixed>::offsetSet()
-36: Parameter #2 $value (int) of method App\Registrar\DomainsAvailability\AbstractDomainsAvailability::offsetSet() should be contravariant with parameter $value (mixed) of method ArrayAccess<mixed,mixed>::offsetSet()
-48: Parameter #1 $offset (int) of method App\Registrar\DomainsAvailability\AbstractDomainsAvailability::offsetExists() should be contravariant with parameter $offset (mixed) of method ArrayAccess<mixed,mixed>::offsetExists()
-56: Parameter #1 $offset (int) of method App\Registrar\DomainsAvailability\AbstractDomainsAvailability::offsetUnset() should be contravariant with parameter $offset (mixed) of method ArrayAccess<mixed,mixed>::offsetUnset()
-64: Parameter #1 $offset (int) of method App\Registrar\DomainsAvailability\AbstractDomainsAvailability::offsetGet() should be contravariant with parameter $offset (mixed) of method ArrayAccess<mixed,mixed>::offsetGet()
+No errors

@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 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants