Enum support in PHP 8.1

Created on 2 June 2022, about 2 years ago
Updated 11 June 2024, 17 days ago

Problem/Motivation

Currently enums introduced in PHP 8.1 are not supported.
This leads to Sniffs like Drupal.Commenting.FileComment requiring a file comment for PHP files containing an enum.

Steps to reproduce

Run said sniff on a PHP file containing an enum.

Proposed resolution

Define T_ENUM constant if it does not exist to avoid errors and add backwards compatibility.

Update Sniffs to also check for T_ENUM constant:

Drupal.Classes.ClassDeclaration
Drupal.Classes.ClassFileName
Drupal.Classes.UseGlobalClass
Drupal.Commenting.ClassComment
Drupal.Commenting.FileComment
Drupal.Commenting.InlineComment
Drupal.Commenting.InlineVariableComment
Drupal.Methods.MethodDeclaration
Drupal.Scope.MethodScope
Drupal.InfoFiles.ClassFiles

Note:
Please note that those changes only work when squizlabs/PHP_CodeSniffer releases the next version to include support for T_ENUM.

πŸ“Œ Task
Status

Fixed

Version

8.3

Component

Coder Sniffer

Created by

πŸ‡¦πŸ‡ΉAustria chfoidl Salzburg

Live updates comments and jobs are added and updated live.
  • PHP 8.1

    The issue particularly affects sites running on PHP version 8.1.0 or later.

Sign in to follow issues

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.69.0 2024