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?
请先登录再写评论。
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:
That's weird… All that seems to be recent work in progress at most. 😕
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