From caa04a507f1652e74a4004b8c2d6bee472316d85 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 30 Jul 2026 20:42:54 +0530 Subject: [PATCH 1/8] Editor, Themes: Evaluate count() once per loop instead of once per iteration. A `for` condition runs once per iteration plus once to terminate, so `$i < count( $array )` calls `count()` n + 1 times to walk an n-element array whose length never changes. Compute the bound in the loop initialiser instead, matching the idiom already used throughout core. `register_block_type_from_metadata()` is the main beneficiary: it runs for every registered block on every request, and the affected loops sit inside `foreach` blocks covering three script fields and three style fields each. In every case the iterated array is provably invariant across the loop body, so there is no behaviour change. Props mukesh. --- src/wp-includes/blocks.php | 6 +++--- src/wp-includes/class-wp-theme-json.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 41e11f4a2a75f..28a50b443781e 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -617,7 +617,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { $scripts = $metadata[ $metadata_field_name ]; $processed_scripts = array(); if ( is_array( $scripts ) ) { - for ( $index = 0; $index < count( $scripts ); $index++ ) { + for ( $index = 0, $script_count = count( $scripts ); $index < $script_count; $index++ ) { $result = register_block_script_handle( $metadata, $metadata_field_name, @@ -651,7 +651,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { $modules = $metadata[ $metadata_field_name ]; $processed_modules = array(); if ( is_array( $modules ) ) { - for ( $index = 0; $index < count( $modules ); $index++ ) { + for ( $index = 0, $module_count = count( $modules ); $index < $module_count; $index++ ) { $result = register_block_script_module_id( $metadata, $metadata_field_name, @@ -687,7 +687,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { $styles = $metadata[ $metadata_field_name ]; $processed_styles = array(); if ( is_array( $styles ) ) { - for ( $index = 0; $index < count( $styles ); $index++ ) { + for ( $index = 0, $style_count = count( $styles ); $index < $style_count; $index++ ) { $result = register_block_style_handle( $metadata, $metadata_field_name, diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index 82b8e89de509c..7545c7da8b170 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -5379,7 +5379,7 @@ public function set_spacing_sizes() { // If there are 7 or fewer steps in the scale revert to numbers for labels instead of t-shirt sizes. if ( $spacing_scale['steps'] <= 7 ) { - for ( $spacing_sizes_count = 0; $spacing_sizes_count < count( $spacing_sizes ); $spacing_sizes_count++ ) { + for ( $spacing_sizes_count = 0, $total_spacing_sizes = count( $spacing_sizes ); $spacing_sizes_count < $total_spacing_sizes; $spacing_sizes_count++ ) { $spacing_sizes[ $spacing_sizes_count ]['name'] = (string) ( $spacing_sizes_count + 1 ); } } From 79d89df844596674a32e03005c6dee6eb06c56ed Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Wed, 5 Aug 2026 21:39:15 +0530 Subject: [PATCH 2/8] Move count() out of the loop initialiser into a variable --- src/wp-includes/blocks.php | 9 ++++++--- src/wp-includes/class-wp-theme-json.php | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index d0834dbc5da4d..2b5ed62a74388 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -677,7 +677,8 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { $scripts = $metadata[ $metadata_field_name ]; $processed_scripts = array(); if ( is_array( $scripts ) ) { - for ( $index = 0, $script_count = count( $scripts ); $index < $script_count; $index++ ) { + $script_count = count( $scripts ); + for ( $index = 0; $index < $script_count; $index++ ) { $result = register_block_script_handle( $metadata, $metadata_field_name, @@ -711,7 +712,8 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { $modules = $metadata[ $metadata_field_name ]; $processed_modules = array(); if ( is_array( $modules ) ) { - for ( $index = 0, $module_count = count( $modules ); $index < $module_count; $index++ ) { + $module_count = count( $modules ); + for ( $index = 0; $index < $module_count; $index++ ) { $result = register_block_script_module_id( $metadata, $metadata_field_name, @@ -747,7 +749,8 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { $styles = $metadata[ $metadata_field_name ]; $processed_styles = array(); if ( is_array( $styles ) ) { - for ( $index = 0, $style_count = count( $styles ); $index < $style_count; $index++ ) { + $style_count = count( $styles ); + for ( $index = 0; $index < $style_count; $index++ ) { $result = register_block_style_handle( $metadata, $metadata_field_name, diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index f25927a29e9df..be77c486ce6f5 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -5379,7 +5379,8 @@ public function set_spacing_sizes() { // If there are 7 or fewer steps in the scale revert to numbers for labels instead of t-shirt sizes. if ( $spacing_scale['steps'] <= 7 ) { - for ( $spacing_sizes_count = 0, $total_spacing_sizes = count( $spacing_sizes ); $spacing_sizes_count < $total_spacing_sizes; $spacing_sizes_count++ ) { + $total_spacing_sizes = count( $spacing_sizes ); + for ( $spacing_sizes_count = 0; $spacing_sizes_count < $total_spacing_sizes; $spacing_sizes_count++ ) { $spacing_sizes[ $spacing_sizes_count ]['name'] = (string) ( $spacing_sizes_count + 1 ); } } From 6fe43d78264d9722e10e37d86c5f36652ac1d3a7 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Fri, 7 Aug 2026 19:12:29 +0000 Subject: [PATCH 3/8] Docs: Revert "Indicate absint() returns non-negative-int...". MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The introduction of a return-type annotation for `absint()` created fatal errors in cases where the function returns a `float` value. This resulted when the value passed into the function is smaller than `PHP_INT_MIN`. Since PHP’s `int` type is unable to represent the magnitude of that number in the positive, it returns a `float` value instead. Reverting the type annotation prevents the crashing, but additional follow-up is warranted to ensure that the function produces the expected return types. Developed in: https://github.com/WordPress/wordpress-develop/pull/12940 Discussed in: https://core.trac.wordpress.org/ticket/65826 Follow-up to [62647]. Props dmsnell, josephscott, westonruter. Fixes #65826. See #64898. git-svn-id: https://develop.svn.wordpress.org/trunk@63158 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/load.php | 3 +-- tests/phpstan/baselines/argument.type.neon | 15 +++++---------- .../baselines/notIdentical.alwaysTrue.neon | 5 ----- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/wp-includes/load.php b/src/wp-includes/load.php index ff68c084104f1..27c58b57dd671 100644 --- a/src/wp-includes/load.php +++ b/src/wp-includes/load.php @@ -1464,9 +1464,8 @@ function is_multisite() { * * @param mixed $maybeint Data you wish to have converted to a non-negative integer. * @return int A non-negative integer. - * @phpstan-return non-negative-int */ -function absint( $maybeint ): int { +function absint( $maybeint ) { return abs( (int) $maybeint ); } diff --git a/tests/phpstan/baselines/argument.type.neon b/tests/phpstan/baselines/argument.type.neon index 4415f515ba9e6..7618b79a4c615 100644 --- a/tests/phpstan/baselines/argument.type.neon +++ b/tests/phpstan/baselines/argument.type.neon @@ -56,12 +56,7 @@ parameters: - message: '#^Parameter \#1 \$text of function esc_attr expects string, int given\.$#' identifier: argument.type - count: 3 - path: ../../../src/wp-admin/edit-comments.php - - - message: '#^Parameter \#1 \$text of function esc_attr expects string, int\<0, max\> given\.$#' - identifier: argument.type - count: 1 + count: 4 path: ../../../src/wp-admin/edit-comments.php - message: '#^Parameter \#1 \$text of function esc_attr expects string, int\\|int\<1, max\> given\.$#' @@ -574,7 +569,7 @@ parameters: count: 5 path: ../../../src/wp-admin/nav-menus.php - - message: '#^Parameter \#2 \$menu_data of function wp_save_nav_menu_items expects array\, int\<0, max\> given\.$#' + message: '#^Parameter \#2 \$menu_data of function wp_save_nav_menu_items expects array\, int given\.$#' identifier: argument.type count: 1 path: ../../../src/wp-admin/nav-menus.php @@ -714,7 +709,7 @@ parameters: count: 1 path: ../../../src/wp-content/themes/twentyeleven/inc/theme-options.php - - message: '#^Parameter \#1 \$text of function esc_attr expects string, int\<0, max\> given\.$#' + message: '#^Parameter \#1 \$text of function esc_attr expects string, int given\.$#' identifier: argument.type count: 1 path: ../../../src/wp-content/themes/twentyeleven/inc/widgets.php @@ -779,7 +774,7 @@ parameters: count: 1 path: ../../../src/wp-content/themes/twentyfourteen/inc/widgets.php - - message: '#^Parameter \#1 \$text of function esc_attr expects string, int\<0, max\> given\.$#' + message: '#^Parameter \#1 \$text of function esc_attr expects string, int given\.$#' identifier: argument.type count: 1 path: ../../../src/wp-content/themes/twentyfourteen/inc/widgets.php @@ -809,7 +804,7 @@ parameters: count: 1 path: ../../../src/wp-content/themes/twentynineteen/template-parts/post/author-bio.php - - message: '#^Parameter \#1 \$text of function esc_attr expects string, int\<0, max\> given\.$#' + message: '#^Parameter \#1 \$text of function esc_attr expects string, int given\.$#' identifier: argument.type count: 1 path: ../../../src/wp-content/themes/twentyseventeen/inc/color-patterns.php diff --git a/tests/phpstan/baselines/notIdentical.alwaysTrue.neon b/tests/phpstan/baselines/notIdentical.alwaysTrue.neon index 5fed187271bfc..631833a87c3ee 100644 --- a/tests/phpstan/baselines/notIdentical.alwaysTrue.neon +++ b/tests/phpstan/baselines/notIdentical.alwaysTrue.neon @@ -18,11 +18,6 @@ parameters: ignoreErrors: - - - message: '#^Strict comparison using \!\=\= between ''all'' and int will always evaluate to true\.$#' - identifier: notIdentical.alwaysTrue - count: 1 - path: ../../../src/wp-admin/includes/class-wp-links-list-table.php - message: '#^Strict comparison using \!\=\= between null and string will always evaluate to true\.$#' identifier: notIdentical.alwaysTrue From 9410db423e7f8bc00cb7a09e35e4542c390d76aa Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 7 Aug 2026 23:30:12 +0000 Subject: [PATCH 4/8] Build/Test Tools: Extend the PHPUnit runner variable to the v1 and v2 workflows. This commit extends r62891 to the two older reusable PHPUnit workflows. That change added the `runs-on` override to `reusable-phpunit-tests-v3.yml` alone, so only branches calling that workflow can be redirected. Branches 4.7 through 5.1 call `reusable-phpunit-tests-v1.yml`, and branches 5.2 through 5.8 call `reusable-phpunit-tests-v2.yml`, both at `@trunk`. Neither reads the variable, so setting `RUNNERS_NAME` at the repository or organization level has no effect on those twelve branches. This applies the same one-line change to both files. With the variable unset, jobs run on `inputs.os` exactly as before, so there is no change by default. Each of the three reusable PHPUnit workflows contains exactly one `runs-on`, so no other line in these files needs the same treatment. Developed in https://github.com/WordPress/wordpress-develop/pull/12847. Follow-up to r62891, r62974, r63003. Props lancewillett. Fixes #65749. git-svn-id: https://develop.svn.wordpress.org/trunk@63159 602fd350-edb4-49c9-b593-d223f7449a82 --- .github/workflows/reusable-phpunit-tests-v1.yml | 2 +- .github/workflows/reusable-phpunit-tests-v2.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-phpunit-tests-v1.yml b/.github/workflows/reusable-phpunit-tests-v1.yml index bd720d7da30ca..13c87c62671f8 100644 --- a/.github/workflows/reusable-phpunit-tests-v1.yml +++ b/.github/workflows/reusable-phpunit-tests-v1.yml @@ -85,7 +85,7 @@ jobs: # - Run the PHPUnit tests. test-php: name: PHP ${{ inputs.php }} / ${{ inputs.multisite && ' Multisite' || 'Single site' }}${{ inputs.split_slow && ' slow tests' || '' }}${{ inputs.memcached && ' with memcached' || '' }} - runs-on: ${{ inputs.os }} + runs-on: ${{ vars.RUNNERS_NAME || inputs.os }} timeout-minutes: 20 permissions: contents: read diff --git a/.github/workflows/reusable-phpunit-tests-v2.yml b/.github/workflows/reusable-phpunit-tests-v2.yml index 84c05862d4a43..15dea5fc31efa 100644 --- a/.github/workflows/reusable-phpunit-tests-v2.yml +++ b/.github/workflows/reusable-phpunit-tests-v2.yml @@ -87,7 +87,7 @@ jobs: # - Ensures version-controlled files are not modified or deleted. test-php: name: PHP ${{ inputs.php }} / ${{ inputs.multisite && ' Multisite' || 'Single Site' }}${{ inputs.split_slow && ' slow tests' || '' }}${{ inputs.memcached && ' with memcached' || '' }} - runs-on: ${{ inputs.os }} + runs-on: ${{ vars.RUNNERS_NAME || inputs.os }} timeout-minutes: 20 permissions: contents: read From cdc5934c3ef1dffb6b3d322836b6ad80acd328bb Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 8 Aug 2026 00:45:30 +0000 Subject: [PATCH 5/8] Tests: Correct `@var` annotation in REST users controller tests. The `$query` variable comes from the `pre_user_query` filter args and is a `WP_User_Query` instance, the `assertInstanceOf( WP_User_Query::class, ... )` on the line above asserts exactly that. The docblock incorrectly declared it as `WP_User`. Developed in https://github.com/WordPress/wordpress-develop/pull/12834. Follow-up to r59899. Props Soean. See #64894. git-svn-id: https://develop.svn.wordpress.org/trunk@63160 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/rest-api/rest-users-controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php index b78e95b95f48d..86ec4b8048551 100644 --- a/tests/phpunit/tests/rest-api/rest-users-controller.php +++ b/tests/phpunit/tests/rest-api/rest-users-controller.php @@ -3283,7 +3283,7 @@ public function test_get_items_only_fetches_ids_for_head_requests( $method ) { $this->assertTrue( isset( $args[0][0] ), 'Query parameters were not captured.' ); $this->assertInstanceOf( WP_User_Query::class, $args[0][0], 'Query parameters were not captured.' ); - /** @var WP_User $query */ + /** @var WP_User_Query $query */ $query = $args[0][0]; if ( $is_head_request ) { From b2a04be77aeb3b3858768f7bd864d22bce48c96f Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Sun, 9 Aug 2026 21:32:11 +0530 Subject: [PATCH 6/8] Revert "Move count() out of the loop initialiser into a variable" This reverts commit 79d89df844596674a32e03005c6dee6eb06c56ed. --- src/wp-includes/blocks.php | 9 +++------ src/wp-includes/class-wp-theme-json.php | 3 +-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 2b5ed62a74388..d0834dbc5da4d 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -677,8 +677,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { $scripts = $metadata[ $metadata_field_name ]; $processed_scripts = array(); if ( is_array( $scripts ) ) { - $script_count = count( $scripts ); - for ( $index = 0; $index < $script_count; $index++ ) { + for ( $index = 0, $script_count = count( $scripts ); $index < $script_count; $index++ ) { $result = register_block_script_handle( $metadata, $metadata_field_name, @@ -712,8 +711,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { $modules = $metadata[ $metadata_field_name ]; $processed_modules = array(); if ( is_array( $modules ) ) { - $module_count = count( $modules ); - for ( $index = 0; $index < $module_count; $index++ ) { + for ( $index = 0, $module_count = count( $modules ); $index < $module_count; $index++ ) { $result = register_block_script_module_id( $metadata, $metadata_field_name, @@ -749,8 +747,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { $styles = $metadata[ $metadata_field_name ]; $processed_styles = array(); if ( is_array( $styles ) ) { - $style_count = count( $styles ); - for ( $index = 0; $index < $style_count; $index++ ) { + for ( $index = 0, $style_count = count( $styles ); $index < $style_count; $index++ ) { $result = register_block_style_handle( $metadata, $metadata_field_name, diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index 37054e7f21640..3431cc76d13ab 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -5386,8 +5386,7 @@ public function set_spacing_sizes() { // If there are 7 or fewer steps in the scale revert to numbers for labels instead of t-shirt sizes. if ( $spacing_scale['steps'] <= 7 ) { - $total_spacing_sizes = count( $spacing_sizes ); - for ( $spacing_sizes_count = 0; $spacing_sizes_count < $total_spacing_sizes; $spacing_sizes_count++ ) { + for ( $spacing_sizes_count = 0, $total_spacing_sizes = count( $spacing_sizes ); $spacing_sizes_count < $total_spacing_sizes; $spacing_sizes_count++ ) { $spacing_sizes[ $spacing_sizes_count ]['name'] = (string) ( $spacing_sizes_count + 1 ); } } From de2572b1da20f0fe6f53eebd6b8bf10ae066dd2f Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 9 Aug 2026 18:49:43 +0000 Subject: [PATCH 7/8] Tests: Use `assertNull()` instead of `assertSame()` with `null`. Using the dedicated `assertNull()` assertion instead of `assertSame( null, $actual )` clarifies intent and produces more descriptive failure messages. Developed in https://github.com/WordPress/wordpress-develop/pull/12818. Follow-up to r62969. Props Soean. See #64894. git-svn-id: https://develop.svn.wordpress.org/trunk@63161 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/functions/maybeSerialize.php | 2 +- tests/phpunit/tests/post/types.php | 2 +- tests/phpunit/tests/post/wpAfterInsertPost.php | 4 ++-- .../tests/rest-api/rest-settings-controller.php | 2 +- tests/phpunit/tests/theme/wpGetBlockCssSelector.php | 12 ++++++------ 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/tests/functions/maybeSerialize.php b/tests/phpunit/tests/functions/maybeSerialize.php index c7ee7179b5984..a4725217e5377 100644 --- a/tests/phpunit/tests/functions/maybeSerialize.php +++ b/tests/phpunit/tests/functions/maybeSerialize.php @@ -222,7 +222,7 @@ public function test_deserialize_request_utility_filtered_iterator_objects( $val } $callback_value = $property->getValue( $new_value ); - $this->assertSame( null, $callback_value ); + $this->assertNull( $callback_value ); } else { $this->assertSame( $value->count(), unserialize( $serialized )->count() ); } diff --git a/tests/phpunit/tests/post/types.php b/tests/phpunit/tests/post/types.php index 2c8564f22aeab..5ae45c67e1044 100644 --- a/tests/phpunit/tests/post/types.php +++ b/tests/phpunit/tests/post/types.php @@ -626,7 +626,7 @@ public function test_removing_autosave_support_removes_rest_api_controller() { remove_post_type_support( 'foo', 'autosave' ); $post_type_object = get_post_type_object( 'foo' ); - $this->assertSame( null, $post_type_object->get_autosave_rest_controller(), 'Autosave controller should be removed.' ); + $this->assertNull( $post_type_object->get_autosave_rest_controller(), 'Autosave controller should be removed.' ); _unregister_post_type( 'foo' ); } diff --git a/tests/phpunit/tests/post/wpAfterInsertPost.php b/tests/phpunit/tests/post/wpAfterInsertPost.php index c312096245af5..e853fcfa59bcd 100644 --- a/tests/phpunit/tests/post/wpAfterInsertPost.php +++ b/tests/phpunit/tests/post/wpAfterInsertPost.php @@ -157,7 +157,7 @@ public function test_new_post_via_wp_insert_post() { ) ); - $this->assertSame( null, self::$passed_post_before_status ); + $this->assertNull( self::$passed_post_before_status ); $this->assertSame( 'a new post', self::$passed_post_title ); } @@ -197,7 +197,7 @@ public function test_new_post_via_rest_controller() { ); rest_get_server()->dispatch( $request ); - $this->assertSame( null, self::$passed_post_before_title ); + $this->assertNull( self::$passed_post_before_title ); $this->assertSame( 'new title', self::$passed_post_title ); } diff --git a/tests/phpunit/tests/rest-api/rest-settings-controller.php b/tests/phpunit/tests/rest-api/rest-settings-controller.php index e8f90b53f20f1..981ca3dc684b6 100644 --- a/tests/phpunit/tests/rest-api/rest-settings-controller.php +++ b/tests/phpunit/tests/rest-api/rest-settings-controller.php @@ -794,6 +794,6 @@ public function test_provides_setting_metadata_in_schema() { $this->assertSame( 'string', $title['type'] ); $this->assertSame( 'Title', $title['title'] ); $this->assertSame( 'Site title.', $title['description'] ); - $this->assertSame( null, $title['default'] ); + $this->assertNull( $title['default'] ); } } diff --git a/tests/phpunit/tests/theme/wpGetBlockCssSelector.php b/tests/phpunit/tests/theme/wpGetBlockCssSelector.php index d52dff978998c..e382217640b4d 100644 --- a/tests/phpunit/tests/theme/wpGetBlockCssSelector.php +++ b/tests/phpunit/tests/theme/wpGetBlockCssSelector.php @@ -131,7 +131,7 @@ public function test_no_feature_level_selector_via_selectors_api() { ); $selector = wp_get_block_css_selector( $block_type, 'typography' ); - $this->assertSame( null, $selector ); + $this->assertNull( $selector ); } /** @@ -205,7 +205,7 @@ public function test_no_feature_selector_via_experimental_property() { ); $selector = wp_get_block_css_selector( $block_type, 'typography' ); - $this->assertSame( null, $selector ); + $this->assertNull( $selector ); } /** @@ -262,7 +262,7 @@ public function test_no_subfeature_level_selector_via_selectors_api() { ); $selector = wp_get_block_css_selector( $block_type, array( 'typography', 'fontSize' ) ); - $this->assertSame( null, $selector ); + $this->assertNull( $selector ); } /** @@ -297,7 +297,7 @@ public function test_no_subfeature_selector_via_experimental_property() { $block_type, array( 'typography', 'fontSize' ) ); - $this->assertSame( null, $selector ); + $this->assertNull( $selector ); } /** @@ -311,10 +311,10 @@ public function test_empty_target_returns_null() { ); $selector = wp_get_block_css_selector( $block_type, array() ); - $this->assertSame( null, $selector ); + $this->assertNull( $selector ); $selector = wp_get_block_css_selector( $block_type, '' ); - $this->assertSame( null, $selector ); + $this->assertNull( $selector ); } /** From 6ef4db2d2d42968ccd74cd680169469075640990 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Mon, 10 Aug 2026 09:15:41 +0530 Subject: [PATCH 8/8] Apply suggestions from code review Co-authored-by: Weston Ruter --- src/wp-includes/blocks.php | 6 +++--- src/wp-includes/class-wp-theme-json.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index d0834dbc5da4d..f2df7226a6d78 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -677,7 +677,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { $scripts = $metadata[ $metadata_field_name ]; $processed_scripts = array(); if ( is_array( $scripts ) ) { - for ( $index = 0, $script_count = count( $scripts ); $index < $script_count; $index++ ) { + for ( $index = 0, $length = count( $scripts ); $index < $length; $index++ ) { $result = register_block_script_handle( $metadata, $metadata_field_name, @@ -711,7 +711,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { $modules = $metadata[ $metadata_field_name ]; $processed_modules = array(); if ( is_array( $modules ) ) { - for ( $index = 0, $module_count = count( $modules ); $index < $module_count; $index++ ) { + for ( $index = 0, $length = count( $modules ); $index < $length; $index++ ) { $result = register_block_script_module_id( $metadata, $metadata_field_name, @@ -747,7 +747,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { $styles = $metadata[ $metadata_field_name ]; $processed_styles = array(); if ( is_array( $styles ) ) { - for ( $index = 0, $style_count = count( $styles ); $index < $style_count; $index++ ) { + for ( $index = 0, $length = count( $styles ); $index < $length; $index++ ) { $result = register_block_style_handle( $metadata, $metadata_field_name, diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index 3431cc76d13ab..7175d7a88747d 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -5386,7 +5386,7 @@ public function set_spacing_sizes() { // If there are 7 or fewer steps in the scale revert to numbers for labels instead of t-shirt sizes. if ( $spacing_scale['steps'] <= 7 ) { - for ( $spacing_sizes_count = 0, $total_spacing_sizes = count( $spacing_sizes ); $spacing_sizes_count < $total_spacing_sizes; $spacing_sizes_count++ ) { + for ( $spacing_sizes_count = 0, $spacing_sizes_length = count( $spacing_sizes ); $spacing_sizes_count < $spacing_sizes_length; $spacing_sizes_count++ ) { $spacing_sizes[ $spacing_sizes_count ]['name'] = (string) ( $spacing_sizes_count + 1 ); } }