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

被刻印的时光 ゝ 提交于 2019-12-13 01:50:27

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/10053306/phpdoc-is-is-possible-to-reference-the-object-property-descriptions-from-factor

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!