Drupal Coding Standards Issues | phpcs

Created on 27 December 2022, about 2 years ago
Updated 22 January 2023, almost 2 years ago

Problem/Motivation

Getting following error/warnings

FILE: /app/modules/contrib/forward/forward.tokens.inc
----------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------
76 | WARNING | Only string literals should be passed to t() where possible
----------------------------------------------------------------------------

FILE: /app/modules/contrib/forward/src/Form/SettingsForm.php
-------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------------
92 | ERROR | The array declaration extends to column 99 (the limit is 80). The array content should be split up over multiple lines
-------------------------------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/forward/src/Services/ForwardLinkGenerator.php
---------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------
99 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
---------------------------------------------------------------------------------------------

Time: 2.34 secs; Memory: 16MB

Steps to reproduce

Run following command

phpcs --standard="Drupal,DrupalPractice" --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml modules/contrib/forward/

Proposed resolution

Above error/warnings need to be fixed

API changes

I removed following line of code form src/Services/ForwardLinkGenerator.php file. As these dependency injection arguments are provided from forward.services.yml file.

/**
 * {@inheritdoc}
 */
public static function create(ContainerInterface $container) {
  return new static(
    $container->get('link_generator'),
    $container->get('renderer'),
    $container->get('token'),
  );
}
🐛 Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

🇮🇳India samit.310@gmail.com

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.

Production build 0.71.5 2024