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

Issue fork hook_event-3348338

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

RenatoG created an issue. See original summary.

renatog’s picture

Status: Active » Needs review

MR with the fix: https://git.drupalcode.org/project/hook_event/-/merge_requests/3

In the first file we have only unused statements.

In the second one README.md we have only some line exceding more than 80 chars but in case that was really necessary pass 8p chars, so put an instruction to ignore this as exception

About the mixed ones I think makes sense for PHP 8+

hardikpandya’s picture

Status: Needs review » Needs work

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
---------------------------------------------------------------------------------------------
renatog’s picture

Title: Fixed phpcs recommendations » Fixed Coding Standards recommendations

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

hardikpandya’s picture

Status: Needs work » Reviewed & tested by the community

In that case, this can be marked RTBC.

  • RenatoG authored 7cb4ac78 on 1.x
    Issue #3348338: Fixed phpcs recommendations
    
sayco’s picture

Status: Reviewed & tested by the community » Fixed

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.

Status: Fixed » Closed (fixed)

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