[Generics] Wrong type resolving #10330
-
Hello, this seems like a bug to me, but I prefer to ask it here before opening an issue. I don't even know what to search for in order to find similar issue 🤷 Shouldn't the last https://phpstan.org/r/4c10c542-ae06-444a-b298-8d4b4ca7dd08 thanks for your answer! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
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 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?assignees=&labels=&projects=&template=Bug_report.yaml), but you'll need a workaround meanwhile anyway :) |
Beta Was this translation helpful? Give feedback.
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 beProxy
and from$object->object()
it's not obvious what happens when$object
isT&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…