Commit 389884f26a for wordpress.org
commit 389884f26afd9db2665390e293d2b34d8780f72b
Author: westonruter <westonruter@git.wordpress.org>
Date: Wed Sep 23 16:04:47 2026 +0000
Code Quality: Remove a redundant null coalescing operator.
In `wp_get_block_style_variation_name_from_class()`, the `?? null` fallback after `preg_match_all()` never applied, since `$matches[1]` is always populated with an array, even when there are no matches or the call fails. The now-empty `nullCoalesce.offset` PHPStan baseline is removed accordingly. The function's types are also refined: the parameter is documented as `string|null`, a native `?array` return type is added, and a conditional return type narrows the result to `list<non-empty-string>` when a string is passed.
Developed in https://github.com/WordPress/wordpress-develop/pull/13673.
Follow-up to r58264, r63023.
Props arshidkv12, westonruter, mukesh27.
See #65817.
Fixes #66162.
Built from https://develop.svn.wordpress.org/trunk@63890
git-svn-id: http://core.svn.wordpress.org/trunk@63062 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/block-supports/block-style-variations.php b/wp-includes/block-supports/block-style-variations.php
index 746ed38177..07b33ed36e 100644
--- a/wp-includes/block-supports/block-style-variations.php
+++ b/wp-includes/block-supports/block-style-variations.php
@@ -12,16 +12,17 @@
*
* @since 6.6.0
*
- * @param string $class_string CSS class string to look for a variation in.
- * @return array|null The block style variation name if found.
+ * @param string|null $class_string CSS class string to look for a variation in.
+ * @return string[]|null The block style variation names (empty if none found), or null if a string was not supplied.
+ * @phpstan-return ( $class_string is string ? list<non-empty-string> : null )
*/
-function wp_get_block_style_variation_name_from_class( $class_string ) {
+function wp_get_block_style_variation_name_from_class( $class_string ): ?array {
if ( ! is_string( $class_string ) ) {
return null;
}
preg_match_all( '/\bis-style-(?!default)(\S+)\b/', $class_string, $matches );
- return $matches[1] ?? null;
+ return $matches[1];
}
/**
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 9d8830a084..5f4d9392f8 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-alpha-63889';
+$wp_version = '7.2-alpha-63890';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.