persistence icon indicating copy to clipboard operation
persistence copied to clipboard

Add support for generics via static analysis

Open alcaeus opened this issue 5 years ago • 7 comments

As was done in doctrine/collections, we should add support for generics using the @psalm-template annotations for generic classes like Repositories and Registries. We should also ensure that generics in PHPStan are supported as well.

See https://github.com/doctrine/collections/pull/177 for the reference implementation in collections.

alcaeus avatar Dec 06 '19 20:12 alcaeus

https://github.com/weirdan/doctrine-psalm-plugin was brought to my attention today. @weirdan would you be open to contributing the annotations to our libraries directly? We've added them to doctrine/collections, but I'd love to see these in all other projects as well.

alcaeus avatar Dec 19 '19 14:12 alcaeus

But of course! What do I need to do to make that happen?

We should also ensure that generics in PHPStan are supported as well.

For the record, PHPStan reads some @psalm- annotations (including @template) and Psalm may soon start to read @phpstan--prefixed ones.

weirdan avatar Dec 19 '19 22:12 weirdan

A pull request to master is a great start. If you want we can discuss this tomorrow in the symfony-devs or doctrine Slack 👍

alcaeus avatar Dec 19 '19 22:12 alcaeus

Unfortunately I won't have time for this before Sunday, so definitely not going to happen tomorrow.

weirdan avatar Dec 19 '19 23:12 weirdan

No worries at all. I'll be off for most of the next two weeks, so please take some time to enjoy the holidays. No need to rush anything here.

alcaeus avatar Dec 20 '19 09:12 alcaeus

I am also up for help if needed! Nice to see it get to other Doctrine projects as well.

nschoellhorn avatar Dec 28 '19 20:12 nschoellhorn

@weirdan @nschoellhorn working with you on annotations was great! Would love to do this again for all persistence libraries. Right @ocramius?

alcaeus avatar Dec 29 '19 23:12 alcaeus