php - PHPDoc, Factory @return type -
let's i've
- an abstract class with 1 abstract method.
- 2 child classes define abstract method in own way.
- a factory returns instance of 1 of 2 child classes based on arguments.
following sample code
abstract class datalist{ abstract public function render($arg1, $arg2); } class datalist_table{ public function render($arg1, $arg2){ /* here */ } } class datalist_list{ public function render($arg1, $arg2){ /* here */ } } class datalistfactory{ /** * usual stuff * * @return datalist */ public static function build($args){ $class_name = 'datalist_' . $args['type']; return new $class_name($args['m'][0], $args['m'][1]); } } //in other file $list = datalistfactory::build($args); $list-> ....
my problem
my ide (phpstorm) not hint on $list->render()
. guess because has been declared abstract
.
question
should put in front of @return
in phpdoc datalistfactory::build()
ide hints on functions defined in child classes well.
p.s.
- i've tried instructions in following questions no success
phpdoc notation specify return type identical parameter type - phpdoc: is possible reference object property descriptions factory method docblock?
- phpdoc preconditions
- phpdoc fluent interface in subclass?
you need open file in project. use phpstorm 8.0.3 create new file in project , insert code. works fine =)
Comments
Post a Comment