开发者

proper phpdoc @return for factory method

开发者 https://www.devze.com 2023-03-10 03:57 出处:网络
I am curious how to docu开发者_如何学编程ment the following scenario. Imagine a group of classes:

I am curious how to docu开发者_如何学编程ment the following scenario. Imagine a group of classes:

abstract class Personality {}
class Me extends Personality {}
class Myself extends Personality {}
class Irene extends Personality {}

If I am writing a factory-esque method to instantiate and return a subclass of class Personality, how would I properly document the @return?

@return mixed  A "Personality" subclass object

or

@return Personality  A "Personality" subclass object


@return Personality A "Personality" subclass object

is the best. And IDE will provide you with autocomplete properties for the Personality class.

0

精彩评论

暂无评论...
验证码 换一张
取 消