Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow custom getRepository()-like methods#1276

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
theredled wants to merge4 commits intoHaehnchen:master
base:master
Choose a base branch
Loading
fromtheredled:getrepository-update

Conversation

@theredled
Copy link

@theredledtheredled commentedJan 20, 2019
edited
Loading

getRepository() currently only support direct calls toManagerRegistry::getRepository orObjectManager::getRepository.
This PR supports other methods - typically shortcuts in Controllers - as soon as they useObjectRepository or a child class as a PHP code return type.

Note : seems hard to support PHPDoc.

Example :

Class MyClass {  public function getRepo($class): ObjectRepository {}}$c = new MyClass();$c->getRepo(MyEntity::class)-> // Gives access to MyEntity repository methods

@theredledtheredled changed the titleAllow custom getRepository() methodsAllow custom getRepository()-like methodsJan 20, 2019
@theredled
Copy link
Author

theredled commentedJan 20, 2019
edited
Loading

I'm only wondering about that part inObjectRepositoryTypeProvider :

public PhpType getType(PsiElement e) {// ...        if(!(e instanceof MethodReference)                /*|| !PhpElementsUtil.isMethodWithFirstStringOrFieldReference(e, "getRepository") */        ) {            return null;        }// ...}

Maybe removing that commented line as I did is too permissive and can cause performance issues? If so, we could narrow the matching methods to "get*" for example...

@Haehnchen
Copy link
Owner

@theredled yes this mentioned method check is for performance and also to not overflow the phpstorm signatures for every method. By removing this simply we are saying we are responsible for all methods.

We need some filtering here. But for now i just see to support it via a configuration.

Another way would be by using the "php7 returns" and index every file to get "getRepo" automaticcally. But as the index is build inside "getType" we dont have access to it at this point. So this must then be cached. So would be a bigger task.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@theredled@Haehnchen

[8]ページ先頭

©2009-2025 Movatter.jp