Fix the warnings/errors reported by PHP_CodeSniffer

Created on 6 July 2023, over 1 year ago
Updated 16 April 2024, 7 months ago

Resolve phpcs errors/warnings

📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇳India roshni27

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

Merge Requests

Comments & Activities

  • Issue created by @roshni27
  • Merge request !7fixes-errors-warning-phpcs → (Closed) created by roshni27
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India roshni27

    Some issues which are better know to maintainer are pending, for reading purpose character limits issues remain and all remaining issues solve by me. Please review the MR.

  • First commit to issue fork.
  • 🇳🇱Netherlands batigolix Utrecht

    I fixed the remaining phpcs issues.

    • e16b7159 committed on 8.x-1.x
      Issue #3372994 by roshni27, batigolix: Fix the warnings/errors reported...
  • 🇳🇱Netherlands batigolix Utrecht

    I tried to rebase the merge request but due to the recent changes this led to git conflicts and I could not safely resolve these.

    So I took the low hanging fruit phpcs fixes from your merge requests and committed these.

    This means there are 2 phpcs errors left that need to be fixed:

    FILE: /var/www/html/web/modules/contrib/country/src/Plugin/Field/FieldFormatter/CountryDefaultFormatter.php
    -----------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------
     27 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    -----------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/modules/contrib/country/src/Plugin/Field/FieldWidget/CountryAutocompleteWidget.php
    ----------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------
     37 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    ----------------------------------------------------------------------------------------------------------
    

    I close the merge request, and set this issue to Needs Work

  • Status changed to Needs work 11 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇳🇱Netherlands batigolix Utrecht
  • 🇳🇱Netherlands batigolix Utrecht
  • Assigned to nitin_lama
  • Merge request !10Resolve #3372994 "Fix the warningserrors" → (Open) created by nitin_lama
  • Status changed to Needs review 11 months ago
  • 🇮🇳India nitin_lama India

    Fixed issues. Please review.

  • Issue was unassigned.
  • Status changed to RTBC 11 months ago
  • 🇵🇭Philippines paraderojether

    Hi nitin_lama,

    I reviewed MR!10 and applied it against Country 8.x-1.x-dev with Drupal core version 10.1.7 and confirmed it fixes the issues reported by phpcs.

    I added screenshots for reference.
    Thank you.

  • Status changed to Needs work 11 months ago
  • 🇩🇪Germany sleitner

    public function getList() in CountryFieldManager should not be removed as long as it is used.

  • Status changed to Fixed 11 months ago
  • 🇳🇱Netherlands batigolix Utrecht

    I do not understand the changes proposed in this merge request. As I said in #8 : there are 2 phpcs errors that still need fixing. The changes in the latest MR are not related to phpcs.

    I will create a new issue for the remaining phpcs errors.

    If you think other issues need to be addressed, please create another issue.

    I will close this issue now, to prevent further confusion.

    Thanks for the efforts @apaderno, @sleitner and @nitin_lama

  • Status changed to Needs work 11 months ago
  • 🇳🇱Netherlands batigolix Utrecht
  • Status changed to Needs review 9 months ago
  • 🇮🇳India chaitanyadessai Goa

    @batigolix Addressed #8 please review patch.

  • Status changed to Needs work 8 months ago
  • 🇳🇱Netherlands arjenk

    This is starting to look very good. Just a couple of small remarks;

    +  public function __construct(CountryFieldManager $countryFieldManager) {
    +    $this->countryFieldManager = $countryFieldManager;
    +  }
    

    You will need to call the parent::__construct() here, otherwise the non overridden functions in FormatterBase are missing services. The current implementation breaks the settings of the field.

    +  public function __construct(CountryFieldManager $countryFieldManager) {
    +    $this->countryFieldManager = $countryFieldManager;
    +  }
    

    That means this will also needs more parameters.

    +  /**
    +   * {@inheritdoc}
    +   */
    

    Bonus points for replacing this with the correct parameter definitions.

  • Status changed to Needs review 8 months ago
  • 🇮🇳India chaitanyadessai Goa

    Please review Patch #22 addressed.

  • Status changed to Needs work 8 months ago
  • 🇳🇱Netherlands batigolix Utrecht

    If I go to /admin/structure/types/manage/article/form-display and switch from the Default Widget to the Autocomplete Widget, then I get this error:

    TypeError: Drupal\Core\Field\WidgetBase::__construct(): Argument #5 ($third_party_settings) must be of type array, null given, called in /var/www/html/web/modules/contrib/country/src/Plugin/Field/FieldWidget/CountryAutocompleteWidget.php on line 63 in Drupal\Core\Field\WidgetBase->__construct() (line 50 of /var/www/html/web/core/lib/Drupal/Core/Field/WidgetBase.php).

  • Assigned to chaitanyadessai
  • Issue was unassigned.
  • Status changed to Needs review 8 months ago
  • 🇮🇳India chaitanyadessai Goa

    Fixed Error mentioned in #24. please review updated patch, Thanks

    • c511f09c committed on 8.x-1.x
      Issue #3372994 by chaitanyadessai, nitin_lama, roshni27, batigolix,...
  • Status changed to Fixed 8 months ago
  • 🇳🇱Netherlands batigolix Utrecht

    I tested this and it works now. I committed this.

    Thanks everybody for their help

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

Production build 0.71.5 2024