我应该使用@return自己,这个还是当前的类? [英] Should I use @return self, this or the current class?

查看:137
本文介绍了我应该使用@return自己,这个还是当前的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个返回当前对象的方法,如何记录?

I have a method that return the current object, how do I document this?

/**
 * set something
 *
 * @return this
 */
public function setSomething(){
            // ...
    return $this;
}

或者我应该做 @return self @return Current_Class_Name

推荐答案

@return Current_Class_Name 肯定会工作,就是我喜欢的。

@return Current_Class_Name will definitely work and is what I prefer.

@return self 可能会与某些程序一起工作。

@return self may work ok with some programs too.

@return this 是坏的,因为这不是一个typename 。

@return this is bad because this is not a typename.

这篇关于我应该使用@return自己,这个还是当前的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