annotating a local variable in php

后端 未结 2 1665
悲&欢浪女
悲&欢浪女 2021-01-31 16:46

I am using Eclipse PDT and I want to annotate a local variable using Phpdoc.

All I see is that I can annotate the variables/properties of a class using @var

2条回答
  •  有刺的猬
    2021-01-31 17:14

    The Phpdoc standard does not cover these annotations (it only cover class properties with the @var tag); however, it is perfectly possible in Eclipse (e.g. PDT):

    /* @var $variable Type */
     ^         ^        `--- type
     |      variable           
     |
     `--- single star
    

    This also works in all other PHP IDEs like Netbeans or Phpstorm which is useful if you exchange your code with others.

    Example Code:

    
     
    

    Example Screenshot (Eclipse PDT (Indigo)):

    Eclipse PDT (Indigo)

    Related Question & Answers:

    • How do I make my PHP IDE understand Dependency Injection Containers?
    • Is there a way to make PhpStorm's autocomplete “go deeper”?

提交回复
热议问题