You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I want to report variable or members not in camelCase, but with some exceptions. So I would like to report only on variable/member declaration, not on usage
Code sample
class Hello
{
// phpcs:disable Squiz.NamingConventions.ValidVariableName// it is ignoredpublicstring$hello_world;
publicfunction__construct(
// it is ignoredpublicint$number_of_results,
) {
}
// phpcs:enable Squiz.NamingConventions.ValidVariableNamepublicfunctiontest(): void
{
// shouldn't be reported$this->number_of_results = 1;
// should be reported for the creation of $number_of_pages $number_of_pages = $this->number_of_results;
}
}
Create a file called test.php with the code sample above...
Run phpcs test.php ...
See error message displayed
55 | ERROR | Member variable "number_of_results" is not in valid camel caps format
58 | ERROR | Variable "number_of_pages" is not in valid camel caps format
58 | ERROR | Member variable "number_of_results" is not in valid camel caps format
Expected behavior
An option to disable on usage (or disable if it has been disabled on the variable/member declaration). I don't want to need to write //phpcs::disable ... every time I use $this->number_of_results
Versions (please complete the following information):
OS: windows 10
PHP: 8.1
PHPCS: 3.7.1
Standard: psr12
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
momala454
changed the title
Squiz.NamingConventions.ValidVariableName only report for declaration, not usage
Squiz.NamingConventions.ValidVariableName how to only report for declaration, not usage
Nov 18, 2022
The sniff cannot be configured to only report on the first definition of a variable. It will always report everywhere the variable is used.
This isn't something I would add to the sniff as it is very hard to track this sort of variable declaration in PHP_CodeSniffer, so the results would not be accurate.
Describe the bug
I want to report variable or members not in camelCase, but with some exceptions. So I would like to report only on variable/member declaration, not on usage
Code sample
Custom ruleset
To reproduce
Steps to reproduce the behavior:
test.php
with the code sample above...phpcs test.php ...
Expected behavior
An option to disable on usage (or disable if it has been disabled on the variable/member declaration). I don't want to need to write //phpcs::disable ... every time I use $this->number_of_results
Versions (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: