Only use colons in case statements

Created on 13 August 2017, about 8 years ago
Updated 11 August 2025, 4 days ago

Problem/Motivation

Using colon instead of semicolon in case statements is deprecated in PHP 8.5
- https://github.com/php/php-src/commit/5f8d648af6ef4e29a3c7f2b2029d08466c...
- RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_semicolon_after_...

Steps to reproduce

git grep -n -E "^\s*case\s+.*;" -- "*.php" "*.module" "*.install"
core/lib/Drupal/Core/Config/Action/Exists.php:15:  case ErrorIfExists;
core/lib/Drupal/Core/Config/Action/Exists.php:16:  case ErrorIfNotExists;
core/lib/Drupal/Core/Config/Action/Exists.php:17:  case ReturnEarlyIfExists;
core/lib/Drupal/Core/Config/Action/Exists.php:18:  case ReturnEarlyIfNotExists;
core/lib/Drupal/Core/Config/DefaultConfigMode.php:13:  case All;
core/lib/Drupal/Core/Config/DefaultConfigMode.php:14:  case InstallSimple;
core/lib/Drupal/Core/Config/DefaultConfigMode.php:15:  case InstallEntities;
core/lib/Drupal/Core/Config/DefaultConfigMode.php:16:  case Optional;
core/lib/Drupal/Core/Config/DefaultConfigMode.php:17:  case SiteOptional;
...

Proposed resolution

Enable SwitchDeclarationSniff and fix usage

Still: here's my suggestion for code unification (and Trivial Patch Of the Month candidate). Regexp search yielded 10 cases, some of which are intermixed with semicolons on other lines in the same switch statement.

Remaining tasks


- enable sniffer and fix usage
- review/commit

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component

other

Created by

πŸ‡³πŸ‡±Netherlands roderik Amsterdam,NL / Budapest,HU

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024