Implement dependency injection where ever possible

Created on 24 August 2022, over 2 years ago
Updated 22 June 2023, almost 2 years ago

There are numerous calls to the \Drupal static class to fetch various services, but as the documentation for that class states, it's primarily intended for legacy/procedural code that hasn't been rewritten to use dependency injection. As the Drupal core dependency injection documentation states:

Another important benefit of dependency injection is that code will be easier to test via PHPUnit tests , because your domain's business logic will be separated from the huge amount of Drupal dependencies.

This essentially compartmentalizes services so that they can easily be mocked up or replaced, both for testing and in some circumstances during normal operation of a Drupal site.

Some examples of converting from \Drupal static class calls to true dependency injection in the PWA module: #3240962: Dependency injection all the things! (Rewrite to use dependency injection wherever possible.)

Specifics

2.x

These will be breaking changes so a new major version is needed.

Convert to services

The following should be converted to services which will make interacting them much easier because Drupal and Symfony will take care of injecting all the dependencies without us having to every time they're referenced:

Convert to plug-ins and plug-in managers

The following would likely work well if adapted to use the Drupal Plug-in API (see also api.drupal.org docs):

Forms

Forms and form handlers can use dependency injection out of the box so we just have to add the create() methods and reference the services they use:

Unclear

The files under src/FormHandler seem to be a mix of things that should be services mixed in with code that wraps form objects:

They might have to be split into services and value objects/wrapper objects.

1.x

TBD

Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

