ImageStyle::load calls should be avoided in classes, use dependency injection instead

Created on 13 June 2023, over 1 year ago
Updated 8 August 2024, 3 months ago

Used command with arguments is:-
phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml web/modules/custom/colorbox

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\colorbox\src\Plugin\Field\FieldFormatter\ColorboxFormatter.php
------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------------
463 | WARNING | ImageStyle::load calls should be avoided in classes, use dependency injection instead
485 | WARNING | ImageStyle::load calls should be avoided in classes, use dependency injection instead
492 | WARNING | ImageStyle::load calls should be avoided in classes, use dependency injection instead
------------------------------------------------------------------------------------------------------------------

🐛 Bug report
Status

Closed: duplicate

Version

2.0

Component

Code

Created by

🇮🇳India arti_parmar

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

  • Issue created by @arti_parmar
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update over 1 year ago
    4 pass
  • 🇮🇳India arti_parmar

    Kindly review patch.

  • Assigned to arpitk
  • 🇮🇳India arpitk

    Reviewing this.

  • Issue was unassigned.
  • Status changed to Needs work over 1 year ago
  • 🇮🇳India arpitk

    Hi the patch #2 applies cleanly and the error mentioned in the issue description is fixed. However the issue summary need to be updated with the command and the arguments used to check should be mentioned in the summary. Moving it to Needs Works.

    Thanks!

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India Ashutosh Ahirwal India

    Hi I have added command with arguments required for this issue in issue summary.
    Please have a look.

    Used command with arguments is:-
    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml web/modules/custom/colorbox

  • Status changed to Needs work over 1 year ago
  • 🇵🇭Philippines kenyoOwen

    Hi arti_parmar

    I applied patch #2 and confirmed that it fixed the phpcs issues mentioned in description, but it added a 1 warning which is:

    FILE: /Users/studenttrainees/Project10/drupalorg10/docroot/modules/contrib/colorbox/src/Plugin/Field/FieldFormatter/ColorboxFormatter.php
    -----------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------------
    14 | WARNING | [x] Unused use statement
    -----------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------------

    Time: 930ms; Memory: 14MB

    Please see the screenshots attached.

    Thank you.

  • Assigned to imustakim
  • 🇮🇳India imustakim Ahmedabad

    Patch updated.
    Please review.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update over 1 year ago
    2 fail
  • Status changed to Needs work about 1 year ago
  • 🇮🇳India Harsh

    The Patch "3366368-11" solves the phpcs reported issues as well as the issues mentioned in the comment number #6.Please review this patch.

  • Status changed to Needs review about 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    4 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    4 pass
  • 🇮🇳India aayushDrupal

    Hi Harsh,
    Your patch #11 has been successfully applied, but there are still some remaining errors. Please check the attached screenshot.

    I have fixed all the remaining errors in my patch #13. Please review.

  • Status changed to Closed: duplicate 3 months ago
  • 🇫🇷France dydave

    This issue has been addressed in related issue:

    Closing in favor of 📌 GitlabCI: Fix PHPCS validation errors Needs review .

    Thanks everyone for the great work on this issue!

Production build 0.71.5 2024