Symfony2 @var annotation Not Working

So I am testing out PHPStorm as a replacement for PhpED as my PHP IDE of choice.  So far even with this issue you are out performing PhpED however this would be a feature that if it worked, I would buy a license this very second.  On your what's new page, the frst item is aboput supporting @var annotations.  So in my Soynfony 2 project I have the following:



phpstorm-autocomplete-issue.png

Now it seems like it is generating some path or namespace that is taking the current file location into account which seems weird (also making autocomplete useless).  Does this feature not work with namespaces?  Am I doing something wrong?

Like I said any help getting this to work would be great as it would be the nail in the coffin for my decision to purchase a license.

0
6 comments

In case this help in determining how PHPStorm in generating the path/namespace/whatever it is generating, here is the path of that file:

phpstorm-autocomplete-issue2.png

0

You should use proper absolute fully qualified names in PHPDoc in current version of PhpStorm - add leading slash ( \Symfony\... )

0

That does fix the issue.  Out of curousity, why do I need that leading slash?  Am I correct in assuming that I should be giving the namespace as the @var value and if so shouldn't adding the leading slash make it go into the global namespace (which this class does not live)?

It is interesting that when I add a use statement that PHPStorm does automatically add in the leading slash for all Symfony2 stuff.  I guess I have only every see custom namesaces not start with the leading slash and even the PHP documentation doesn't have the leading slash for custom samespaces so I just assumed that a leading slash was reserved for internal PHP only.

0

Well, this is PhpStorm specific implementation effect. We will support same rules as for regular "in-code" class references in 3.0, see http://youtrack.jetbrains.net/issue/WI-5789

This won't make your original doc work though, because within namespace Symfony/Some reference Symfony/Other IS relative to the containing and docs won't work as expected (and this problem with all symfony's own current type docs)

0

Will PhpStorm support just qualified name(without leading slash) in phpdocs? Any plans?

0

We considering it - however this is against the language specs and makes TON of problems.

0

Please sign in to leave a comment.