Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
一个类应该在设置器上启用链接,因此相应的函数应该return $this;
return $this;
现在对于@return注释,我看到了实现
@return
@return self
和
@return MyModel
哪一个被认为是最佳实践,为什么?
一些IDE不支持@return self,这就是为什么一些开发者使用@return MyModel
如果您在“ParentClass”类中有一些方法。
案例 1)@return 父类。当您从子级调用该方法时,实际返回的对象与记录的不同。
案例 2) @return 这个。一切都好
@return MyModel 与 @return self/static 相同