Issues reported by phpstan

Created on 17 January 2024, 5 months ago
Updated 18 April 2024, 2 months ago

Problem/Motivation

Steps to reproduce

$ php vendor/bin/phpstan analyze $_WEB_ROOT/modules/custom/$CI_PROJECT_NAME $PHPSTAN_CONFIGURATION --no-progress || EXIT_CODE=$?
 ------ ------------------------------------------------------------------------------ 
  Line   src/Form/MessageSettingsForm.php                                              
 ------ ------------------------------------------------------------------------------ 
  59     Unsafe usage of new static().                                                 
         💡 See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
 ------ ------------------------------------------------------------------------------ 
 ------ ------------------------------------------------------------------------------ 
  Line   src/Form/MessageTemplateForm.php                                              
 ------ ------------------------------------------------------------------------------ 
  47     Unsafe usage of new static().                                                 
         💡 See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
 ------ ------------------------------------------------------------------------------ 
 ------ ---------------------------------------------------------------------- 
  Line   src/FormElement/MessageTemplateMultipleTextField.php                  
 ------ ---------------------------------------------------------------------- 
  52     \Drupal calls should be avoided in classes, use dependency injection  
         instead                                                               
  73     \Drupal calls should be avoided in classes, use dependency injection  
         instead                                                               
 ------ ---------------------------------------------------------------------- 
 ------ ------------------------------------------------------------------------------ 
  Line   src/MessageListBuilder.php                                                    
 ------ ------------------------------------------------------------------------------ 
  54     Unsafe usage of new static().                                                 
         💡 See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
  83     \Drupal calls should be avoided in classes, use dependency injection          
         instead                                                                       
 ------ ------------------------------------------------------------------------------ 
 ------ ------------------------------------------------------------------------------ 
  Line   src/MessagePurgeBase.php                                                      
 ------ ------------------------------------------------------------------------------ 
  67     Unsafe usage of new static().                                                 
         💡 See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
  80     Method Drupal\message\MessagePurgeBase::process() should return bool          
         but return statement is missing.                                              
 ------ ------------------------------------------------------------------------------ 
 ------ ------------------------------------------------------------------------------ 
  Line   src/MessageTemplateListBuilder.php                                            
 ------ ------------------------------------------------------------------------------ 
  43     Unsafe usage of new static().                                                 
         💡 See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
 ------ ------------------------------------------------------------------------------ 
 ------ ------------------------------------------------------------------------------ 
  Line   src/Plugin/MessagePurge/Days.php                                              
 ------ ------------------------------------------------------------------------------ 
  56     Unsafe usage of new static().                                                 
         💡 See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
 ------ ------------------------------------------------------------------------------ 
 ------ ------------------------------------------------------------------------------ 
  Line   src/Plugin/QueueWorker/MessageCheckAndDeleteWorker.php                        
 ------ ------------------------------------------------------------------------------ 
  56     Unsafe usage of new static().                                                 
         💡 See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
 ------ ------------------------------------------------------------------------------ 
 ------ ------------------------------------------------------------------------------ 
  Line   src/Plugin/QueueWorker/MessageDeletionWorker.php                              
 ------ ------------------------------------------------------------------------------ 
  53     Unsafe usage of new static().                                                 
         💡 See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
 ------ ------------------------------------------------------------------------------ 
 ------ -------------------------------------------------------------------------------------- 
  Line   src/Plugin/migrate/destination/MessageTemplateDestination.php                         
 ------ -------------------------------------------------------------------------------------- 
  23     Method                                                                                
         Drupal\message\Plugin\migrate\destination\MessageTemplateDestination::updateEntity()  
         should return Drupal\Core\Entity\EntityInterface but return statement                 
         is missing.                                                                           
 ------ -------------------------------------------------------------------------------------- 
 ------ ---------------------------------------------------------------------- 
  Line   src/Plugin/migrate/process/MessageTemplateProcessText.php             
 ------ ---------------------------------------------------------------------- 
  25     \Drupal calls should be avoided in classes, use dependency injection  
         instead                                                               
 ------ ---------------------------------------------------------------------- 
 [ERROR] Found 14 errors  

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇺🇸United States bluegeek9

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 @bluegeek9
  • First commit to issue fork.
  • Status changed to Needs review 5 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 5 months ago
    37 pass, 2 fail
  • 🇮🇳India Ashutosh Ahirwal India

    Fixes all the issue raised by phpcs need maintainer review for remaining issue.

    ./vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,css,js,yml web/modules/custom/message

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/message/message.module
    -----------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------
    229 | WARNING | Unused variable $message.
    -----------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/message/tests/src/Functional/MessageEntityDelete.php
    -----------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------------------------------------------
    172 | WARNING | Unused variable $delete_queue.
    174 | WARNING | Unused variable $check_delete_queue.
    -----------------------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/message/tests/src/Kernel/Plugin/MessagePurge/QuotaTest.php
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------
    69 | WARNING | Unused variable $i.
    -----------------------------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/message/modules/message_example/message_example.tokens.inc
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
    -----------------------------------------------------------------------------------------------------------------------------------
    65 | WARNING | Unused variable $token_service.
    70 | WARNING | Unused variable $langcode.
    73 | WARNING | Unused variable $langcode.
    75 | WARNING | Unused variable $sanitize.
    -----------------------------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/message/src/Form/MessageSettingsForm.php
    -----------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------
    145 | WARNING | Unused variable $entity_id.
    -----------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/message/src/Entity/MessageTemplate.php
    ---------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------
    353 | WARNING | Unused variable $id.
    ---------------------------------------------------------------------------------------------------------------

    Time: 1.13 secs; Memory: 14MB

  • 🇮🇳India Rohit Sankhla

    Fixed all the issues by phpstan which is listed in the description. Please review the patch.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 5 months ago
    37 pass, 2 fail
  • Status changed to Needs review 5 months ago
  • Status changed to Needs work 5 months ago
  • 🇺🇸United States bluegeek9

    Using @phpstan-consistent-constructor is not an acceptable solution.

  • 🇮🇳India Rohit Sankhla

    Removed @phpstan-consistent-constructor, added different solution. please verify.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 5 months ago
    30 pass, 8 fail
  • Status changed to Needs review 4 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 4 months ago
    38 pass
  • 🇮🇳India chaitanyadessai

    Fixed all phpcs errors.

  • Pipeline finished with Skipped
    3 months ago
    #138161
  • Status changed to Fixed 3 months ago
  • 🇺🇸United States bluegeek9
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024