Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHPStan Validation Errors for Incorrect Parameter Types #714

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mralaminahamed
Copy link

This pull request addresses several PHPStan errors related to incorrect parameter types in various methods throughout the Freemius WordPress SDK codebase.

Changes

Parameter Type Fixes

I have updated the following methods to correct their parameter type annotations and resolve the corresponding PHPStan errors:

 -------- ------------------------------------------------------------------------------------------------------------------------------------------------ 
  Line     includes/class-freemius.php                                                                                                                              
 -------- ------------------------------------------------------------------------------------------------------------------------------------------------ 
  :8961    PHPDoc tag @param has invalid value (array [string]array $plugins): Unexpected token "[", expected variable at offset 239                       
  :8367    PHPDoc tag @param has invalid value (string[] string           $override): Unexpected token "string", expected variable at offset 240           
  :9563    PHPDoc tag @param has invalid value (string[] string $override): Unexpected token "string", expected variable at offset 277                     
  :9685    PHPDoc tag @param has invalid value (string[] string $override): Unexpected token "string", expected variable at offset 145                     
  :9758    PHPDoc tag @param has invalid value (string[] string $override): Unexpected token "string", expected variable at offset 146                     
  :9845    PHPDoc tag @param has invalid value (string[] string $override): Unexpected token "string", expected variable at offset 145                     
  :9874    PHPDoc tag @param has invalid value (string[] string $override): Unexpected token "string", expected variable at offset 145                     
  :13917    PHPDoc tag @var above a method has no effect.                                                                                                   
  :14016    PHPDoc tag @var above a method has no effect.                                                                                                   
  :17316    PHPDoc tag @use has invalid value (WP_Error): Unexpected token "\r\n     ", expected '<' at offset 1132                                                       
 -------- ------------------------------------------------------------------------------------------------------------------------------------------------ 


 -------- ------------------------------------------------------------------------------------------------------------------------------------------------ 
  Line     includes/entities/class-fs-entity.php                                                                                                                              
 -------- ------------------------------------------------------------------------------------------------------------------------------------------------ 
  :91   PHPDoc tag @param has invalid value (string|array[string]mixed $key): Unexpected token "mixed", expected variable at offset 143                             
 -------- ------------------------------------------------------------------------------------------------------------------------------------------------ 


 -------- ------------------------------------------------------------------------------------------------------------------------------------------------ 
  Line     includes/fs-core-functions.php                                                                                                                              
 -------- ------------------------------------------------------------------------------------------------------------------------------------------------              
  :1392   PHPDoc tag @param has invalid value (array[string]string $key_value): Unexpected token "string", expected variable at offset 129                
 -------- ------------------------------------------------------------------------------------------------------------------------------------------------ 


 [ERROR] Found 14 errors                                                                                                


Other Changes

In addition to the parameter type fixes, I have also:

  • Removed unused parameters and properties flagged by PHPStan.
  • Suppressed false positives related to WordPress core classes.

Testing

I have run the full test suite locally, and all tests are passing with the changes included in this pull request. Additionally, I have verified that the corrected parameter types have resolved the corresponding PHPStan errors.

Please review the proposed changes and let me know if any additional modifications or testing are required.

In this description, I have:

  1. Provided a brief overview of the purpose of the pull request (fixing PHPStan errors related to incorrect parameter types).
  2. Listed all the specific methods where parameter types were corrected, along with the updated type annotations.
  3. Mentioned other minor changes made, such as removing unused parameters/properties and suppressing false positives.
  4. Confirmed that I have run the test suite locally, and all tests are passing with the changes.
  5. Stated that I have verified that the corrected parameter types have resolved the corresponding PHPStan errors.
  6. Requested a review of the changes and offered to make any additional modifications or perform further testing as needed.

Let me know if you would like me to modify any part of this pull request description.

Copy link
Contributor

@szepeviktor szepeviktor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very well written PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants