Haehnchen / idea-php-symfony2-plugin

IntelliJ IDEA / PhpStorm Symfony Plugin
https://plugins.jetbrains.com/plugin/7219
MIT License
910 stars 137 forks source link

Is there a way to add PHP template name support for custom render function? #1704

Open Anubarak opened 3 years ago

Anubarak commented 3 years ago

Sorry for the incredible bad title.. and thank you very much for your great plugin, it really helps me. One thing I was looking for is the following:

My Controller

// works...
public function myFunction()
{
    $this->view->render('template-path.twig, ['var1' => 1]);
}

pressing CTRL enables me to jump right to the template and all variables in the template are available in PHPStorm image image

I would like to create a custom wrapper for this

public function myCustomTemplateRenderFunction(string $templateName, array $variables = [])
{
    // do some stuff, proceed the templateName and variables... custom logic here...

    return $this->view->render('calculations/' . $templateName . '.twig', $variables);
}

// .....
// automatically jumping to the template or variable suggestions is not possible here anymore
$this->myCustomTemplateRenderFunction('test', ['var1' => 1]);

So my question is: is there any possible way (via PHPDoc, Plugin Settings injection or whatever) to tell PHPStorm myCustomTemplateRenderFunction actually calls a render function with a certain path in the end?

Thank you very much.

Lorenzschaef commented 2 years ago

Maybe this is what you are looking for?

https://www.jetbrains.com/help/phpstorm/symfony-creating-helper-functions.html

Anubarak commented 2 years ago

@Lorenzschaef Not 100% what I wanted - but I can go with that. Thank you very much. This functionality is awesome

Haehnchen commented 2 years ago

yes, in general i am thinking to support "wildcards" for templates in many places and also to improve all php completion with code path analyse, with both this would catch your use case here.