In PHPStorm, I can type-hint a variable this way:
/** @var Point $point */
$point->x();
However, say I inherited a variable from a parent class, and want to type-hint it:
class PointProxy extends Proxy
{
public function x()
{
...
/** @var Point $this->geometry */
return $this->geometry->x();
}
}
This doesn't work, PHPStorm acts as if I had type-hinted $this
, and not $this->geometry
.
Is there a way to make such a type-hint work without redeclaring the $geometry
property in the subclass, or is this unsupported?
Try this code. Also you can press alt+enter
at undefined properties and select Add @property
it will help you to create phpdoc faster.
/**
* @property Point $geometry
*/
class PointProxy extends Proxy {
public function x() {
return $this->geometry->
}
}
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