Fix the issues reported by phpcs

Created on 31 October 2019, about 5 years ago
Updated 20 October 2023, about 1 year ago

Problem/Motivation

Currently, the module does not respect coding standards.

Proposed resolution

Launch phpcs and fix the errors.
phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info entity_staging

FILE: entity_staging.drush.inc
-------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------
 34 | ERROR | [x] Missing function doc comment
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------


FILE: src/Form/EntityStagingForm.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 8 WARNINGS AFFECTING 9 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
  17 | ERROR   | [ ] Missing short description in doc comment
  66 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  67 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  68 | WARNING | [x] A comma should follow the last multiline array item. Found: '../staging'
  74 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  75 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  82 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  93 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 105 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------


FILE: src/EntityStagingExport.php
----------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------------
 147 | ERROR | [ ] Description for the @return value is missing
 203 | ERROR | [x] Data types in @var tags need to be fully namespaced
----------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------


FILE: src/EntityStagingImport.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 11 ERRORS AND 1 WARNING AFFECTING 10 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
 116 | ERROR   | [ ] Missing parameter comment
 116 | ERROR   | [ ] Missing parameter type
 117 | ERROR   | [ ] Missing parameter comment
 118 | ERROR   | [ ] Missing parameter comment
 118 | ERROR   | [ ] Missing parameter type
 119 | ERROR   | [ ] Missing parameter comment
 136 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 172 | ERROR   | [ ] Missing parameter type
 174 | ERROR   | [ ] Missing parameter type
 179 | ERROR   | [ ] Description for the @return value is missing
 181 | ERROR   | [ ] Type hint "null" missing for $language
 199 | ERROR   | [x] Data types in @var tags need to be fully namespaced
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------


FILE: src/Plugin/migrate/source/EntityStagingJson.php
------------------------------------------------------------------------------------------------------
FOUND 10 ERRORS AFFECTING 9 LINES
------------------------------------------------------------------------------------------------------
  23 | ERROR | [ ] Class property $input_path should use lowerCamel naming without underscores
  26 | ERROR | [x] Function comment short description must start with exactly one space
  26 | ERROR | [x] Doc comment short description must end with a full stop
  30 | ERROR | [ ] Class property $staging_directory should use lowerCamel naming without underscores
 109 | ERROR | [x] Array indentation error, expected 8 spaces but found 10
 110 | ERROR | [x] Array indentation error, expected 8 spaces but found 10
 111 | ERROR | [x] Array indentation error, expected 8 spaces but found 10
 112 | ERROR | [x] Array indentation error, expected 8 spaces but found 10
 113 | ERROR | [x] Array indentation error, expected 8 spaces but found 10
 114 | ERROR | [x] Array closing indentation error, expected 6 spaces but found 8
------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------


FILE: src/EntityStagingManager.php
-----------------------------------------------------------------------------
FOUND 11 ERRORS AND 1 WARNING AFFECTING 12 LINES
-----------------------------------------------------------------------------
  65 | ERROR   | Description for the @return value is missing
  81 | ERROR   | Parameter $allowed_only is not described in comment
  87 | ERROR   | Description for the @return value is missing
 103 | ERROR   | Description for the @return value is missing
 123 | ERROR   | Description for the @return value is missing
 135 | ERROR   | Type hint "array" missing for $entity_types
 143 | ERROR   | Missing parameter type
 146 | ERROR   | Description for the @return value is missing
 158 | WARNING | Line exceeds 80 characters; contains 88 characters
 160 | ERROR   | Missing parameter type
 162 | ERROR   | Missing parameter type
 165 | ERROR   | Description for the @return value is missing
-----------------------------------------------------------------------------


FILE: src/EventSubscriber/EntityStagingProcessFileUriFieldSubscriber.php
-------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------------
 29 | ERROR   | [ ] Missing parameter comment
 44 | WARNING | [x] A comma should follow the last multiline array item. Found: $process_field
-------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------


FILE: src/EventSubscriber/EntityStagingProcessRevisionFieldSubscriber.php
--------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
--------------------------------------------------------------------------------------------------------------------
 28 | ERROR   | [ ] Missing parameter comment
 36 | WARNING | [x] A comma should follow the last multiline array item. Found: )
--------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------


