phpat icon indicating copy to clipboard operation
phpat copied to clipboard

Selectors based on Doctrine metadata

Open hkdobrev opened this issue 5 years ago • 0 comments

Enhancement description It would be really useful if you can point phpat to certain classes like entities, repositories etc. when using Doctrine or another data mapper. It's usually easy with active record ORM implementations as models would usually extend a base model class. However, Doctrine could have only configuration via XML, PHP or annotations considering specific classes as Doctrine entities.

Some use cases for that would be enforcing entities to not extend classes or implement certain interfaces, require some traits for timestamping etc.

Suggested approach or solution

At first, I was thinking these selectors would be based on PHPDoc annotations. There are many tools relying on annotations like PHPUnit and especially in the Symfony ecosystem like validators, routing and entities. So such selectors could still be useful.

However, Doctrine could have those configurations combined from annotations, XML, YAML and PHP configuration files. So it'd be better to use the Doctrine metadata specifically for more useful Doctrine selectors. Similar to https://github.com/phpstan/phpstan-doctrine phpat (or an extension) could load the Doctrine metadata from a provided entity manager or a configuration instance allowing for very quick and easy detection of which classes are considered entities by Doctrine.

hkdobrev avatar Mar 15 '20 12:03 hkdobrev