Equivalent of @var annotation for Twig

I'm passing objects to Twig templates:

<img src="{{ branding.getLogoUrl }}">

I assumed there's no way to instruct PhpStorm about this (documentation doesn't mention anything as far as I can tell) but I found a Stack Overflow answer from 2015 stating this should work:

{# @var branding \Full\Namespace\Here\Branding\EmailBrandingInterface #}

But it doesn't accomplish anything for me (hovering or Ctrl+clicking the placeholder doesn't show the class, and method is not reported as used). I have Symfony and Twig plugins. Can it be done? Could it be done but it cannot any more?

 

1

Hi there,

It is the syntax as fas as I'm aware. Although I have never used it myself (have not used Twig for a while).

On related note:

 

1

That's weird… All that seems to be recent work in progress at most. 😕

0

I figured it out… This feature is provided by the Symfony plugin and, although installed and enabled, it was disabled for this project.

PHP → Symfony → Enable Plugin for Project

1

请先登录再写评论。