Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typehint (intellisense) objects within a twig loop

Tags:

I've searched for a solution but I can't find any suitable for Twig, I know it's a quality of life thing. But it would make templating slightly easier.

Example

{% for userObj in userObjCollection %}   {{ userObj.property }}    {# I want to type hint userObj so I can use intellisense to get the right property #} {% endfor %} 

I'm currently using the PHPStorm IDE,
any suggestions or pointers are greatly appreciated.

Edit Note that this is pure a question for an easier way to code within the loop. Not something a user of a site would come in contact with. (Also added phpstorm tag to clarify)

Edit 2
I've got the Symfony2 and PHP Annotations plugins installed (Sorry for not pointing this out earlier)

like image 889
Ricardo Avatar asked Mar 20 '15 10:03

Ricardo


1 Answers

Use this in your twig:

{# @var foo \FooObject #} 
like image 143
Tom Avatar answered Sep 23 '22 04:09

Tom