Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate semicolons after case in switch statement #15258

Open
upyx opened this issue Aug 6, 2024 · 9 comments
Open

Deprecate semicolons after case in switch statement #15258

upyx opened this issue Aug 6, 2024 · 9 comments

Comments

@upyx
Copy link

upyx commented Aug 6, 2024

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.

@cmb69
Copy link
Member

cmb69 commented Aug 6, 2024

This syntax can be used when using plain PHP templates, e.g. https://3v4l.org/7mKS8. While I would not recommend to use switch statements in such templates, some code might still rely on that, so I think dropping support for semicolons after case requires an RFC.

Copy link

github-actions bot commented Nov 5, 2024

There has not been any recent activity in this feature request. It will automatically be closed in 14 days if no further action is taken. Please see https://github.com/probot/stale#is-closing-stale-issues-really-a-good-idea to understand why we auto-close stale feature requests.

@github-actions github-actions bot added the Stale label Nov 5, 2024
@theodorejb
Copy link
Contributor

Don't close it.

@cmb69
Copy link
Member

cmb69 commented Nov 6, 2024

Is anyone going to pursue the RFC process?

@theodorejb
Copy link
Contributor

I'm interested in making an RFC, if someone can assist with the implementation.

@cmb69
Copy link
Member

cmb69 commented Nov 6, 2024

The implementation might be as simple as removing this line:

Anyhow, I suggest that you write to mailing list to gauge some opinions.

@github-actions github-actions bot removed the Stale label Nov 7, 2024
Copy link

github-actions bot commented Feb 5, 2025

There has not been any recent activity in this feature request. It will automatically be closed in 14 days if no further action is taken. Please see https://github.com/probot/stale#is-closing-stale-issues-really-a-good-idea to understand why we auto-close stale feature requests.

@github-actions github-actions bot added the Stale label Feb 5, 2025
@theodorejb
Copy link
Contributor

Don't close

@cmb69 cmb69 removed the Stale label Feb 5, 2025
@DanielEScherzer
Copy link
Contributor

Just cross-linking that this was added to the general 8.5 deprecations RFC (https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_semicolon_after_case_in_switch_statement) and the discussion thread was at https://externals.io/message/126000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants