Skip to content
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

service autocompletion not working on container shortcuts #46

Closed
jovobe opened this issue Apr 29, 2013 · 12 comments
Closed

service autocompletion not working on container shortcuts #46

jovobe opened this issue Apr 29, 2013 · 12 comments
Labels

Comments

@jovobe
Copy link

jovobe commented Apr 29, 2013

If you use a container-shortcut for the get-method like the "Symfony\Bundle\FrameworkBundle\Controller\Controller" but not call the get-method directly on the container-object ($this->container->get($id)) e.g. with a getter: $this->getContainer()->get($id)
container-shortcut
the autocompletion for the services is not working. The $this->getContainer() getter has a correct annotation:
container-getter

@adrienbrault
Copy link
Contributor

The plugin initially had some support for this. However, because the implementation felt a bit like a hack and to improve performance, it was removed.

@adrienbrault
Copy link
Contributor

Would you like to be able to have an per project setting to add your CustomBaseController:get method signature ?

@Haehnchen
Copy link
Owner

we only need to resolve the $id parameter. i did some research on that before, that looks working, but needs some more improvements

PhpPsiElement value = ((AssignmentExpression)parent).getValue();

@jovobe
Copy link
Author

jovobe commented May 5, 2013

I think a method signature per project would fix my problem for now. However, I think that it is not a clean solution. The right way would be to resolve the $id paramenter depending on the annotation of the $this->getContainer() method.

@cerritus
Copy link

cerritus commented May 7, 2013

Autocomplete for getRepository shotrcut also doesn't work

public function getRep($name)
{
    return $this->get('doctrine')->getRepository($name);
}

@Haehnchen
Copy link
Owner

same issue, if we resolve the first one we will also get the second :)
by the way here is also a reflink: http://devnet.jetbrains.com/message/5486464

@heorshe
Copy link

heorshe commented Aug 9, 2013

+1 this would indeed be a good feature

@Haehnchen
Copy link
Owner

can now be configured or activate on docblocks: http://symfony2-plugin.espend.de/extension/method_parameter.html

@heorshe
Copy link

heorshe commented Aug 9, 2013

autocomplete for parameters works, but autocomplete for return value not work :(

/**
 * @param string $serviceName #Service
 */
protected function get($serviceName)
{
    return $this->container->get($serviceName);
}

/**
 * @param string $entityName #Entity
 */
protected function getRep($entityName)
{
    return $this->container->get('doctrine')->getRepository($entityName);
}

$this->container->get('router')-> // work
$this->get('router')-> // not work
$this->container->get('doctrine')->getRepository('App:User')-> // work
$this->getRep('App:User')-> // not work

@Haehnchen
Copy link
Owner

iam also search for a solution many times on that, but currently its not possible because of api limits and needs some hacking code...

@Haehnchen
Copy link
Owner

close... all core suitable core method support it now

@heorshe
Copy link

heorshe commented Feb 21, 2014

autocomplete for return value still not working

$this->container->get('router')-> // work
$this->get('router')-> // not work

maybe it is necessary to add ContainerAware in SymfonyPhpReferenceContributor.CONTAINER_SIGNATURES instead of Controller?

    private static MethodMatcher.CallToSignature[] CONTAINER_SIGNATURES = new MethodMatcher.CallToSignature[] {
        new MethodMatcher.CallToSignature("\\Symfony\\Component\\DependencyInjection\\ContainerInterface", "get"),
        new MethodMatcher.CallToSignature("\\Symfony\\Component\\DependencyInjection\\ContainerAware", "get"),
    };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants