PHP8,如何在属性中写评论?
我正在从注释迁移到属性,但我有疑问。 我应该如何为我的方法编写注释以解释它们的功能?
我应该像这样结合注释和属性吗?
/**
* This route does this and that.
*/
#[Route('/my/route/', name:'my_route')]
public function myRoute(): Response
但它很丑。或者相反,甚至更难看:
#[Route('/my/route/', name:'my_route')]
/**
* This route does this and that.
*/
public function myRoute(): Response
或者我应该给它们加上标签?但它没有被 IDE 正确解析(当我将鼠标悬停在该方法上时,我没有看到该描述)
# This method does this and that
#[Route('/my/route/', name:'my_route')]
public function myRoute(): Response
我知道这个问题听起来像是一个基于选项的问题,但我正在寻找是否有“官方”推荐的方法,我不能没有找到任何关于此的内容,所有有关属性的示例都没有任何评论......
I am migrating from annotations to attributes, but I have a doubt.
How should I write comments to my methods, to explain their functionality?
Should I combine annotations and attributes, like this?
/**
* This route does this and that.
*/
#[Route('/my/route/', name:'my_route')]
public function myRoute(): Response
But it's ugly. Or opposite, even uglier:
#[Route('/my/route/', name:'my_route')]
/**
* This route does this and that.
*/
public function myRoute(): Response
Or should I put them with an hashtag? But it's not parsed correctly by IDEs (I don't see that description when I mouseover the method)
# This method does this and that
#[Route('/my/route/', name:'my_route')]
public function myRoute(): Response
I know this question sounds like an option-based one, but I'm looking if there is an "official" recommended way, I couldn't find anything about this, all the examples about attributes don't have any comment...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论