Fix PHPstan issues

Created on 29 June 2024, 5 months ago
Updated 1 July 2024, 5 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

New arguments are added to the public constructors of GovUKNotifyMail and GovUKNotifyMessages.
The addWhere() methods are removed from the views filter plugins.

Data model changes

None.

📌 Task
Status

Needs review

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 → (Open) created by Eli-T
  • Status changed to Needs work 5 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 5 months ago
  • 🇬🇧United Kingdom Eli-T Manchester
Production build 0.71.5 2024