phpsyntaxphpstormpsr-2

Private member variable must be prefixed with an underscore


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


Solution

  • 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