🇨🇦Canada ambient.impact Toronto

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India vishal365365

    FOUND 59 ERRORS AFFECTING 48 LINES
    ------------------------------------------------------------------------------
    2 | ERROR | [x] Blank lines are not allowed in class definitions
    4 | ERROR | [x] Expected 1 space after colon in style definition; 2 found
    5 | ERROR | [ ] Style definitions must end with a semicolon
    5 | ERROR | [x] Expected 1 space after colon in style definition; 2 found
    6 | ERROR | [ ] Style definitions must end with a semicolon
    6 | ERROR | [x] Expected 1 space after colon in style definition; 3 found
    7 | ERROR | [x] Blank lines are not allowed in class definitions
    10 | ERROR | [ ] Style definitions must end with a semicolon
    10 | ERROR | [x] Expected 1 space after colon in style definition; 2 found
    11 | ERROR | [ ] Style definitions must end with a semicolon
    11 | ERROR | [x] Expected 1 space after colon in style definition; 2 found
    12 | ERROR | [ ] Style definitions must end with a semicolon
    12 | ERROR | [x] Expected 1 space after colon in style definition; 3 found
    13 | ERROR | [x] Blank lines are not allowed in class definitions
    14 | ERROR | [ ] Style definitions must end with a semicolon
    15 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
    15 | ERROR | [ ] No style definition found on line; check for missing colon
    17 | ERROR | [ ] Style definitions must end with a semicolon
    18 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
    18 | ERROR | [ ] No style definition found on line; check for missing colon
    20 | ERROR | [ ] Style definitions must end with a semicolon
    21 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
    21 | ERROR | [ ] No style definition found on line; check for missing colon
    23 | ERROR | [x] Blank lines are not allowed in class definitions
    39 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
    39 | ERROR | [ ] No style definition found on line; check for missing colon
    41 | ERROR | [ ] Style definitions must end with a semicolon
    42 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
    42 | ERROR | [ ] No style definition found on line; check for missing colon
    44 | ERROR | [ ] Style definitions must end with a semicolon
    45 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
    45 | ERROR | [ ] No style definition found on line; check for missing colon
    50 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
    51 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
    52 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
    53 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
    54 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
    55 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
    56 | ERROR | [x] Blank lines are not allowed in class definitions
    57 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
    58 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
    59 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
    76 | ERROR | [x] Blank lines are not allowed in class definitions
    78 | ERROR | [x] Blank lines are not allowed in class definitions
    80 | ERROR | [x] Blank lines are not allowed in class definitions
    82 | ERROR | [x] Blank lines are not allowed in class definitions
    86 | ERROR | [x] Blank lines are not allowed in class definitions
    88 | ERROR | [x] Blank lines are not allowed in class definitions
    91 | ERROR | [x] Blank lines are not allowed in class definitions
    93 | ERROR | [x] Blank lines are not allowed in class definitions
    94 | ERROR | [x] Expected 1 space after colon in style definition; 2 found
    96 | ERROR | [x] Blank lines are not allowed in class definitions
    98 | ERROR | [x] Blank lines are not allowed in class definitions
    99 | ERROR | [x] Expected 1 space after colon in style definition; 2 found
    101 | ERROR | [x] Blank lines are not allowed in class definitions
    103 | ERROR | [x] Blank lines are not allowed in class definitions
    105 | ERROR | [x] Blank lines are not allowed in class definitions
    109 | ERROR | [x] Expected 1 space after colon in style definition; 3 found
    110 | ERROR | [x] Expected 1 space after colon in style definition; 2 found
    ------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 43 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/config_enforce.api.php
    ----------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------
    1 | ERROR | [x] Missing file doc comment
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/config_enforce.install
    ----------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------
    1 | ERROR | [x] Missing file doc comment
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/config_enforce.module
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AND 4 WARNINGS AFFECTING 6 LINES
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    1 | ERROR | [x] Missing file doc comment
    7 | WARNING | [x] Unused use statement
    16 | WARNING | [x] '@TODO: Make this a service?' should match the format '@todo Fix problem X here.'
    27 | WARNING | [x] '@TODO: Skip all confirm forms.' should match the format '@todo Fix problem X here.'
    41 | WARNING | [ ] Line exceeds 80 characters; contains 83 characters
    58 | ERROR | [ ] All functions defined in a module file must be prefixed with the module's name, found "_log" but expected "config_enforce__log"
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/tests/src/FunctionalJavascript/AjaxSubFormCompatibilityTest.php
    -----------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------
    7 | WARNING | [x] Unused use statement
    -----------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/tests/src/Functional/EnforcementLevelsTest.php
    ------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 6 WARNINGS AFFECTING 6 LINES
    ------------------------------------------------------------------------------------------
    98 | WARNING | [x] There must be no blank line following an inline comment
    114 | WARNING | [x] There must be no blank line following an inline comment
    164 | WARNING | [x] There must be no blank line following an inline comment
    181 | WARNING | [x] There must be no blank line following an inline comment
    236 | WARNING | [x] There must be no blank line following an inline comment
    252 | WARNING | [x] There must be no blank line following an inline comment
    ------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/tests/src/Functional/HookTest.php
    -----------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------
    8 | WARNING | [x] Unused use statement
    -----------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/tests/src/Functional/DataAttributesTest.php
    ------------------------------------------------------------------------------------------------
    FOUND 4 ERRORS AND 1 WARNING AFFECTING 5 LINES
    ------------------------------------------------------------------------------------------------
    8 | WARNING | [x] Unused use statement
    87 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    91 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    96 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
    100 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
    ------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/tests/src/Functional/FormConfigDependencyTest.php
    -------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    -------------------------------------------------------------------------------------------------------------------------------------------
    8 | WARNING | [x] Unused use statement
    35 | ERROR | [ ] The array declaration extends to column 84 (the limit is 80). The array content should be split up over multiple lines
    -------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/tests/src/Functional/ConfigResolverTypesTest.php
    --------------------------------------------------------------------------------------------
    FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES
    --------------------------------------------------------------------------------------------
    9 | WARNING | [x] Unused use statement
    176 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
    177 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
    178 | ERROR | [x] Expected newline after closing brace
    --------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/tests/src/Functional/ConfigEnforceUiAssertTestTrait.php
    ---------------------------------------------------------------------------------------------------
    FOUND 5 ERRORS AFFECTING 5 LINES
    ---------------------------------------------------------------------------------------------------
    28 | ERROR | [ ] Description for the @return value is missing
    37 | ERROR | [ ] Description for the @return value is missing
    76 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    166 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    182 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
    ---------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/tests/modules/config_enforce_hook_test/config_enforce_hook_test.module
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    1 | ERROR | [x] Missing file doc comment
    6 | WARNING | [ ] Format should be "* Implements hook_foo().", "* Implements hook_foo_BAR_ID_bar() for xyz_bar().",, "* Implements hook_foo_BAR_ID_bar() for xyz-bar.html.twig.", "* Implements
    | | hook_foo_BAR_ID_bar() for xyz-bar.tpl.php.", or "* Implements hook_foo_BAR_ID_bar() for block templates."
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/src/ConfigEnforcer.php
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 9 ERRORS AND 2 WARNINGS AFFECTING 11 LINES
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    51 | ERROR | [ ] Description for the @return value is missing
    71 | ERROR | [x] Inline control structures are not allowed
    74 | ERROR | [x] Inline control structures are not allowed
    98 | ERROR | [x] Inline control structures are not allowed
    116 | WARNING | [ ] Line exceeds 80 characters; contains 82 characters
    123 | ERROR | [ ] Description for the @return value is missing
    135 | ERROR | [ ] Description for the @return value is missing
    148 | ERROR | [ ] Description for the @return value is missing
    152 | WARNING | [x] '@TODO: find a better way to ignore uuid in general case, rather than special case system.site' should match the format '@todo Fix problem X here.'
    153 | ERROR | [x] Inline control structures are not allowed
    154 | ERROR | [x] Inline control structures are not allowed
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/src/EnforcedConfigRegistry.php
    --------------------------------------------------------------------------------------------------------------------
    FOUND 9 ERRORS AND 4 WARNINGS AFFECTING 13 LINES
    --------------------------------------------------------------------------------------------------------------------
    21 | ERROR | [x] You must use "/**" style comments for a member variable comment
    24 | ERROR | [x] You must use "/**" style comments for a member variable comment
    37 | ERROR | [ ] Description for the @return value must be on the next line
    54 | ERROR | [x] Parameter comment must be on the next line
    55 | ERROR | [x] Parameter comment must be on the next line
    56 | ERROR | [x] Parameter comment must be on the next line
    58 | ERROR | [ ] Description for the @return value must be on the next line
    68 | WARNING | [ ] Line exceeds 80 characters; contains 89 characters
    74 | WARNING | [ ] Line exceeds 80 characters; contains 81 characters
    80 | WARNING | [x] '@TODO: This doesn't belong in this class.' should match the format '@todo Fix problem X here.'
    81 | ERROR | [x] You must use "/**" style comments for a function comment
    90 | WARNING | [x] '@TODO: This doesn't belong in this class.' should match the format '@todo Fix problem X here.'
    91 | ERROR | [x] You must use "/**" style comments for a function comment
    --------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/src/Form/FormHelperTrait.php
    ----------------------------------------------------------------------------------------------------
    FOUND 4 ERRORS AND 1 WARNING AFFECTING 4 LINES
    ----------------------------------------------------------------------------------------------------
    20 | ERROR | [x] You must use "/**" style comments for a member variable comment
    23 | ERROR | [x] You must use "/**" style comments for a member variable comment
    26 | ERROR | [x] You must use "/**" style comments for a member variable comment
    26 | ERROR | [ ] Class property $current_config should use lowerCamel naming without underscores
    67 | WARNING | [ ] Only string literals should be passed to t() where possible
    ----------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/src/Form/EnforceForm.php
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------
    7 | WARNING | [x] Unused use statement
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/src/Form/SettingsForm.php
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------
    9 | WARNING | [x] Unused use statement
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/src/Form/AbstractEnforceForm.php
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 11 ERRORS AND 4 WARNINGS AFFECTING 13 LINES
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    8 | WARNING | [x] Unused use statement
    37 | WARNING | [ ] The deprecation-version '1.0.0' does not match the lower-case machine-name standard: drupal:n.n.n or project:n.x-n.n or project:n.x-n.n-label[n] or project:n.n.n or
    | | project:n.n.n-label[n]
    37 | WARNING | [ ] The removal-version '2.0.0' does not match the lower-case machine-name standard: drupal:n.n.n or project:n.x-n.n or project:n.x-n.n-label[n] or project:n.n.n or
    | | project:n.n.n-label[n]
    37 | ERROR | [ ] Each @deprecated tag must have a @see tag immediately following it
    42 | ERROR | [ ] The trigger_error message 'Using this method is deprecated in 1.0.0 and will be removed before 2.0.0.' does not match the strict standard format: %thing% is deprecated in
    | | %deprecation-version% and is removed from %removal-version%. %extra-info%. See %cr-link%
    62 | ERROR | [x] Expected 1 space after "=>"; 0 found
    72 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
    91 | ERROR | [x] Inline control structures are not allowed
    100 | ERROR | [x] Inline control structures are not allowed
    114 | ERROR | [x] Expected 1 space before opening brace; found 0
    142 | ERROR | [ ] Comment indentation error, expected only 1 spaces
    146 | ERROR | [x] Array indentation error, expected 8 spaces but found 10
    148 | ERROR | [x] Array indentation error, expected 8 spaces but found 10
    150 | ERROR | [x] Array indentation error, expected 8 spaces but found 10
    191 | WARNING | [ ] Line exceeds 80 characters; contains 87 characters
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/src/TargetModuleCollection.php
    --------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------
    21 | ERROR | [x] Expected 1 blank line after function; 2 found
    --------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/src/EnforcedConfig.php
    ---------------------------------------------------------------------------------------------------------------------
    FOUND 9 ERRORS AND 1 WARNING AFFECTING 10 LINES
    ---------------------------------------------------------------------------------------------------------------------
    19 | ERROR | [x] You must use "/**" style comments for a member variable comment
    22 | ERROR | [x] You must use "/**" style comments for a member variable comment
    25 | ERROR | [x] You must use "/**" style comments for a member variable comment
    28 | ERROR | [x] You must use "/**" style comments for a member variable comment
    31 | ERROR | [x] You must use "/**" style comments for a member variable comment
    34 | ERROR | [x] You must use "/**" style comments for a member variable comment
    116 | ERROR | [x] Inline control structures are not allowed
    137 | WARNING | [x] '@TODO: This doesn't belong in this class.' should match the format '@todo Fix problem X here.'
    138 | ERROR | [x] You must use "/**" style comments for a function comment
    142 | ERROR | [x] Inline control structures are not allowed
    ---------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/src/Commands/ConfigEnforceCommands.php
    ----------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ----------------------------------------------------------------------------------
    17 | ERROR | [x] Doc comment long description must end with a full stop
    27 | ERROR | [x] Missing function doc comment
    ----------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/src/FormHandler/AbstractEnforceFormHandler.php
    ------------------------------------------------------------------------------------------
    FOUND 3 ERRORS AFFECTING 3 LINES
    ------------------------------------------------------------------------------------------
    19 | ERROR | [x] You must use "/**" style comments for a member variable comment
    37 | ERROR | [x] Trailing punctuation for @see references is not allowed.
    46 | ERROR | [x] Trailing punctuation for @see references is not allowed.
    ------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/src/FormHandler/EnforceFormHandler.php
    ----------------------------------------------------------------------------------
    FOUND 6 ERRORS AND 3 WARNINGS AFFECTING 9 LINES
    ----------------------------------------------------------------------------------
    10 | WARNING | [x] Unused use statement
    11 | WARNING | [x] Unused use statement
    26 | ERROR | [x] Inline control structures are not allowed
    29 | ERROR | [x] Inline control structures are not allowed
    59 | ERROR | [x] Inline control structures are not allowed
    65 | ERROR | [x] Inline control structures are not allowed
    69 | WARNING | [ ] Line exceeds 80 characters; contains 83 characters
    70 | ERROR | [x] Inline control structures are not allowed
    88 | ERROR | [x] Inline control structures are not allowed
    ----------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/src/ConfigResolver.php
    -------------------------------------------------------------------------------------------------------
    FOUND 10 ERRORS AND 1 WARNING AFFECTING 11 LINES
    -------------------------------------------------------------------------------------------------------
    19 | ERROR | [x] You must use "/**" style comments for a member variable comment
    22 | ERROR | [x] You must use "/**" style comments for a member variable comment
    25 | ERROR | [x] You must use "/**" style comments for a member variable comment
    67 | ERROR | [x] Inline control structures are not allowed
    76 | ERROR | [x] Inline control structures are not allowed
    80 | WARNING | [ ] Line exceeds 80 characters; contains 87 characters
    81 | ERROR | [x] Inline control structures are not allowed
    84 | ERROR | [x] Inline control structures are not allowed
    107 | ERROR | [ ] Protected method name "ConfigResolver::isAConfigForm" is not in lowerCamel format
    153 | ERROR | [ ] Missing short description in doc comment
    154 | ERROR | [ ] Description for the @return value must be on the next line
    -------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/src/TargetModule.php
    ----------------------------------------------------------------------------------
    FOUND 6 ERRORS AFFECTING 5 LINES
    ----------------------------------------------------------------------------------
    19 | ERROR | [x] You must use "/**" style comments for a member variable comment
    22 | ERROR | [x] You must use "/**" style comments for a member variable comment
    27 | ERROR | [ ] Missing parameter comment
    27 | ERROR | [ ] Missing parameter type
    34 | ERROR | [ ] Missing short description in doc comment
    35 | ERROR | [ ] Description for the @return value is missing
    ----------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/src/ConfigImporter.php
    -------------------------------------------------------------------------------------------------------------------------------
    FOUND 12 ERRORS AND 5 WARNINGS AFFECTING 15 LINES
    -------------------------------------------------------------------------------------------------------------------------------
    27 | ERROR | [x] There should be no white space after an opening "{"
    27 | ERROR | [x] There should be no white space before a closing "}"
    29 | ERROR | [ ] Parameter $filenames is not described in comment
    32 | ERROR | [ ] Doc comment for parameter $filename does not match actual variable name $filenames
    46 | WARNING | [x] '@TODO log whether config has changed?' should match the format '@todo Fix problem X here.'
    46 | WARNING | [x] There must be no blank line following an inline comment
    51 | ERROR | [x] Missing function doc comment
    59 | WARNING | [x] '@TODO Log this to Drush too.' should match the format '@todo Fix problem X here.'
    76 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    77 | ERROR | [x] You must use "/**" style comments for a function comment
    81 | ERROR | [x] Expected newline after closing brace
    92 | ERROR | [x] Expected 1 space(s) after cast statement; 0 found
    101 | ERROR | [x] Expected newline after closing brace
    104 | ERROR | [x] Expected newline after closing brace
    123 | WARNING | [x] '@TODO: simplify this when' should match the format '@todo Fix problem X here.'
    146 | WARNING | [x] '@TODO log this?' should match the format '@todo Fix problem X here.'
    148 | ERROR | [x] Case breaking statements must be followed by a single blank line
    -------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 15 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/src/ConfigEnforceHelperTrait.php
    ------------------------------------------------------------------------------------
    FOUND 5 ERRORS AFFECTING 5 LINES
    ------------------------------------------------------------------------------------
    11 | ERROR | [x] Missing trait doc comment
    14 | ERROR | [x] Missing function doc comment
    18 | ERROR | [x] Missing function doc comment
    20 | ERROR | [x] Expected 1 blank line after function; 0 found
    21 | ERROR | [x] The closing brace for the trait must have an empty line before it
    ------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/src/EnforcedConfigCollection.php
    ----------------------------------------------------------------------------
    FOUND 6 ERRORS AFFECTING 6 LINES
    ----------------------------------------------------------------------------
    18 | ERROR | [ ] Missing member variable doc comment
    29 | ERROR | [ ] Missing short description in doc comment
    30 | ERROR | [ ] Description for the @return value is missing
    39 | ERROR | [x] Parameter comment must be on the next line
    43 | ERROR | [x] Inline control structures are not allowed
    56 | ERROR | [ ] Description for the @return value is missing
    ----------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------

    FILE: /home/vishal/Downloads/config_enforce/README.md
    ----------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------
    9 | ERROR | [x] Expected 1 newline at end of file; 2 found
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------

  • Status changed to Needs review almost 2 years ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update almost 2 years ago
    13 pass
Production build 0.71.5 2024