Skip to content

[PHP8.3] "final public const string JOURNEY" leads to "Class constants must be uppercase" #3936

Closed
PHPCSStandards/PHP_CodeSniffer
#332
@ralusnom

Description

@ralusnom

Description

In IntelliJ IDEA phpcs, incorrectly flags valid PHP code as an warning. Specifically, it misinterprets the type of class constants. For example, declaring a constant like final public const string JOURNEY; results in an error message from PHP CS Fixer stating

"phpcs: Class constants must be uppercase; expected STRING but found string".

It seems that PHP CS Fixer is incorrectly checking the type declaration (string) instead of the constant name (JOURNEY).

Runtime version

PHP CS Fixer v3.40.2, when used with PHP 8.3

Code snippet that reproduces the problem

<?php
// Erroneous code snippet
final public const string JOURNEY;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions