refactor: fix proxy system and introduce psalm extension#704
Conversation
e3a9d51 to
cff5ae5
Compare
yes, thanks to the change in composer.json |
7c764ab to
1576c3b
Compare
828aa05 to
c00bfaf
Compare
| abstract class Factory | ||
| { | ||
| /** @var Attributes[] */ | ||
| /** @phpstan-var Attributes[] */ |
There was a problem hiding this comment.
everytime we use phpstan pseudo types, we should use @phpstan- annotations because Psalm seems to not understand it
and moreover, see this comment from stof here, I think it is relevant
I'll make another PR where I fix all of the related docblocks
|
|
||
| $parameters = $this->normalizeParameters($parameters); | ||
| $instantiator = $this->instantiator ?? Configuration::instance()->instantiator; | ||
| /** @var T $object */ |
There was a problem hiding this comment.
it seems like PHPStorm does not only interprets methods signature (like PHPStan would do) but it events guesses stuff from the methods' body. I had really hard times to find but it basically fixes 90% of auto-complete problems 🎉
| public static function first(string $sortBy = 'id'): object | ||
| { | ||
| return static::repository()->firstOrFail($sortBy); | ||
| /** @var T $object */ |
There was a problem hiding this comment.
same, this is here to help auto-complete
fixes #701 #696
I've decided to completely remove all methods in
PersistenceProxyObjectFactory, so we do not override@finalmethods anymore. We still need to figure out a solution forPersistenceObjectFactory::create(), I'll do this in a further PR.Psalm does not understand the following:
it always consider the template to be
Userand notUser&Proxy<User>. I think because we're breaking covariance (T&Proxy<T>is wider thanT)I've finally decided to introduce a psalm extension, we will be able to fix nearly every typing problem in here.