-
-
Notifications
You must be signed in to change notification settings - Fork 92
[PHPStan] improve FactoryCollection
generics annotation with template-type
#894
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
Comments
fixed 😄 https://phpstan.org/r/441da82d-53cc-40ee-8b4e-4ff82b7988b6 - @param FactoryCollection<Something, SomethingFactory> $somethingFactories
+ @param FactoryCollection<Something&Proxy<Something>, SomethingFactory> $somethingFactories those By the way, the only use case to type hint with |
Thank you ❤️ The use case for type hints is with data providers. |
I've might have just found a way to simplify this - you can interpret the type from TFactory, example taken from here phpstan/phpstan#9053 https://phpstan.org/r/7a4e6c92-1d39-4470-860f-890d47aee32c What do you think? |
this is very cool! I didn't even know one thing I'd like, is that the current way of documenting factories still works. We've already introduced a BC break around this few months ago, and I would not want to introduce another one now... do you think both fashions of documenting |
I don't think so, best I can come up right now is to just leave the signature as is and ignore the Tried a few ideas using Template default types from phpstan/phpstan#4801 but couldn't get any to work for both one and two template types specified. The hurdle here seems to be that the |
ok then, I'm sorry, but we're not going to integrate this now in Foundry BUT this could be integrated to Foundry 3, that might land at the end of the year (as for Symfony 8.0) BTW, there's some chances that we offer a rector set to migrate to Foundry 3, the same way we did for migration from 1 to 2 |
@edglev I'll keep this open 👍 if at some point, you're willing to provide a PR with the changes with |
FactoryCollection
generics annotation with template-type
Ah, sorry for closing this :D Sure, I'll make a PR sometime later |
Looks like there is an issue with phpstan type definition, specifically
&Proxy<T>
part breaking extension chain resolving toFactory<T>
.I don't understand why
T&Proxy<T>
is a not a subtype ofobject
.Is this a problem in PhpStan itself?
Minimal reproducer https://phpstan.org/r/eece4718-641c-4e5b-bac9-e4f1430f8fda
Just as a test - removing
&Proxy<T>
part from PersistentProxyObjectFactory makes PhpStan happy.https://phpstan.org/r/dc467615-ce04-4f6c-8370-b6be346ec8c0
The text was updated successfully, but these errors were encountered: