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 diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index a0360ffdc8bf8..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; $index < count( $scripts ); $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; $index < count( $modules ); $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; $index < count( $styles ); $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 1517605bf4aa7..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; $spacing_sizes_count < count( $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 ); } } 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 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/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 ) { 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 ); } /**