Volodymyr Sitdikov
Volodymyr Sitdikov

Reputation: 424

How to set PhpStorm recognize variable's class

I stacked with a problem in PhpStorm. I have a code:

/**
 * $this->data['rows'] My_Class[]
 */
public function countRows(){
    foreach($this->data['rows'] as $row){
        $row->(here i want to get all functions in a class with autocomplete)
    }
}

Here I am trying to reach Class functions with PhpStorm autocomplete helper but this doesn't work.

How could I define some variable exact class or type with PHPDoc?

Upvotes: 3

Views: 280

Answers (1)

LazyOne
LazyOne

Reputation: 165471

You can type hint $row variable directly with /** @var MyClass $row */ PHPDoc comment:

foreach($this->data['rows'] as $row){
    /** @var MyClass $row */
    $row->(here i want to get all functions in a class with autocomplete)
}

Upvotes: 4

Related Questions