-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
PHPCSStandards/PHP_CodeSniffer
#332Labels
Description
Describe the bug
PHP 8.3 allows defining a type for class constants (see https://php.watch/versions/8.3/typed-constants) to enforce compatibility with overrides and have better static analysis support.
When using this with current stable phpcs, this triggers an error message like:
Class constants must be uppercase; expected STRING but found string
Code sample
class Test {
const string TEST_CONSTANT = 'test';
}Custom ruleset
<?xml version="1.0"?>
<ruleset name="My Custom Standard">
<description>If you are using a custom ruleset, please enter it here.</description>
</ruleset>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
Class constants must be uppercase; expected STRING but found string
Expected behavior
No error.
Versions (please complete the following information)
| Operating System | any |
| PHP version | 8.3 |
| PHP_CodeSniffer version | latest |
| Standard | any? |
| Install type | composer |
Please confirm:
- I have searched the issue list and am not opening a duplicate issue.
- I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
- I have verified the issue still exists in the
masterbranch of PHP_CodeSniffer.
denisvanmorgan, matmper, MaxiCom, burned42, MirakuSan and 7 more