0

i'm working with huge models on PHPStorm. I'm trying to minimize my annotations.

I want to turn this

Class Stack 
{
    /** @var string */
    public $foo;
    /** @var string */
    public $bar;
    /** @var int    */
    public $foobar;
}

into this:

Class Stack 
{
    /** @var string */ //for both vars
    public $foo;
    public $bar;
    /** @var int    */
    public $foobar;
}

I found the #@+ syntax to define multiple vars but seems that is not working. Maybe there is a workaround?

Thank you very much.

By the way, can i tell phpstorm that $this->MyModel is a MyModel type? Something like:

/** @var $this->MyModel MyModel **/
$this->MyModel

Because CodeIgniter puts all of your models inside a param of the controller.

2 Answers 2

3

I'm afraid that I've not seen any IDE that knows how to recognize the docblock template syntax of /*#@+/.

As for $this->MyModel, you could try using the @property tag on that class where you are using $this->MyModel.

Although some IDEs can reportedly recognize that @var syntax to set a datatype on a local variable:

/** @var \MyModel $model */
$model = $this->MyModel;

I don't think it would work with a class property like that.

Sign up to request clarification or add additional context in comments.

Comments

1

Why you cannot declare it with @property in the PHPDoc block of the class?

/**
 * @property myModel MyModelClass
 */
class Test
{}

$t = new Test();
$t->myModel->[CTRL+Space will return available methods];

Anyway most better to declare property manually in the class. Just make it transparent.

It's really weird to use group comment for objects. I haven't had such practice. But feel free to use similar code:

/**#@+
 * Test
 *
 * @var int
 */
protected $_aa = 1;
protected $_aa2 = 2;
/**#@-*/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.