I'm trying out phpstan and psalm for php and I would like to write a class that can take different type of objects and return the right one based on the factory to call.
What I'm trying to achieve is that if I pass an object of type A to the Transformer, the compiler knows that a SuperA will be returned.
While I can go without errors in psalm (though I still get SuperA|SuperB instead of the right object), I got an error on what I'm passing in phpstan.
https://phpstan.org/r/4fce6f46-7aea-4f73-8259-df895910f064
https://psalm.dev/r/352e64ea95
Is there a way to do it?