// we found a alias but not a repository name, so try a scope search if we are inside repository class
// class implements \Doctrine\Common\Persistence\ObjectRepository, so search for model name of "repositoryClass"
if(rootAlias != null && repository == null) {
MethodReference methodReference = methodReferences.iterator().next();
PhpClass phpClass = PsiTreeUtil.getParentOfType(methodReference, PhpClass.class);
if(new Symfony2InterfacesUtil().isInstanceOf(phpClass, "\\Doctrine\\Common\\Persistence\\ObjectRepository")) {
for(DoctrineModel model: EntityHelper.getModelClasses(project)) {
String className = model.getPhpClass().getPresentableFQN();
if(className != null) {
PhpClass resolvedRepoName = EntityHelper.getEntityRepositoryClass(project, className);
if(PhpElementsUtil.isEqualClassName(resolvedRepoName, phpClass.getPresentableFQN())) {