FILE: src/EventSubscriber/EntityStagingExportUserSubscriber.php
----------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------
 28 | ERROR | Missing parameter comment
----------------------------------------------------------------------------------------------------------


FILE: src/EventSubscriber/EntityStagingProcessMenuLinkContentParentFieldSubscriber.php
---------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
---------------------------------------------------------------------------------------------------------------------------------
 29 | ERROR   | [ ] Missing parameter comment
 44 | WARNING | [x] A comma should follow the last multiline array item. Found: $process_field
---------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------


FILE: src/EventSubscriber/EntityStagingProcessEntityReferenceRevisionFieldSubscriber.php
-----------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES
-----------------------------------------------------------------------------------------------------------------------------------
 13 | WARNING | [ ] Line exceeds 80 characters; contains 82 characters
 46 | ERROR   | [ ] Missing parameter comment
 70 | WARNING | [x] A comma should follow the last multiline array item. Found: $process_field
-----------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------


FILE: src/EventSubscriber/EntityStagingProcessUuidFieldSubscriber.php
----------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------
 28 | ERROR | Missing parameter comment
----------------------------------------------------------------------------------------------------------------


FILE: src/EventSubscriber/EntityStagingProcessImageAndFileReferenceFieldSubscriber.php
---------------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AND 1 WARNING AFFECTING 4 LINES
---------------------------------------------------------------------------------------------------------------------------------
 28 | ERROR   | [ ] Missing parameter comment
 51 | WARNING | [x] A comma should follow the last multiline array item. Found: $process_field
 80 | ERROR   | [x] Array indentation error, expected 12 spaces but found 14
 80 | ERROR   | [x] Object operator not indented correctly; expected 12 spaces but found 14
 83 | ERROR   | [x] Array indentation error, expected 12 spaces but found 14
 83 | ERROR   | [x] Object operator not indented correctly; expected 12 spaces but found 14
---------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------


FILE: src/EventSubscriber/EntityStagingProcessEntityReferenceFieldSubscriber.php
-------------------------------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AND 3 WARNINGS AFFECTING 6 LINES
-------------------------------------------------------------------------------------------------------------------------------
  57 | ERROR   | [ ] Missing parameter comment
  64 | WARNING | [ ] Unused variable $dependencies.
  66 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
  70 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
  78 | WARNING | [ ] Line exceeds 80 characters; contains 88 characters
  78 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 108 | WARNING | [x] A comma should follow the last multiline array item. Found: $process_field
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------


FILE: src/EventSubscriber/EntityStagingProcessFieldSubscriber.php
------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------
 28 | ERROR | Missing parameter comment
------------------------------------------------------------------------------------------------------------


FILE: src/EventSubscriber/EntityStagingProcessTimestampFieldSubscriber.php
------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------------------------------
 28 | ERROR   | [ ] Missing parameter comment
 31 | ERROR   | [ ] If the line declaring an array spans longer than 80 characters, each element should be broken into its own line
 41 | WARNING | [x] A comma should follow the last multiline array item. Found: $process_field
------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------


FILE: src/Event/EntityStagingProcessFieldDefinitionEvent.php
-------------------------------------------------------------------------------------------------------
FOUND 8 ERRORS AFFECTING 8 LINES
-------------------------------------------------------------------------------------------------------
  36 | ERROR | [x] Doc comment short description must end with a full stop
  38 | ERROR | [x] Expected "array" but found "array;" for @var tag in member variable comment
  49 | ERROR | [ ] Parameter $field_definition is not described in comment
  54 | ERROR | [ ] Missing parameter type
  66 | ERROR | [ ] Description for the @return value is missing
 115 | ERROR | [ ] Description for the @return value is missing
 129 | ERROR | [x] Expected 1 blank line after function; 0 found
 130 | ERROR | [x] The closing brace for the class must have an empty line before it
-------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------


FILE: src/Event/EntityStagingBeforeExportEvent.php
---------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
---------------------------------------------------------------------------------------------
 36 | ERROR | [ ] Missing parameter type
 41 | ERROR | [x] Parameter comment must end with a full stop
 85 | ERROR | [ ] Type hint "array" missing for $entities
---------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------
📌 Task
Status

Fixed

Version

2.0

