Update PHPStan 2.2.13 - #13410
Conversation
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| $safe_text = (string) preg_replace_callback( | ||
| $regex, | ||
| static function ( $matches ) { | ||
| if ( ! isset( $matches[0] ) ) { |
There was a problem hiding this comment.
fixes
4851 Call to function array_key_exists() with 0 and array{0: string, non_cdata_followed_by_cdata: '', 1: '', 2: '', cdata: '', 3: '', 4: '', non_cdata: string, ...}|array{0:
string, non_cdata_followed_by_cdata: string, 1: string, 2: string, cdata: non-falsy-string, 3: non-falsy-string, 4: non-falsy-string} will always evaluate to true.
🪪 function.alreadyNarrowedType
at src/wp-includes/formatting.php:4851
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
done |
| count: 2 | ||
| path: ../../../src/wp-includes/class-wp-embed.php | ||
| - | ||
| message: '#^Parameter \#1 \$handle of function curl_getinfo expects resource, \(resource\|false\) given\.$#' |
|
🤖 Comment by Claude Fable 5.1 Updated after 09218f6, which corrects the The baseline changes were analyzed to understand why each error appeared or disappeared between PHPStan 2.2.5 and 2.2.13. Both versions were run on the affected files with the baselines stripped, the output was diffed, each difference was bisected across 2.2.6 through 2.2.12, and each was reduced to a standalone repro. Summary
Removed errors
The three phpdoc-only checks. Core sets Added errorsThe sixth $v = $t->version;
if ( ! empty( $v ) ) { }
$w = $t->version; // silent in 2.2.5, reported in 2.2.13; reported in both without the empty() checkNarrowing the variable also narrowed the remembered expression, and the later fetch used that entry without reaching the undefined-property rule. This is not called out in the 2.2.6 notes; it fell out of the expression-handling fixes. The
|
wp_die() accepts an integer message, which the legacy Ajax handlers use for their -1/0/1 responses, and _wp_die_process_input() passes it through untouched since only a WP_Error is rewritten. Its docblock only admitted string|WP_Error, so the processed message was typed as a plain string and PHPStan 2.2.13 reported the is_string() and is_scalar() guards in the wp_die() handlers as always true. Type the parameter as string|WP_Error|int and the first element of the returned hash as string|int. The is_string() check in _default_wp_die_handler() is now reachable and leaves the baseline; the three is_scalar() entries remain, with their message updated to reflect the int|string type, since int|string is always scalar. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Recent PHPStan releases bring substantial performance improvements. The baselines are regenerated for the new version. The docblock of `_wp_die_process_input()` is also corrected to admit the integer message that `wp_die()` accepts for the legacy Ajax responses, which the helper passes through untouched. This removes a baseline entry for a guard in `_default_wp_die_handler()` that the incomplete type made look unreachable. Developed in #13410. Follow-up to r44666, r53144, r62703, r62798. Props markusstaab, westonruter. See #65817. Fixes #66051. git-svn-id: https://develop.svn.wordpress.org/trunk@63510 602fd350-edb4-49c9-b593-d223f7449a82
Recent PHPStan releases bring substantial performance improvements. The baselines are regenerated for the new version. The docblock of `_wp_die_process_input()` is also corrected to admit the integer message that `wp_die()` accepts for the legacy Ajax responses, which the helper passes through untouched. This removes a baseline entry for a guard in `_default_wp_die_handler()` that the incomplete type made look unreachable. Developed in WordPress/wordpress-develop#13410. Follow-up to r44666, r53144, r62703, r62798. Props markusstaab, westonruter. See #65817. Fixes #66051. Built from https://develop.svn.wordpress.org/trunk@63510 git-svn-id: http://core.svn.wordpress.org/trunk@62686 1a063a9b-81f0-0310-95a4-ce76da25c4cd
at PHPStan we worked hard to improve performance on recent releases. Updating the tooling makes sure Wordpress can use latest additions and get the best possible PHPStan experience
before this PR (PHPStan 2.2.5)
after this PR (PHPStan 2.2.13)
running on Macbook M4-Pro, PHP 8.5.10 (cli)
=> ~20 seconds faster (wall-time; cold result-cache)
https://core.trac.wordpress.org/ticket/66051