1

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

  • To start with: show exact message screenshot please. I do not remember such requirement. Must be either some disabled-by-default inspection or 3rd party inspection. – LazyOne Aug 09 '18 at 08:14
  • 2
    OK ... so as you can see it comes from `phpcs` .. which is **PHP Code Sniffer**. Adjust your Code Sniffer rules or choose different Coding standard (at `Settings/Preferences | Editor | Inspections | PHP | Quality tools | PHP Code Sniffer validation`) where you do not have such requirement. – LazyOne Aug 09 '18 at 08:22
  • @LazyOne: Thank you. This option was directly under `PHP` for me for some reason, but the rest of the route you described worked perfectly. – Mayor of the Plattenbaus Aug 09 '18 at 08:37
  • We must be using different IDE versions -- I'm on vanilla 2018.2. – LazyOne Aug 09 '18 at 08:39

1 Answers1

3

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

LazyOne
  • 158,824
  • 45
  • 388
  • 391