From 2898a27dbd250bbf084dd214c28b7fd9e2bb39bd Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 6 Mar 2023 10:18:16 +0100 Subject: [PATCH 1/2] Add `@phpstan-assert` to `is_wp_error` --- functionMap.php | 1 + wordpress-stubs.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/functionMap.php b/functionMap.php index 1a505e16..c44b4c2a 100644 --- a/functionMap.php +++ b/functionMap.php @@ -65,4 +65,5 @@ 'WP_Block_List::offsetGet' => ['WP_Block|null', 'offset'=>'int'], 'WP_Block_List::offsetSet' => ['void', 'offset'=>'int|null'], 'WP_Block_List::offsetUnset' => ['void', 'offset'=>'int'], + 'is_wp_error' => ['bool', '@phpstan-assert-if-true'=>'\WP_Error $thing'] ]; diff --git a/wordpress-stubs.php b/wordpress-stubs.php index 9157cb6a..956ed348 100644 --- a/wordpress-stubs.php +++ b/wordpress-stubs.php @@ -110284,6 +110284,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 + * @phpstan-return bool */ function is_wp_error($thing) { From 17921126315e90d0849c3f41293a53ba139d5e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Mon, 6 Mar 2023 10:31:34 +0100 Subject: [PATCH 2/2] Raise PHPStan version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c71c1e58..ddaa9b54 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "nikic/php-parser": "< 4.12.0", "php-stubs/generator": "^0.8.3", "phpdocumentor/reflection-docblock": "^5.3", - "phpstan/phpstan": "^1.2" + "phpstan/phpstan": "^1.9" }, "suggest": { "paragonie/sodium_compat": "Pure PHP implementation of libsodium",