-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
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 ignored
public string $hello_world;
public function __construct(
// it is ignored
public int $number_of_results,
) {
}
// phpcs:enable Squiz.NamingConventions.ValidVariableName
public function test(): 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;
}
}Custom ruleset
<?xml version="1.0"?>
<rule ref="Squiz.NamingConventions.ValidVariableName"/>To reproduce
Steps to reproduce the behavior:
- Create a file called
test.phpwith 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.