Fixed Coding Standards recommendations

Created on 16 March 2023, about 2 years ago

Problem/Motivation

Running the phpcs we got some issues:

FILE: hook_event/src/Event/HookEventInterface.php
-------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------
 41 | ERROR | Unknown type hint "mixed" found for $default_value
 51 | ERROR | Unknown type hint "mixed" found for $value
-------------------------------------------------------------------------------------------------------------


FILE: hook_event/src/Event/HookInvokeEventInterface.php
-------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------
 24 | ERROR | Unknown type hint "mixed" found for $value
-------------------------------------------------------------------------------------------------------------------


FILE: hook_event/src/Extension/ModuleHandler.php
------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------
 7 | WARNING | [x] Unused use statement
 9 | WARNING | [x] Unused use statement
------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------


FILE: hook_event/README.md
--------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
--------------------------------------------------------------------------------------
  62 | WARNING | Line exceeds 80 characters; contains 109 characters
  92 | WARNING | Line exceeds 80 characters; contains 89 characters
 104 | WARNING | Line exceeds 80 characters; contains 84 characters
--------------------------------------------------------------------------------------

Time: 352ms; Memory: 8MB

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ“Œ Task
Status

Fixed

Version

1.0

Component

Code

Created by

๐Ÿ‡ง๐Ÿ‡ทBrazil renatog Campinas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @renatog
  • @renatog opened merge request.
  • Status changed to Needs review about 2 years ago
  • Status changed to Needs work about 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia hardikpandya

    I agree on the points for README and mixed typehint. I did found a couple of other phpcs issues pending related to DI.

    FILE: src/Discovery/HookEventsDiscovery.php
    ---------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    ---------------------------------------------------------------------------------------------
     64 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     66 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    ---------------------------------------------------------------------------------------------
  • ๐Ÿ‡ง๐Ÿ‡ทBrazil renatog Campinas

    I was thinking about fix on this current issue focus on "Coding Standards", and have a separated ticket to handle the "Best Practice" where we can fix the DI cases cited

  • Status changed to RTBC about 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia hardikpandya

    In that case, this can be marked RTBC.

  • Status changed to Fixed about 2 years ago
  • ๐Ÿ‡ต๐Ÿ‡ฑPoland sayco Toruล„

    Thx, RenatoG! For the mixed type, it's as you said - the PHP 8.0+ feature, so it should stay as it is.
    I also understand the point of ignoring the README.md, having code samples makes it almost impossible to keep with that limit (I tend to like the PSR-12 120 chars limit BTW).

    Regarding the DI, I really wanted to push this module to the stable release.
    This was the only piece of the puzzle that I couldn't figure out. I was trying to make it
    the same way as the circular reference is done at the core for the theme.manager

      theme.manager:
        class: Drupal\Core\Theme\ThemeManager
        arguments: ['%app.root%', '@theme.negotiator', '@theme.initialization', '@module_handler']
        calls:
          - [setThemeRegistry, ['@theme.registry']]
    

    strangely without any luck.
    I don't have that much time recently so any help on this issue will be appreciated.

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

Production build 0.71.5 2024