refactor: fix proxy system and introduce psalm extension
this PR partially fixes the issue https://github.com/zenstruck/foundry/issues/696:
I've decided to completely remove all methods in PersistenceProxyObjectFactory, so we do not override @final methods anymore. We still need to figure out a solution for PersistenceObjectFactory::create(), I'll do this in a further PR.
fixes https://github.com/zenstruck/foundry/issues/701:
Psalm does not understand the following:
/**
* @extends PersistentProxyObjectFactory<User>
*/
class UserFactory extends PersistentProxyObjectFactory{}
/**
* @template T of object
* @extends PersistentObjectFactory<T&Proxy<T>>
*/
abstract class PersistentProxyObjectFactory extends PersistentObjectFactory{}
/**
* @template T of object
*/
abstract class PersistentObjectFactory{}
it always consider the template to be User and not User&Proxy<User>. I think because we're breaking covariance (T&Proxy<T> is wider than T)
I've finally decided to introduce a psalm extension, we will be able to fix nearly every typing problem in here.
I'm unfamiliar with psalm plugins, will this be auto-registered in projects using foundry and psalm?
yes, thanks to the change in composer.json