Skip to content

PHP 8.1 enum not recognized #3474

@fefas

Description

@fefas

Describe the bug
PHP 8.1 enum not recognized.

Code sample

<?php

enum MyEnum
{
    case CONST1;
    case CONST2;
}

To reproduce

Just run the PHPCS with the PSR12 ruleset and the output will be something like:

FILE: /var/www/code/src/MyEnum.php
-----------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
-----------------------------------------------------------------------------------------------------------------------
 5 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 4
   |       |     (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
 6 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 4
   |       |     (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
 7 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, found 0
   |       |     (Generic.WhiteSpace.ScopeIndent.Incorrect)
-----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------

By running the auto fix, I get:

<?php

enum MyEnum
{
case CONST1;
case CONST2;
    }

Expected behavior
The following code should cause no CS error:

<?php

enum MyEnum
{
    case CONST1;
    case CONST2;
}

Versions (please complete the following information):

  • OS: Docker on MacOS (image tag php:8.1.0RC5-cli-alpine3.14)
  • PHP: 8.1 RC5
  • PHPCS: 3.6.1
  • Standard: PSR12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions