Skip to content

PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase with colon and bracket is unclear #1322

@othercorey

Description

@othercorey

Describe the bug

The error message is unclear when a switch case begins with : and {:

CASE statements must be defined using a colon (PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase)

Code sample

switch ($type) {
  case 'bool':
  {
    break;
  }
}

Expected behavior

Expect the error message to explain the case cannot include bracket scope after the colon not just that it needs a colon.

Versions (please complete the following information)

PHP version 8.3
PHP_CodeSniffer version 4.0.1
Standard PSR2
Install type composer

Additional context

Add any other context about the problem here.

Please confirm

  • I have searched the issue list and am not opening a duplicate issue.
  • I have read the Contribution Guidelines and this is not a support question.
  • 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 4.x branch of PHP_CodeSniffer.

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