Open marien-probesys opened 3 weeks ago
Hi @marien-probesys
which Foundry's (and PHPStan) version are you using? I've recently added specific phpdoc for this case
Hi @nikophil, thanks for your answer. I'm using PHPStan 1.12.11 (the latest version of v1) and Foundry 2.2.2.
I'm sorry I made a mistake in my explanations: the problem is not with the instantiateWith()
method directly, but with its callable parameter $instantiator
. It is its return type which is wrong! (so the InstantiatorCallable
type defined at the top of the file)
If you need it, I can create a minimal project tomorrow in order to reproduce the problem.
I've created a repository to reproduce the problem: https://github.com/marien-probesys/foundry-721
You can see the error here: https://github.com/marien-probesys/foundry-721/actions/runs/11915667680/job/33206464561
And the factory: https://github.com/marien-probesys/foundry-721/blob/main/src/Factory/PostFactory.php
thanks for your reproducer! I'll soon check this
Hi,
I use PHPStan to verify the typing in my application. I have an issue when using the
instantiateWith()
method in aPersistentProxyObjectFactory
factory.instantiateWith()
is declared in theObjectFactory
and must return an object of the template classT
. However, when inheriting from thePersistentProxyObjectFactory
class,T
becomesT&Proxy<T>
. Meaning that PHPStan expectsinstantiateWith()
to return aT&Proxy<T>
object.