Problem with underscore and camelCase report

Hi.
I have a problem with the report:
rulesets-controversial.xml-CamelCasePropertyName
PHPCS_PEAR_NamingConventions_ValidVariableName

For example:

If I have this line:

private string $_tablePatients = ‘pacientes’; Phpmd tell me: The property $_tablePatients is not named in camelCase:

But:
I have another code:

private string $codeUser = ‘’; Phpcs tell me: Private member variable “codeUser” must be prefixed with an underscore:

My ask its:

What is the recommendation to prevent these reports or what could you do in this case?

Exclude it from analysis github? or another fix?

Thanks for your answers !

Hello @Vitri_App, and welcome to the Codacy Community! :wave:

It appears that the two tools PHP Mess Detector and PHP Code Sniffer are configured with conflicting rules.

The PSR-12 coding style explicitly says not to prefix property names with an underscore (see section “4.3 Properties and Constants”). So I recommend disabling this PHP Code Sniffer rule on your repository Code patterns page.

Let us know if this helps!

Hello @paulo.ribeiro

Thanks for your answer, It’s useful. I’m going to change options.

Thank you !

1 Like