Component

Code

Created by

🇫🇷France goz

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

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.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +   * @param string $bundle_id
    +   *   The bundle id.

    id is misspelled.

    +   * @param string $bundle_label
    +   *   The name of the bundle.

    It is sufficient to say The bundle label.

    -        /** @var EntityStagingProcessFieldDefinitionEvent $event */
    +        /* @var \Drupal\entity_staging\Event\EntityStagingProcessFieldDefinitionEvent $event */

    The existing comment is correct.

    +   * @param string $entity_type
        *   The entity type machine name.

    There is no need to say machine name.

        * @return \Drupal\Core\Entity\ContentEntityTypeInterface
    +   *   The entity type.

    It actually return an entity, not an entity type.

       * @return array
    +   *   Migration Dependencies.
        */

    Dependencies is misspelled, since it is not at the beginning of the sentence.

        * @param \Drupal\entity_staging\Event\EntityStagingBeforeExportEvent $event
    +   *   Field Definition Event.

    It is missing an article.
    There are misspelled words, since they are not at the beginning of the sentence. (Only the first word is at the beginning of the sentence.)

    -      '#title' => t('Entity staging directory'),
    -      '#description' => t('Directory where the content will be exported. This directory is relative to the drupal root.'),
    -      '#default_value' => ($staging_directory) ? $staging_directory : '../staging'
    +      '#title' => $this->t('Entity staging directory'),
    +      '#description' => $this->t('Directory where the content will be exported. This directory is relative to the drupal root.'),
    +      '#default_value' => ($staging_directory) ? $staging_directory : '../staging',

    The code should use the null coalescing operator.

       /**
    -   *  Get staging directory
    +   * Get staging directory.
        *
        * @var string
        */
    -  protected $staging_directory;

    The short descriptions for properties do not start with Get.

           if (in_array($key, [
    -          'type',
    -          'shortcut_set',
    -          'vid',
    -          'bundle',
    -          'queue',
    -        ]) && isset($item['target_id'])) {
    +        'type',
    +        'shortcut_set',
    +        'vid',
    +        'bundle',
    +        'queue',
    +      ]) && isset($item['target_id'])) {
             $value = $item['target_id'];
           }

    The Drupal coding standards says that control structures are written on a single line.

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India sakthi_dev

    Please review. Addressed the comments in #15.

  • 🇫🇷France goz
    1. +++ b/src/EventSubscriber/EntityStagingProcessEntityReferenceFieldSubscriber.php
      @@ -55,27 +55,27 @@ class EntityStagingProcessEntityReferenceFieldSubscriber implements EventSubscri
      -          $dependencies[] = $migration;
      ...
      -      // Spacial case for entity types with bundle but without bundles in field settings
      

      This should not be changed, there is nothing to do with phpcs reports

    2. +++ b/src/Plugin/migrate/source/EntityStagingJson.php
      @@ -20,23 +20,23 @@ class EntityStagingJson extends SourcePluginBase {
      +  protected $inputPath;
      

      Variable should not be renamed, there is no rules on that on phpcs

    3. +++ b/src/Plugin/migrate/source/EntityStagingJson.php
      @@ -20,23 +20,23 @@ class EntityStagingJson extends SourcePluginBase {
      +  protected $stagingDirectory;
      

      Variable should not be renamed, there is no rules on that on phpcs

  • Assigned to goz
  • 🇫🇷France goz

    I'm working on this to commit fixes

  • 🇫🇷France goz

    Move to 2.0.x, since 8.x-1.x will not be supported anymore

  • 🇫🇷France goz

    +++ b/src/Plugin/migrate/source/EntityStagingJson.php
    @@ -20,23 +20,23 @@ class EntityStagingJson extends SourcePluginBase {
    + protected $inputPath;

    Variable should not be renamed, there is no rules on that on phpcs

    +++ b/src/Plugin/migrate/source/EntityStagingJson.php
    @@ -20,23 +20,23 @@ class EntityStagingJson extends SourcePluginBase {
    + protected $stagingDirectory;

    My bad, there is lowerCamel rule

  • @goz opened merge request.
  • Status changed to Fixed about 1 year ago
  • 🇫🇷France goz

    Thanks all of you

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

Production build 0.71.5 2024