Skip to content

Conversation

@westonruter
Copy link
Member

@westonruter westonruter commented May 6, 2024

See #775.

This fixes the following PHPStan issues:

[ERROR] Found 11 errors
 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  Line   tests/includes/server-timing/perflab-server-timing-tests.php                                                                                                                                   
 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  111    Parameter #2 $args of method Perflab_Server_Timing::register_metric() expects array{measure_callback: callable(): mixed, access_cap: string}, array{access_cap: 'exist'} given.                
         💡 Array does not have offset 'measure_callback'.                                                                                                                                              
  122    Parameter #2 $args of method Perflab_Server_Timing::register_metric() expects array{measure_callback: callable(): mixed, access_cap: string}, array{measure_callback: '__return_null'} given.  
         💡 Array does not have offset 'access_cap'.                                                                                                                                                    
 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------ 
  Line   tests/includes/site-health/audit-autoloaded-options/audit-autoloaded-options-test.php                                                                             
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------ 
  27     Parameter #1 $tests of function perflab_aao_add_autoloaded_options_test expects array{direct: array<string, array{label: string, test: string}>}, array{} given.  
         💡 Array does not have offset 'direct'.                                                                                                                           
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------ 

 ------ ------------------------------------------------------------------------------------------------------------ 
  Line   tests/includes/site-health/audit-enqueued-assets/audit-enqueued-assets-helper-test.php                      
 ------ ------------------------------------------------------------------------------------------------------------ 
  93     Parameter #1 $resource_url of function perflab_aea_get_path_from_resource_url expects string, false given.  
 ------ ------------------------------------------------------------------------------------------------------------ 

 ------ --------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  Line   tests/includes/site-health/audit-enqueued-assets/audit-enqueued-assets-test.php                                                                                
 ------ --------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  168    Parameter #1 $tests of function perflab_aea_add_enqueued_assets_test expects array{direct: array<string, array{label: string, test: string}>}, array{} given.  
         💡 Array does not have offset 'direct'.                                                                                                                        
 ------ --------------------------------------------------------------------------------------------------------------------------------------------------------------- 

 ------ ---------------------------------------------------------------------------------- 
  Line   tests/plugins/auto-sizes/auto-sizes-test.php                                      
 ------ ---------------------------------------------------------------------------------- 
  49     Parameter #3 $icon of function wp_get_attachment_image expects bool, null given.  
  61     Parameter #3 $icon of function wp_get_attachment_image expects bool, null given.  
 ------ ---------------------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------------ 
  Line   tests/plugins/dominant-color-images/dominant-color-test.php                         
 ------ ------------------------------------------------------------------------------------ 
  237    Parameter #3 $icon of function wp_get_attachment_image expects bool, string given.  
 ------ ------------------------------------------------------------------------------------ 

 ------ --------------------------------------------------------------------------------------------------------------------------------------------- 
  Line   tests/plugins/webp-uploads/image-edit-tests.php                                                                                              
 ------ --------------------------------------------------------------------------------------------------------------------------------------------- 
  400    Parameter #2 $hashed_size_name of method PerformanceLab\Tests\TestCase\ImagesTestCase::assertSizeNameIsHashed() expects string, null given.  
 ------ --------------------------------------------------------------------------------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------------------------------------------ 
  Line   tests/plugins/webp-uploads/load-tests.php                                                                         
 ------ ------------------------------------------------------------------------------------------------------------------ 
  653    Parameter #1 $needle of method PHPUnit\Framework\Assert::assertStringContainsString() expects string, int given.  
  654    Parameter #1 $needle of method PHPUnit\Framework\Assert::assertStringContainsString() expects string, int given.  
 ------ ------------------------------------------------------------------------------------------------------------------ 

Please review individual commits for changes.

@westonruter westonruter added the [Type] Bug An existing feature is broken label May 6, 2024
@westonruter westonruter added this to the performance-lab 3.1.0 milestone May 6, 2024
@github-actions
Copy link

github-actions bot commented May 6, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: westonruter <[email protected]>
Co-authored-by: mukeshpanchal27 <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. LGTM.


$this->server_timing->register_metric(
'metric-without-measure-callback',
// @phpstan-ignore-next-line
Copy link
Member

Choose a reason for hiding this comment

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

Could you add note here why we ignore it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. Added in c588e58

Base automatically changed from update/phpstan-level-4 to trunk May 7, 2024 16:35
@westonruter westonruter merged commit 837ad90 into trunk May 7, 2024
Copy link
Member

@thelovekesh thelovekesh left a comment

Choose a reason for hiding this comment

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

LGTM!

level: 4
level: 5
treatPhpDocTypesAsCertain: false
rememberPossiblyImpureFunctionValues: false
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better if it had some doc reference on why this option was added?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops. Merged before I saw this. Yes, good idea. Added in 0cd8565. I'll add a commit to #1203 to explain.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in b86637e

@westonruter westonruter deleted the update/phpstan-level-5 branch May 7, 2024 16:43
@westonruter westonruter added the skip changelog PRs that should not be mentioned in changelogs label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip changelog PRs that should not be mentioned in changelogs [Type] Bug An existing feature is broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants