Skip to content

PSR2.ControlStructures.SwitchDeclaration confused when semicolon is used for cases instead of colon #579

@VasekPurchart

Description

@VasekPurchart

I got really confused by this error message:

 4 | ERROR | CASE statements must not be defined using curly braces | | (PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase) 

In the end I narrowed it down to the problem being usage of ; isntead of :. Frankly I've never known this was even possible, but it is mentioned in the PHP manual:

It's possible to use a semicolon instead of a colon after a case

This can be reproduced with this code:

<?php switch ($foo) { case 1; }

In PSR2 there is no mention if semicolon is allowed in this place so I guess the correct resolution is not to show any errors (certainly not this one).

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