zenstruck / foundry

A model factory library for creating expressive, auto-completable, on-demand dev/test fixtures with Symfony and Doctrine.
https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html
MIT License
609 stars 63 forks source link

refactor: change phpstan FactoryCollection return type #530

Closed nikophil closed 6 months ago

nikophil commented 7 months ago

I think this is a better type system around FactoryCollection

the only problem of this solution is that in userland, for factory collections created from PersistentProxyObjectFactory, phpstan requires that you type it this way: FactoryCollection<Proxy<SomeObject>>

but without this update, all objects created with PersistentProxyObjectFactory::createMany() (or createSequence()) is considered as NOT a proxy. ie: I had plenty of errors like this:

Call to an undefined method App\Domain\Programming|Zenstruck\Foundry\Persistence\Proxy<App\Domain\Programming>::object()

The PHPStan errors I added to the baseline are still internal to Foundry, and can be added safely