Problem/Motivation

PHPStan provides the following errors on 8.x-4.x which are likely because of automated version upgrades since our last commit on that branch.

 ------ ---------------------------------------------------------------------- 
  Line   src/Annotation/DataProducer.php                                       
 ------ ---------------------------------------------------------------------- 
  46     PHPDoc tag @throws with type                                          
         Doctrine\Common\Annotations\AnnotationException is not subtype of     
         Throwable                                                             
         🪪  throws.notThrowable                                               
  48     Instantiated class Doctrine\Common\Annotations\AnnotationException    
         not found.                                                            
         🪪  class.notFound                                                    
         💡  Learn more at https://phpstan.org/user-guide/discovering-symbols  
  48     Throwing object of an unknown class                                   
         Doctrine\Common\Annotations\AnnotationException.                      
         🪪  class.notFound                                                    
         💡  Learn more at https://phpstan.org/user-guide/discovering-symbols  
 ------ ---------------------------------------------------------------------- 
 ------ ---------------------------------------------------------------------- 
  Line   src/Annotation/PersistedQuery.php                                     
 ------ ---------------------------------------------------------------------- 
  46     PHPDoc tag @throws with type                                          
         Doctrine\Common\Annotations\AnnotationException is not subtype of     
         Throwable                                                             
         🪪  throws.notThrowable                                               
  48     Instantiated class Doctrine\Common\Annotations\AnnotationException    
         not found.                                                            
         🪪  class.notFound                                                    
         💡  Learn more at https://phpstan.org/user-guide/discovering-symbols  
  48     Throwing object of an unknown class                                   
         Doctrine\Common\Annotations\AnnotationException.                      
         🪪  class.notFound                                                    
         💡  Learn more at https://phpstan.org/user-guide/discovering-symbols  
 ------ ---------------------------------------------------------------------- 
 ------ ---------------------------------------------------------------------- 
  Line   src/Annotation/Schema.php                                             
 ------ ---------------------------------------------------------------------- 
  46     PHPDoc tag @throws with type                                          
         Doctrine\Common\Annotations\AnnotationException is not subtype of     
         Throwable                                                             
         🪪  throws.notThrowable                                               
  48     Instantiated class Doctrine\Common\Annotations\AnnotationException    
         not found.                                                            
         🪪  class.notFound                                                    
         💡  Learn more at https://phpstan.org/user-guide/discovering-symbols  
  48     Throwing object of an unknown class                                   
         Doctrine\Common\Annotations\AnnotationException.                      
         🪪  class.notFound                                                    
         💡  Learn more at https://phpstan.org/user-guide/discovering-symbols  
 ------ ---------------------------------------------------------------------- 
 ------ ---------------------------------------------------------------------- 
  Line   src/Annotation/SchemaExtension.php                                    
 ------ ---------------------------------------------------------------------- 
  62     PHPDoc tag @throws with type                                          
         Doctrine\Common\Annotations\AnnotationException is not subtype of     
         Throwable                                                             
         🪪  throws.notThrowable                                               
  64     Instantiated class Doctrine\Common\Annotations\AnnotationException    
         not found.                                                            
         🪪  class.notFound                                                    
         💡  Learn more at https://phpstan.org/user-guide/discovering-symbols  
  64     Throwing object of an unknown class                                   
         Doctrine\Common\Annotations\AnnotationException.                      
         🪪  class.notFound                                                    
         💡  Learn more at https://phpstan.org/user-guide/discovering-symbols  
 ------ ---------------------------------------------------------------------- 
 ------ -------------------------------------------------------------- 
  Line   src/Controller/ExplorerController.php                         
 ------ -------------------------------------------------------------- 
  104    Call to deprecated method get() of class                      
         Symfony\Component\HttpFoundation\Request:                     
         since Symfony 7.4, use properties `->attributes`, `query` or  
         `request` directly instead                                    
         🪪  method.deprecated                                         
  105    Call to deprecated method get() of class                      
         Symfony\Component\HttpFoundation\Request:                     
         since Symfony 7.4, use properties `->attributes`, `query` or  
         `request` directly instead                                    
         🪪  method.deprecated                                         
 ------ -------------------------------------------------------------- 
 [ERROR] Found 14 errors                                                        

Steps to reproduce

Proposed resolution

Address the deprecations; or ignore them and flag future incompatibility if we can only fix this on 5.x

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork graphql-3575931

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kingdutch created an issue. See original summary.

nickolaj made their first commit to this issue’s fork.

nickolaj’s picture

Status: Active » Needs review

Replaced `Doctrine\Common\Annotations\AnnotationException` with `\InvalidArgumentException` in all 4 annotation classes (no longer available as a dependency), and replaced deprecated `$request->get()` calls with `$request->query->get()` in `ExplorerController.php`.

kingdutch’s picture

Status: Needs review » Needs work

Thanks for your contribution nickolaj. To make sure we don't accidentally break 4.x the proposed changes need some work.

Depending on how we see the BC layer of this, changing out the exception to one that does not subclass the original can cause downstream code to fail in its error handling. Additionally https://www.drupal.org/node/3551049 leaves a more appropriate class in place than "InvalidArgumentException".

For the explorer we'll need to be sure that the explorer provides the query and variables as `$_GET` parameters (`query`) rather than `$_POST` parameters (`request`) and does not change the two depending on something. For example GraphQL requests outside of the explorer can be done using both GET and POST; so using only one parameter bag would not work.

nickolaj’s picture

Status: Needs work » Needs review

1. Replaced InvalidArgumentException with Drupal\Component\Annotation\Doctrine\AnnotationException as suggested — good point about preserving BC for downstream exception handling. Referenced #3551049 for the
appropriate Drupal core replacement.
2. Reverted ExplorerController changes entirely — you're right that $request->get() is the correct approach here since it covers both GET and POST parameter bags.

klausi’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me, thanks!

Leaving this for @Kingdutch to double-check and commit.

klausi’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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