thanks for the link @mad-briller, I will check out the talk later today. Always happy to learn more about PHPStan!
That said, the error is confusing, and I still don't see how my example is problematic. It saying the function should return TypeObject of AbstractA|AbstractB and it is literally returning TypeObject, which the generic defines as TypeObject of AbstractA|AbstractB.
But, maybe the talk will enlighten me or give me an idea of how to solve this.
sorry @arderyp i misunderstood the error mesage myself,
i thought it was stating that because the method is generic over a single class, but has the possibility to return either AbstractA or AbstractB, phpstan was getting confused by that
but judging by the fix provided by @rvanvelzen i was wrong :D