douliu3831
2018-08-09 08:01
浏览 100
已采纳

私有成员变量必须以下划线为前缀

In PhpStorm, I am adding some code to a class. The class has a private property defined via this line:

private $pdfService

... but the line is underlined by the IDE's syntax checker. Hovering over the line shows the following error message:

Private member variable "jobRepository" must be prefixed with an underscore

This is annoying, since using an underscore to indicate privacy on a property is explicitly discouraged by PSR-2.

Is there a simple way to update the syntax checking so that it adheres to PSR-2 in regards to this rule?

====

Edit: Here's a screenshot.

enter image description here

图片转代码服务由CSDN问答提供 功能建议

在PhpStorm中,我将一些代码添加到类中。 该类有一个通过以下行定义的私有属性:

  private $ pdfService 
   
 
 

...但是 IDE的语法检查器强调了行的下划线。 将鼠标悬停在该行上会显示以下错误消息:

私有成员变量“jobRepository”必须以 下划线为前缀

这很烦人,因为 PSR-2

是否有一种简单的方法可以更新语法检查,使其符合此规则的PSR-2?

====

编辑:这是截图。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duandao8607 2018-08-09 08:48
    已采纳

    The whole message starts with phpcs: .. which means that it comes from PHP Code Sniffer which you have configured and enabled integration for this project.

    Adjust your Code Sniffer rules accordingly or choose different Coding standard (at Settings/Preferences | Editor | Inspections | PHP | Quality tools | PHP Code Sniffer validation) where you do not have such requirement.

    enter image description here

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题