Skip to content

[Generics] Wrong type resolving #10330

Closed Answered by ondrejmirtes
nikophil asked this question in Support
Discussion options

You must be logged in to vote

You can see what's happening if you put more dumps in there: https://phpstan.org/r/f3d526bb-e53d-4513-b4d2-dffd3b67784b

The thing is that PHPStan think that from T|Proxy<T> both sides can be Proxy and from $object->object() it's not obvious what happens when $object is T&Proxy. I see how it could be improved, but also what sometimes happen is that it breaks someone else's crazy use-case :)

The best way forward for you is to have two different functions - one that accepts only proxies, and another one that only accepts final objects. That way the signatures of both of them are going to be straightforward.

Another option is to open a bug report (https://github.com/phpstan/phpstan/issues/new…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@nikophil
Comment options

@nikophil
Comment options

Answer selected by nikophil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Support
Labels
None yet
2 participants