How to tell code inspector my base class?
Hi,
I got base abstract class with code like this:
protected function importFromLegacyData($row) {}
public static function getById($id) {
...
$className = get_called_class();
$result = new $className();
$result->importFromLegacyData($row);
return $result;
}
My problem really lies in Code Inspection - it complains method importFromLegacyData() is not found in the class. This is no surprise really, because I guess CI does not simply know what class $result objects refers too. I'd be fine if CI could even assume that $result is my base class as method is importFromLegacyData() implemented here - can this be done in any way?
Please sign in to leave a comment.
Hi there,
Use PHPDoc for inline variable:
You could try to use "self" or "static" to specify current class instead of specific class ("MyClass" in the example above) -- I just do not know if this will work this way (never tried myself).
Seems both approaches work. So either inline PHPDoc or replacing get_called_class() with new static(); solve my problem. Thanks.