简体   繁体   中英

PHPDoc: Is is possible to reference the object property descriptions from factory method docblock?

If I use a factory method to instantiate objects then is it possible to reference the docblock descriptions of the class properties for the objects being instantiated?

I find myself looking into the classes to remind me what parameters to give the factory method. It would be handy if I could just reference all the relevant docblock descriptions from all the objects that the factory outputs, then my IDE would prompt me when I call the factory method.

For the scenario you describe, the best path I can see is to have all those potential classes implement the same interface, or perhaps extend from the same abstract parent class. Then, use @return on the factory method to say it returns an object of that interface/abstract. That way, the IDE would be able to read the docblocks from the code of the interface/abstract and present info to you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM