Code Quality: Add @phpstan-assert-if-true to is_wp_error().

This ensures PHPStan is aware that passing a `WP_Error` instance to `is_wp_error()` will cause the function to return `true`. This reduces the total number of PHPStan errors at rule level 7 from 14,271 to 13,233 (-1,038 or -7.27%). 

Developed in https://github.com/WordPress/wordpress-develop/pull/11095

See #64238.

Built from https://develop.svn.wordpress.org/trunk@61774


git-svn-id: http://core.svn.wordpress.org/trunk@61080 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter
2026-02-28 19:59:46 +00:00
parent 4bbdf78c53
commit 27c65a99cf
2 changed files with 3 additions and 1 deletions

View File

@@ -1798,6 +1798,8 @@ function wp_doing_cron() {
*
* @param mixed $thing The variable to check.
* @return bool Whether the variable is an instance of WP_Error.
*
* @phpstan-assert-if-true WP_Error $thing
*/
function is_wp_error( $thing ) {
$is_wp_error = ( $thing instanceof WP_Error );

View File

@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '7.0-beta2-61773';
$wp_version = '7.0-beta2-61774';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.