Fix PHPstan issues

Created on 29 June 2024, 10 months ago
Updated 30 June 2024, 10 months ago

Problem/Motivation

There are PHPStan issues. We should fix them.

Steps to reproduce

Run pipeline.

Proposed resolution

Fix issues.

Remaining tasks

All the things.

User interface changes

None.

API changes

None hopefully.

Data model changes

None.

📌 Task
Status

Active

Version

3.1

Component

Code

Created by

🇬🇧United Kingdom Eli-T Manchester

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

Merge Requests

Comments & Activities

  • Issue created by @Eli-T
  • Merge request !9#3458026: 🚨 fix PHPStan issues → (Merged) created by Eli-T
  • Status changed to Needs work 10 months ago
  • 🇬🇧United Kingdom Eli-T Manchester

    Note commit 57b0b5ac adds arguments to the public contstructor of the GovUKNotifyMail plugin, which breaks BC.

  • 🇬🇧United Kingdom Eli-T Manchester
  • 🇬🇧United Kingdom Eli-T Manchester

    The remaining phpstan warnings are duplicated across the three views filter plugins in this repeated function

      /**
       * {@inheritdoc}
       */
      public function addWhere($group, $field, $value = NULL, $operator = NULL) {
        // Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all
        // the default group.
        if (empty($group)) {
          $group = 0;
        }
        // Check for a group.
        if (!isset($this->where[$group])) {
          $this->setWhereGroup('AND', $group);
        }
        $this->where[$group]['conditions'][] = [
          'field' => $field,
          'value' => $value,
          'operator' => $operator,
        ];
      }

    The phpstan warnings are

     ------ ---------------------------------------------------------------------------- 
      Line   modules/govuk_notify_views_backend/src/Plugin/views/filter/Id.php           
     ------ ---------------------------------------------------------------------------- 
      42     Call to an undefined method                                                 
             Drupal\govuk_notify_views_backend\Plugin\views\filter\Id::setWhereGroup().  
      44     Access to an undefined property                                             
             Drupal\govuk_notify_views_backend\Plugin\views\filter\Id::$where.           
             💡 Learn more:                                                              
                https://phpstan.org/blog/solving-phpstan-access-to-undefined-property    
     ------ ---------------------------------------------------------------------------- 
  • 🇬🇧United Kingdom Eli-T Manchester
  • Status changed to Needs review 10 months ago
  • 🇬🇧United Kingdom Eli-T Manchester
  • 🇬🇧United Kingdom Eli-T Manchester
  • 🇬🇧United Kingdom Eli-T Manchester
    • eli-t committed f470d572 on 3.1.x
      #3458026: 🚨  fix PHPStan issues, fix admin form on D11, and set lowest...
Production build 0.71.5 2024