Skip to content

[generate:event:subscriber] Generated EventSubscriber class does not honor coding standards #3983

@csegarra

Description

@csegarra

Problem/Motivation

The code generated for the EventSubscriber has some errors regarding the Drupal coding standards:

  • Expected 1 blank line before function; 2 found before the class constructor.
  • Visibility must be declared on method "getSubscribedEvents".
  • Doc comment short description must be on a single line, further text should be a separate paragraph on callback functions.
  • Missing parameter comment on callback functions.
  • Expected type hint "GetResponseEvent"; found "Event" for $event on callback functions.

How to reproduce

Using Drupal Console 1.8 create a custom module:

drupal generate:module \
  --module "CS Test" \
  --machine-name cs_test \
  --module-path modules/custom \
  --description "Code Styling test module" \
  -q

And then add an EventSubscriber for some events:

drupal generate:event:subscriber \
  --module cs_test

Solution

The EventSubscriber class should be modified to follow the Drupal coding standards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions