Fix all phpstan issues

Created on 30 August 2024, 6 months ago
Updated 12 September 2024, 5 months ago

Problem/Motivation

Mirror of https://github.com/Gizra/og/pull/767

📌 Task
Status

Closed: duplicate

Version

1.0

Component

og.module

Created by

🇦🇷Argentina dagmar Argentina

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

Merge Requests

Comments & Activities

  • Issue created by @dagmar
  • Merge request !14WIP: Fix phpstan issues → (Open) created by dagmar
  • Pipeline finished with Failed
    6 months ago
    Total: 465s
    #269742
  • 🇦🇷Argentina dagmar Argentina

    51 errors to go

    ------ ----------------------------------------------------------------------------------------------------------- 
      Line   Entity/OgMembership.php                                                                                    
     ------ ----------------------------------------------------------------------------------------------------------- 
      322    Parameter #2 $callback of function array_filter expects (callable(Drupal\og\OgRoleInterface): bool)|null,  
             Closure(Drupal\og\Entity\OgRole): bool given.                                                              
      325    Parameter #1 $callback of function array_map expects (callable(Drupal\og\OgRoleInterface): mixed)|null,    
             Closure(Drupal\og\Entity\OgRole): (int|string|null) given.                                                 
      401    Parameter #2 $callback of function array_filter expects (callable(Drupal\og\OgRoleInterface): bool)|null,  
             Closure(Drupal\og\Entity\OgRole): bool given.                                                              
      616    Call to an undefined method Drupal\Core\Entity\EntityInterface::getGroup().                                
     ------ ----------------------------------------------------------------------------------------------------------- 
    
     ------ ------------------------------------------------------------------------------------------------ 
      Line   MembershipManager.php                                                                           
     ------ ------------------------------------------------------------------------------------------------ 
      55     Interface Drupal\Core\Entity\EntityTypeManagerInterface referenced with incorrect case:         
             Drupal\core\Entity\EntityTypeManagerInterface.                                                  
      308    Parameter #1 $group of method Drupal\og\OgMembershipInterface::setGroup() expects               
             Drupal\Core\Entity\ContentEntityInterface, Drupal\Core\Entity\EntityInterface given.            
      355    Call to an undefined method Drupal\Core\Entity\EntityInterface::get().                          
      364    Call to an undefined method Drupal\Core\Entity\EntityInterface::get().                          
      472    Instanceof between int and Drupal\Core\Session\AccountInterface will always evaluate to false.  
             💡 Because the type is coming from a PHPDoc, you can turn off this check by setting             
                treatPhpDocTypesAsCertain: false in your phpstan.neon.                                       
      486    Instanceof between int and Drupal\Core\Session\AccountInterface will always evaluate to false.  
             💡 Because the type is coming from a PHPDoc, you can turn off this check by setting             
                treatPhpDocTypesAsCertain: false in your phpstan.neon.                                       
      498    Instanceof between int and Drupal\Core\Session\AccountInterface will always evaluate to false.  
             💡 Because the type is coming from a PHPDoc, you can turn off this check by setting             
                treatPhpDocTypesAsCertain: false in your phpstan.neon.                                       
      553    Method Drupal\og\MembershipManager::loadGroups() should return                                  
             array<array<Drupal\Core\Entity\ContentEntityInterface>> but returns                             
             array<array<Drupal\Core\Entity\EntityInterface>>.                                               
     ------ ------------------------------------------------------------------------------------------------ 
    
     ------ ----------------------------------------------------------------------------------------------------- 
      Line   Og.php                                                                                               
     ------ ----------------------------------------------------------------------------------------------------- 
      126    Method Drupal\og\Og::createField() should return Drupal\Core\Field\FieldConfigInterface but returns  
             Drupal\field\FieldConfigInterface.                                                                   
      185    Call to an undefined method Drupal\og\MembershipManagerInterface::getGroupMemberships().             
      205    Parameter #2 $user of method Drupal\og\MembershipManagerInterface::createMembership() expects        
             Drupal\user\UserInterface, Drupal\Core\Session\AccountInterface given.                               
     ------ ----------------------------------------------------------------------------------------------------- 
    
     ------ ------------------------------------------------------------------------------------------------------------- 
      Line   OgAccess.php                                                                                                 
     ------ ------------------------------------------------------------------------------------------------------------- 
      197    If condition is always true.                                                                                 
             💡 Because the type is coming from a PHPDoc, you can turn off this check by setting                          
                treatPhpDocTypesAsCertain: false in your phpstan.neon.                                                    
      249    Call to an undefined method Drupal\Core\Access\AccessResultInterface::addCacheTags().                        
      295    Call to method addCacheTags() on an unknown class Drupal\Core\Access\RefinableCacheableDependencyInterface.  
             💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                          
      295    PHPDoc tag @var for variable $result contains unknown class                                                  
             Drupal\Core\Access\RefinableCacheableDependencyInterface.                                                    
             💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                          
      319    Parameter #2 $group of class Drupal\og\Event\GroupContentEntityOperationAccessEvent constructor expects      
             Drupal\Core\Entity\ContentEntityInterface, Drupal\Core\Entity\EntityInterface given.                         
      319    Parameter #3 $groupContent of class Drupal\og\Event\GroupContentEntityOperationAccessEvent constructor       
             expects Drupal\Core\Entity\ContentEntityInterface, Drupal\Core\Entity\EntityInterface given.                 
     ------ ------------------------------------------------------------------------------------------------------------- 
    
     ------ --------------------------------------------------------------------------------------------------------------- 
      Line   OgRoleManager.php                                                                                              
     ------ --------------------------------------------------------------------------------------------------------------- 
      125    Method Drupal\og\OgRoleManager::getRequiredDefaultRoles() should return array<Drupal\og\Entity\OgRole> but     
             returns array<string, Drupal\Core\Entity\EntityInterface>.                                                     
      136    Method Drupal\og\OgRoleManager::getRolesByBundle() should return array<Drupal\og\OgRoleInterface> but returns  
             array<Drupal\Core\Entity\EntityInterface>.                                                                     
      165    Method Drupal\og\OgRoleManager::getRolesByPermissions() should return array<Drupal\og\OgRoleInterface> but     
             returns array<Drupal\Core\Entity\EntityInterface>.                                                             
      188    Negated boolean expression is always false.                                                                    
             💡 Because the type is coming from a PHPDoc, you can turn off this check by setting                            
                treatPhpDocTypesAsCertain: false in your phpstan.neon.                                                      
     ------ --------------------------------------------------------------------------------------------------------------- 
    
     ------ ---------------------------------------------------------------------------------------------------- 
      Line   PermissionManager.php                                                                               
     ------ ---------------------------------------------------------------------------------------------------- 
      61     Method Drupal\og\PermissionManager::getDefaultGroupPermissions() should return                      
             array<Drupal\og\GroupPermission> but returns array<Drupal\og\PermissionInterface>.                  
      81     Method Drupal\og\PermissionManager::getDefaultEntityOperationPermissions() should return            
             array<Drupal\og\GroupContentOperationPermission> but returns array<Drupal\og\PermissionInterface>.  
     ------ ---------------------------------------------------------------------------------------------------- 
    
     ------ ------------------------------------------------------------------------------------- 
      Line   Plugin/EntityReferenceSelection/OgSelection.php                                      
     ------ ------------------------------------------------------------------------------------- 
      121    Call to an undefined method                                                          
             Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface::buildEntityQuery().  
      150    If condition is always true.                                                         
      159    If condition is always true.                                                         
     ------ ------------------------------------------------------------------------------------- 
    
     ------ --------------------------------------------------------------------------------------------------------------- 
      Line   Plugin/Field/FieldFormatter/GroupSubscribeFormatter.php                                                        
     ------ --------------------------------------------------------------------------------------------------------------- 
      158    If condition is always true.                                                                                   
             💡 Because the type is coming from a PHPDoc, you can turn off this check by setting                            
                treatPhpDocTypesAsCertain: false in your phpstan.neon.                                                      
      193    Left side of && is always true.                                                                                
             💡 Because the type is coming from a PHPDoc, you can turn off this check by setting                            
                treatPhpDocTypesAsCertain: false in your phpstan.neon.                                                      
      193    Variable $access in PHPDoc tag @var does not exist.                                                            
      198    Left side of && is always true.                                                                                
             💡 Remove remaining cases below this one and this error will disappear too.                                    
      218    Offset 'title' on array{title: Drupal\Core\StringTranslation\TranslatableMarkup, url: Drupal\Core\Url, class:  
             array{'unsubscribe'}} in empty() always exists and is not falsy.                                               
     ------ --------------------------------------------------------------------------------------------------------------- 
    
     ------ -------------------------------------------------------------------------------------------------------- 
      Line   Plugin/Field/FieldWidget/OgComplex.php                                                                  
     ------ -------------------------------------------------------------------------------------------------------- 
      138    Call to an undefined method Drupal\Core\TypedData\TypedDataInterface::get().                            
      175    Access to an undefined property Drupal\Core\TypedData\TypedDataInterface::$_weight.                     
             💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                    
      285    Parameter #3 $weight_delta of method Drupal\og\Plugin\Field\FieldWidget\OgComplex::otherGroupsSingle()  
             expects int, float given.                                                                               
      305    Parameter #3 $weight_delta of method Drupal\og\Plugin\Field\FieldWidget\OgComplex::otherGroupsSingle()  
             expects int, float given.                                                                               
     ------ -------------------------------------------------------------------------------------------------------- 
    
     ------ --------------------------------------------------------------------------------------------------------------- 
      Line   Plugin/Validation/Constraint/UniqueOgMembershipConstraintValidator.php                                         
     ------ --------------------------------------------------------------------------------------------------------------- 
      56     Method Drupal\og\Plugin\Validation\Constraint\UniqueOgMembershipConstraintValidator::validate() has parameter  
             $value with no type specified.                                                                                 
      58     Variable $value in isset() always exists and is not nullable.                                                  
      89     Access to an undefined property Symfony\Component\Validator\Constraint::$notUniqueMembership.                  
             💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                           
     ------ --------------------------------------------------------------------------------------------------------------- 
    
     ------ --------------------------------------------------------------------------------------------------------------- 
      Line   Plugin/Validation/Constraint/ValidOgRoleConstraintValidator.php                                                
     ------ --------------------------------------------------------------------------------------------------------------- 
      18     Method Drupal\og\Plugin\Validation\Constraint\ValidOgRoleConstraintValidator::validate() has parameter $value  
             with no type specified.                                                                                        
      20     Variable $value in isset() always exists and is not nullable.                                                  
      25     Negated boolean expression is always false.                                                                    
             💡 Because the type is coming from a PHPDoc, you can turn off this check by setting                            
                treatPhpDocTypesAsCertain: false in your phpstan.neon.                                                      
      31     Call to an undefined method Drupal\Core\Entity\FieldableEntityInterface::getGroup().                           
      32     Call to an undefined method Drupal\Core\Entity\FieldableEntityInterface::getGroup().                           
      34     Call to an undefined method Drupal\Core\Field\FieldItemInterface::referencedEntities().                        
      36     Access to an undefined property Symfony\Component\Validator\Constraint::$notValidRole.                         
             💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                           
     ------ --------------------------------------------------------------------------------------------------------------- 
    
     ------ ----------------------------------------------------------------------------------------------------------- 
      Line   Plugin/views/argument_default/Group.php                                                                    
     ------ ----------------------------------------------------------------------------------------------------------- 
      77     Method Drupal\og\Plugin\views\argument_default\Group::buildOptionsForm() has parameter $form with no type  
             specified.                                                                                                 
      126    Method Drupal\og\Plugin\views\argument_default\Group::getGroup() should return                             
             Drupal\Core\Entity\ContentEntityInterface|null but return statement is missing.                            
     ------ ----------------------------------------------------------------------------------------------------------- 
    
     [ERROR] Found 51 errors                                                                                                
    
    
  • Pipeline finished with Failed
    6 months ago
    Total: 791s
    #276043
  • Status changed to Closed: duplicate 5 months ago
  • 🇷🇴Romania claudiu.cristea Arad 🇷🇴

    All those problems (plus Drupal 11 compatibility) are already addressed in 📌 Drupal 11 compatibility Needs review . Better review that issue instead of creating this new one. Marking this as duplicate of 📌 Drupal 11 compatibility Needs review .

Production build 0.71.5 2024