Commit 4b59d16861 for wordpress.org
commit 4b59d1686109b96e17a8749911b338fc0093c5e0
Author: westonruter <westonruter@git.wordpress.org>
Date: Wed Sep 23 16:42:49 2026 +0000
Code Quality: Fix an always-true comparison in `WP_Theme_JSON`.
In `WP_Theme_JSON::convert_variables_to_value()`, variable substitution was guarded by `0 <= strpos( $style, 'var(' )`, which is always true because `strpos()` returns `false` when the needle is absent, and `0 <= false` evaluates to `true`. This is replaced with `str_contains()`. There is no change in output, since the `preg_match_all()` call requires a literal `var(` to match anything; the only runtime difference is that the regular expression is no longer run on style values that contain no CSS variable.
This was the sole error suppressed in the `smallerOrEqual.alwaysTrue` PHPStan baseline, so that baseline file is deleted along with its entry in `phpstan.neon.dist`.
Developed in https://github.com/WordPress/wordpress-develop/pull/13675.
Follow-up to r55986, r63023.
Props som9663.
See #65817.
Fixes #66164.
Built from https://develop.svn.wordpress.org/trunk@63895
git-svn-id: http://core.svn.wordpress.org/trunk@63064 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/class-wp-theme-json.php b/wp-includes/class-wp-theme-json.php
index d61e8e2a91..704405af2b 100644
--- a/wp-includes/class-wp-theme-json.php
+++ b/wp-includes/class-wp-theme-json.php
@@ -5887,7 +5887,7 @@ class WP_Theme_JSON {
continue;
}
- if ( 0 <= strpos( $style, 'var(' ) ) {
+ if ( str_contains( $style, 'var(' ) ) {
// find all the variables in the string in the form of var(--variable-name, fallback), with fallback in the second capture group.
$has_matches = preg_match_all( '/var\(([^),]+)?,?\s?(\S+)?\)/', $style, $var_parts );
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 5f4d9392f8..4e953e8151 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-alpha-63890';
+$wp_version = '7.2-alpha-63895';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.