Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/reusable-phpunit-tests-v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-phpunit-tests-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/wp-includes/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/class-wp-theme-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/wp-includes/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down
15 changes: 5 additions & 10 deletions tests/phpstan/baselines/argument.type.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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\<min, \-1\>\|int\<1, max\> given\.$#'
Expand Down Expand Up @@ -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\<array\>, int\<0, max\> given\.$#'
message: '#^Parameter \#2 \$menu_data of function wp_save_nav_menu_items expects array\<array\>, int given\.$#'
identifier: argument.type
count: 1
path: ../../../src/wp-admin/nav-menus.php
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions tests/phpstan/baselines/notIdentical.alwaysTrue.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/functions/maybeSerialize.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
}
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/post/types.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}

Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/tests/post/wpAfterInsertPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down Expand Up @@ -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 );
}

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/rest-api/rest-settings-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] );
}
}
2 changes: 1 addition & 1 deletion tests/phpunit/tests/rest-api/rest-users-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
12 changes: 6 additions & 6 deletions tests/phpunit/tests/theme/wpGetBlockCssSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

/**
Expand Down Expand Up @@ -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 );
}

/**
Expand Down Expand Up @@ -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 );
}

/**
Expand Down Expand Up @@ -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 );
}

/**
Expand All @@ -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 );
}

/**
Expand Down
Loading