Skip to content

Enums still not supported as of 3.6.2 #3602

@jacekwilczynski

Description

@jacekwilczynski

Describe the bug
Despite #3478, there's still Generic.WhiteSpace.ScopeIndent errors when using enums.

Code sample

<?php

declare(strict_types=1);

enum MyEnum
{
    case FIRST_OPTION;
    case SECOND_OPTION;
    case THIRD_OPTION;
}

Custom ruleset

<?xml version="1.0" encoding="UTF-8"?>

<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">

    <arg name="basepath" value="."/>
    <arg name="cache" value="var/.phpcs-cache"/>
    <arg name="colors"/>
    <arg name="extensions" value="php"/>
    <arg value="p"/>
    <arg value="n"/>
    <arg value="s"/>

    <rule ref="PSR1"/>

    <rule ref="PSR12">
        <exclude name="PSR12.Operators.OperatorSpacing.NoSpaceBefore"/>
        <exclude name="PSR12.Operators.OperatorSpacing.NoSpaceAfter"/>
    </rule>

    <rule ref="Generic.Files.LineLength">
        <properties>
            <property name="lineLimit" value="120"/>
        </properties>
    </rule>
    <rule ref="Generic.Metrics.NestingLevel">
        <properties>
            <property name="nestingLevel" value="3"/>
            <property name="absoluteNestingLevel" value="3"/>
        </properties>
    </rule>
    <rule ref="Generic.PHP.ForbiddenFunctions"/>
    <rule ref="Generic.PHP.NoSilencedErrors"/>
    <rule ref="Generic.WhiteSpace.ScopeIndent"/>
    <rule ref="Generic.Formatting.SpaceAfterCast"/>

    <rule ref="Squiz.Classes.ValidClassName">
        <exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>
    </rule>
</ruleset>

but a simple config like:

<?xml version="1.0" encoding="UTF-8"?>

<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">

    <rule ref="Generic.WhiteSpace.ScopeIndent"/>
</ruleset>

produces an identical result.

To reproduce
Steps to reproduce the behavior:

  1. Create a file called test.php with the code sample above...
  2. Run phpcs test.php ...
  3. See error message displayed
  7 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 4 (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
  8 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 4 (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
  9 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 4 (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
 10 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, found 0
    |       |     (Generic.WhiteSpace.ScopeIndent.Incorrect)

Expected behavior
No errors.

Versions:

  • OS: Debian GNU/Linux 11 (bullseye)
  • PHP: 8.1.6
  • PHPCS: 3.6.2
  • Standard: PSR1 + PSR12 + other rules (see config above)

Additional context
I am actually using the most recent version:

vendor/bin/phpcs --version
PHP_CodeSniffer version 3.6.2 (stable) by Squiz (http://www.squiz.net)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions