Enable SlevomatCodingStandard.Classes.BackedEnumTypeSpacing

Created on 26 November 2024, 4 months ago

Problem/Motivation

A standard was defined for Enum and it can be enforced with SlevomatCodingStandard.Classes.BackedEnumTypeSpacing.

Steps to reproduce

Proposed resolution

Enable SlevomatCodingStandard.Classes.BackedEnumTypeSpacing

Remaining tasks

Add SlevomatCodingStandard.Classes.BackedEnumTypeSpacing to core/phpcs.xml.dist

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

📌 Task
Status

Active

Version

11.0 🔥

Component

other

Created by

🇳🇿New Zealand quietone

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.

  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @quietone
  • First commit to issue fork.
  • Pipeline finished with Failed
    4 months ago
    Total: 543s
    #352944
  • Pipeline finished with Failed
    4 months ago
    Total: 509s
    #353004
  • 🇳🇿New Zealand quietone

    @ankitv18, this issue is tagged as a Novice, and is best to leave such issues for a first time contributor. Unless, of course, the issue has become stale.

  • 🇮🇳India ankitv18

    I saw no one has touched this issue since past two days that's why raised the MR.
    Anyways I'll keep this issue in Active state for new members.

  • 🇺🇸United States dww

    2 days during a holiday week isn't much time to give new contributors a chance to find and work on it. This is not a release-blocking, urgent task, so there's no need to rush. 😅

    That said, since the work is already done, and there's a reviewable MR, leaving the status 'Active' does nothing to help new users, and might potentially lead to confusion.

  • 🇺🇸United States dww

    Looks like random fails in the pipeline. I just retried the jobs. Let's see if the bot is happy with the re-runs (should be).

  • 🇺🇸United States dww

    Bot is happy. MR is simple and does the trivial change requested by the clear issue summary.

    I tried some manual local testing to make sure the sniff does what we want. I made the following change:

    diff --git a/core/lib/Drupal/Core/Database/Event/StatementEvent.php b/core/lib/Drupal/Core/Database/Event/StatementEvent.php
    index 452c200..1033945 100644
    --- a/core/lib/Drupal/Core/Database/Event/StatementEvent.php
    +++ b/core/lib/Drupal/Core/Database/Event/StatementEvent.php
    @@ -7,7 +7,7 @@
     /**
      * Enumeration of the statement related database events.
      */
    -enum StatementEvent: string {
    +enum StatementEvent : string {
    
       case ExecutionStart = StatementExecutionStartEvent::class;
       case ExecutionEnd = StatementExecutionEndEvent::class;
    

    Then I did this:

    composer run phpcs core/lib/Drupal/Core/Database/Event/StatementEvent.php
    

    Without this MR change applied, phpcs passed. Once I added the MR diff, I got:

    ----------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------
     10 | ERROR | [x] There must be no whitespace before colon.
    ----------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------
    

    Then I tried phpcbf to make sure that worked, too:

    PHPCBF RESULT SUMMARY
    ----------------------------------------------------------------------------------------------------
    FILE                                                                                FIXED  REMAINING
    ----------------------------------------------------------------------------------------------------
    .../core/lib/Drupal/Core/Database/Event/StatementEvent.php  1      0
    ----------------------------------------------------------------------------------------------------
    A TOTAL OF 1 ERROR WERE FIXED IN 1 FILE
    ----------------------------------------------------------------------------------------------------
    

    So all is working as expected, and enforcing the standard we adopted.

    Nothing else to do here. RTBC.

    Thanks,
    -Derek

  • 🇮🇳India ankitv18

    Totally make sense ~~ I'll keep that in my mind :D
    And thanks for the quick review & moving into RTBC.

    • larowlan committed 0dc7ae45 on 11.x
      Issue #3490056 by ankitv18, dww, quietone: Enable SlevomatCodingStandard...
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    Committed to 11.x - thanks!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024