-
Notifications
You must be signed in to change notification settings - Fork 130
Update PHPStan level to 4 #1201
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
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
… update/phpstan-level-4 * 'trunk' of https://github.com/WordPress/performance: Fix offset does not exist on array in test Fix variable in empty() always exists and is not falsy Use function stub to override filtered return value typing Revert "Add typing for attachment metadata added by webp-uploads" Revert "Add typing for attachment metadata added by Dominant Color Images" Update comment to reference visibility instead of opacity Use visibility:hidden instead of opacity:0 Clarify Chromium behavior in comment Add optimization_detective_disabled query var to disable behavior Add pointer-events:none to the iframe Hide post embed iframes with opacity instead of clipping
02e26cd
to
80eb27e
Compare
$this->assertTrue( $this->server_timing->has_registered_metric( 'test-metric' ), 'Metric without cap should still be registered' ); | ||
$this->assertFalse( $called, 'Measure callback without cap must not be run' ); | ||
|
||
wp_set_current_user( self::$admin_id ); | ||
$this->server_timing->register_metric( 'test-metric-2', $args ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without passing the callback here, PHPStan isn't aware that the $called
variable could actually have changed so it complains:
Call to method PHPUnit\Framework\Assert::assertTrue() with false and 'Measure callback…' will always evaluate to false.
$this->assertArrayHasKey( 'full-orig', $backup_sizes ); | ||
$this->assertArrayHasKey( 'thumbnail-orig', $backup_sizes ); | ||
$this->assertArrayHasKey( 'medium-orig', $backup_sizes ); | ||
$this->assertArrayHasKey( 'medium_large-orig', $backup_sizes ); | ||
$this->assertArrayHasKey( 'large-orig', $backup_sizes ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without assertions like this, PHPStan complains about the foreach()
loop below being passed $backup_sizes
as an empty array.
@@ -489,9 +493,7 @@ public function it_should_store_the_next_image_hash_on_the_backup_sources() { | |||
$this->assertIsArray( $backup_sources ); | |||
$this->assertCount( 2, $backup_sources ); | |||
foreach ( array_keys( $backup_sources ) as $name ) { | |||
if ( 'full-orig' === $name ) { | |||
$this->assertSame( 'full-orig', $name ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clearly this will always be the same 😄
function perflab_server_timing_init(): void { | ||
perflab_server_timing(); | ||
} | ||
|
||
add_action( 'wp_loaded', 'perflab_server_timing_init' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just avoids the need to ignore the PHPStan error about an action callback returning a value.
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
See #775.
This fixes the following PHPStan issues:
[ERROR] Found 65 errors
Please review individual commits for changes.