Is there any why to make my IDE (actually PHPStorm) understand that:
$student->setName('Marco');
Will return an instance of Student, without redefining setName() in the subclass (only for adding PHPDoc comments)?
class Person
{
private $name;
/**
* @param string $name
* @return Person
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
}
class Student extends Person { }
You can return $this instead of person in your docblock
you have to overwrite your method tag as comment like this
/**
* @method Student setName($name)
*/
class Student extends Person { }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With