-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsing of entity annotations/attributes to determine repository class #98
Comments
Doesn't Doctrine compile those annotations to some machine-readable readable format? I guess it would be easier to work with that (with automatic recompilation, if necessary) instead of replicating the parsing / interpretation of annotations. |
I had this idea when I started this plugin, but I stopped being a Doctrine user before I got to that. |
It does when the metadata cache is activated (which is usually not the case in dev environments). |
If there's a standard way to invoke it the plugin could do that at startup. |
Well, I think we can use the doctrine code to generate metadata for a single file but I am unsure if that works for any edge-case. I wonder if going with |
If you're using Doctrine attributes on your entities this gives you the repo class based on the entity: $reflection = new ReflectionClass($entityClass);
$attribute = $reflection->getAttributes(Entity::class);
$repositoryClass = $attribute[0]->getArguments()['repositoryClass']; If anyone is more familiar with Psalm plugin dev maybe they could update this https://github.com/runtothefather/doctrine-psalm-plugin to use this method too? |
Currently looking at this to work on vimeo/psalm#10896 My rough approach (not yet gotten anything concrete yet) is to do something like: final class MarkEntityFieldsAsTaintSources implements AfterExpressionAnalysisInterface
{
public static function afterExpressionAnalysis(AfterExpressionAnalysisEvent $event): ?bool
{
$propertyFetchCandidate = $event->getExpr();
if (! $propertyFetchCandidate instanceof PropertyFetch) {
return null;
}
$statementsSource = $event->getStatementsSource();
$typeProvider = $statementsSource->getNodeTypeProvider();
$entityType = $typeProvider->getType($propertyFetchCandidate->var);
if (null === $entityType) {
return null;
}
// extract atomic type from entity manager here
$entityType->getAtomicTypes() // @TODO |
Hey there,
I have entities which have own repository implementations.
These implementations are referred to with the
Entity
Attribute/Annotation (usingrepositoryClass
option).This plugin only provides generic support as of now.
Are you interested in having this feature part of this plugin?
I think I might find some time somewhen in the near future to implement that.
Happy to get feedback on this.
The text was updated successfully, but these errors were encountered: