Take a look at this code example:
class basetype {
public function method() {
return false;
}
}
class extendtype extends basetype {
public function methodb() {
return true;
}
}
class aa {
/**
* @var basetype
*/
protected $membera;
}
class bb extends aa {
public function __constructor() {
$this->membera = new extendtype();
}
public function dosomething() {
$this->membera->methodb();
}
}
When edited within PHPStorm I get warning that "Method methodb not found in class basetype". I work with preexisting code base and can not alter the base classes. So what can I do in order to remove this warning?
You can override $membera in your class BB and give it a new doc-block with the derived type.
class bb extends aa {
/**
* @var extendtype
*/
protected $membera;
public function __constructor() {
$this->membera = new extendtype();
}
public function dosomething() {
$this->membera->methodb();
}
}
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