PHP_CodeSniffer
PHP_CodeSniffer copied to clipboard
Squiz.NamingConventions.ValidVariableName.NotCamelCaps + property promotion = false positive
Describe the bug
Property promotions handling like variables, but they are class property
Code sample
<?php declare(strict_types = 1);
namespace Tests;
class Test {
public string $normal_property = 'abc';
public function __construct(
public string $promoted_property = 'abc',
) {
// empty
}
}
Custom ruleset
<?xml version="1.0"?>
<ruleset name="My Custom Standard">
<rule ref="Squiz.NamingConventions.ValidVariableName.NotCamelCaps"/>
</ruleset>
To reproduce Steps to reproduce the behavior:
- Create a file called
test.php
with the code sample above... - Run
phpcs test.php ...
- See error message displayed
----------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------
9 | ERROR | Variable "promoted_property" is not in valid camel caps format
----------------------------------------------------------------------------
Expected behavior
No error.
Versions (please complete the following information):
- OS: Windows 10
- PHP: 8.0
- PHPCS: 3.6.2