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

Issue fork drupal-3490056

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

quietone created an issue. See original summary.

ankitv18 made their first commit to this issue’s fork.

quietone’s picture

@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.

ankitv18’s picture

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.

dww’s picture

Status: Active » Needs review

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.

dww’s picture

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).

dww’s picture

Status: Needs review » Reviewed & tested by the community

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

ankitv18’s picture

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...
larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 11.x - thanks!

Status: Fixed » Closed (fixed)

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