Skip to content

Deprecate semicolons after case in switch statement #15258

Open
@upyx

Description

@upyx

Description

Hello everyone 👋

Did you know that...

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

<?php
switch($beer)
{
    case 'tuborg';
    case 'carlsberg';
    case 'heineken';
        echo 'Good choice';
    break;
    default;
        echo 'Please make a new selection...';
    break;
}
?>

This has been working since at least PHP 4: https://php-legacy-docs.zend.com/manual/php4/en/control-structures.switch

I had never seen syntax like this until I accidentally wrote it myself. The resulting code confused everyone.

IMO, this syntax doesn't have benefits and can lead to mistakes. Therefore, I propose to deprecate it and remove it from future versions.

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