Coding Standards: Include one space after function keyword for closures.

Note: This is enforced by WPCS 3.0.0.

Reference: [https://github.com/WordPress/WordPress-Coding-Standards/pull/2328 WPCS: PR #2328 Core: properly check formatting of function declaration statements].

Props jrf.
See #59161, #58831.

git-svn-id: https://develop.svn.wordpress.org/trunk@56559 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2023-09-12 15:21:02 +00:00
parent 9c9329c447
commit fd6c5606b1
96 changed files with 188 additions and 188 deletions
+2 -2
View File
@@ -387,7 +387,7 @@ class Tests_Actions extends WP_UnitTestCase {
*/
public function test_action_closure() {
$hook_name = __FUNCTION__;
$closure = static function( $a, $b ) {
$closure = static function ( $a, $b ) {
$GLOBALS[ $a ] = $b;
};
add_action( $hook_name, $closure, 10, 2 );
@@ -400,7 +400,7 @@ class Tests_Actions extends WP_UnitTestCase {
$this->assertSame( $GLOBALS[ $context[0] ], $context[1] );
$hook_name2 = __FUNCTION__ . '_2';
$closure2 = static function() {
$closure2 = static function () {
$GLOBALS['closure_no_args'] = true;
};
add_action( $hook_name2, $closure2 );
+1 -1
View File
@@ -343,7 +343,7 @@ class Tests_Admin_IncludesFile extends WP_UnitTestCase {
add_filter(
'wp_signature_hosts',
static function( $urls ) {
static function ( $urls ) {
$urls[] = 'example.com';
return $urls;
}
+1 -1
View File
@@ -795,7 +795,7 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase {
add_filter(
'get_sample_permalink',
function( $permalink, $post_id, $title, $name, $post ) use ( $post_original ) {
function ( $permalink, $post_id, $title, $name, $post ) use ( $post_original ) {
$this->assertEquals( $post_original, $post, 'Modified post object passed to get_sample_permalink filter.' );
return $permalink;
},
+1 -1
View File
@@ -192,7 +192,7 @@ class Tests_Admin_IncludesSchema extends WP_UnitTestCase {
// Set the "default" value for the timezone to a deprecated timezone.
add_filter(
'gettext_with_context',
static function( $translation, $text, $context ) {
static function ( $translation, $text, $context ) {
if ( '0' === $text && 'default GMT offset or timezone string' === $context ) {
return 'America/Buenos_Aires';
}
@@ -54,7 +54,7 @@ class Tests_Admin_WpAutomaticUpdater extends WP_UnitTestCase {
public function test_send_plugin_theme_email_should_append_plugin_urls( $urls, $successful, $failed ) {
add_filter(
'wp_mail',
function( $args ) use ( $urls ) {
function ( $args ) use ( $urls ) {
foreach ( $urls as $url ) {
$this->assertStringContainsString(
$url,
@@ -322,7 +322,7 @@ class Tests_Admin_WpAutomaticUpdater extends WP_UnitTestCase {
public function test_send_plugin_theme_email_should_not_append_plugin_urls( $urls, $successful, $failed ) {
add_filter(
'wp_mail',
function( $args ) use ( $urls ) {
function ( $args ) use ( $urls ) {
foreach ( $urls as $url ) {
$this->assertStringNotContainsString(
$url,
@@ -96,7 +96,7 @@ class Tests_Admin_wpCommentsListTable extends WP_UnitTestCase {
public function test_bulk_action_menu_supports_options_and_optgroups() {
add_filter(
'bulk_actions-edit-comments',
static function() {
static function () {
return array(
'delete' => 'Delete',
'Change State' => array(
+1 -1
View File
@@ -421,7 +421,7 @@ class Tests_Admin_wpSiteHealth extends WP_UnitTestCase {
// Set thresholds so high they should never be exceeded.
add_filter(
'site_status_persistent_object_cache_thresholds',
static function() {
static function () {
return array(
'alloptions_count' => PHP_INT_MAX,
'alloptions_bytes' => PHP_INT_MAX,
+1 -1
View File
@@ -74,7 +74,7 @@ class Tests_Ajax_wpAjaxAddTag extends WP_Ajax_UnitTestCase {
'tag-name' => 'techno',
),
'expected' => 'A new category added.',
'callback' => static function( array $messages ) {
'callback' => static function ( array $messages ) {
$messages['category'][1] = 'A new category added.';
return $messages;
},
@@ -176,7 +176,7 @@ class Tests_Ajax_wpAjaxAjaxTagSearch extends WP_Ajax_UnitTestCase {
// Add the ajax_term_search_results filter.
add_filter(
'ajax_term_search_results',
static function( $results, $tax, $s ) {
static function ( $results, $tax, $s ) {
return array( 'ajax_term_search_results was applied' );
},
10,
+1 -1
View File
@@ -284,7 +284,7 @@ class Tests_Block_Template extends WP_UnitTestCase {
register_block_type(
'test/in-the-loop-logger',
array(
'render_callback' => function() use ( &$in_the_loop_logs ) {
'render_callback' => function () use ( &$in_the_loop_logs ) {
$in_the_loop_logs[] = in_the_loop();
return '';
},
+4 -4
View File
@@ -109,7 +109,7 @@ class Tests_Blocks_Context extends WP_UnitTestCase {
'gutenberg/contextWithAssigned',
'gutenberg/contextWithoutDefault',
),
'render_callback' => static function( $attributes, $content, $block ) use ( &$provided_context ) {
'render_callback' => static function ( $attributes, $content, $block ) use ( &$provided_context ) {
$provided_context[] = $block->context;
return '';
@@ -149,7 +149,7 @@ class Tests_Blocks_Context extends WP_UnitTestCase {
'gutenberg/test-context-consumer',
array(
'uses_context' => array( 'postId', 'postType' ),
'render_callback' => static function( $attributes, $content, $block ) use ( &$provided_context ) {
'render_callback' => static function ( $attributes, $content, $block ) use ( &$provided_context ) {
$provided_context[] = $block->context;
return '';
@@ -182,7 +182,7 @@ class Tests_Blocks_Context extends WP_UnitTestCase {
'gutenberg/test-context-consumer',
array(
'uses_context' => array( 'example' ),
'render_callback' => static function( $attributes, $content, $block ) use ( &$provided_context ) {
'render_callback' => static function ( $attributes, $content, $block ) use ( &$provided_context ) {
$provided_context[] = $block->context;
return '';
@@ -190,7 +190,7 @@ class Tests_Blocks_Context extends WP_UnitTestCase {
)
);
$filter_block_context = static function( $context ) {
$filter_block_context = static function ( $context ) {
$context['example'] = 'ok';
return $context;
};
+1 -1
View File
@@ -307,7 +307,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
// Force the return value of wp_max_upload_size() to be 500.
add_filter(
'upload_size_limit',
static function() {
static function () {
return 500;
}
);
@@ -101,7 +101,7 @@ class Tests_Blocks_GetBlockTemplates extends WP_UnitTestCase {
*/
private function get_template_ids( $templates ) {
return array_map(
static function( $template ) {
static function ( $template ) {
return $template->id;
},
$templates
+3 -3
View File
@@ -957,7 +957,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
* @ticket 49615
*/
public function test_filter_block_registration() {
$filter_registration = static function( $args, $name ) {
$filter_registration = static function ( $args, $name ) {
$args['attributes'] = array( $name => array( 'type' => 'boolean' ) );
return $args;
};
@@ -975,7 +975,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
* @ticket 52138
*/
public function test_filter_block_registration_metadata() {
$filter_metadata_registration = static function( $metadata ) {
$filter_metadata_registration = static function ( $metadata ) {
$metadata['apiVersion'] = 3;
return $metadata;
};
@@ -993,7 +993,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
* @ticket 52138
*/
public function test_filter_block_registration_metadata_settings() {
$filter_metadata_registration = static function( $settings, $metadata ) {
$filter_metadata_registration = static function ( $settings, $metadata ) {
$settings['api_version'] = $metadata['apiVersion'] + 1;
return $settings;
};
@@ -536,7 +536,7 @@ END
add_filter(
'render_block',
static function( $block_content, $block ) use ( $parsed_comment_author_name_block ) {
static function ( $block_content, $block ) use ( $parsed_comment_author_name_block ) {
/*
* Insert a Comment Author Name block (which requires `commentId`
* block context to work) after the Comment Content block.
@@ -591,7 +591,7 @@ END
$render_block_callback = new MockAction();
add_filter( 'render_block', array( $render_block_callback, 'filter' ), 10, 3 );
$render_block_data_callback = static function( $parsed_block ) {
$render_block_data_callback = static function ( $parsed_block ) {
// Add a Social Links block to a Comment Template block's inner blocks.
if ( 'core/comment-template' === $parsed_block['blockName'] ) {
$inserted_block_markup = <<<END
+8 -8
View File
@@ -275,7 +275,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
$this->registry->register(
'core/dynamic',
array(
'render_callback' => static function() {
'render_callback' => static function () {
return 'b';
},
)
@@ -296,7 +296,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
$this->registry->register(
'core/greeting',
array(
'render_callback' => static function( $attributes, $content, $block ) {
'render_callback' => static function ( $attributes, $content, $block ) {
return sprintf( 'Hello from %s', $block->name );
},
)
@@ -366,7 +366,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
'default' => '!',
),
),
'render_callback' => static function( $block_attributes ) {
'render_callback' => static function ( $block_attributes ) {
return sprintf(
'Hello %s%s',
$block_attributes['toWhom'],
@@ -391,7 +391,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
$this->registry->register(
'core/outer',
array(
'render_callback' => static function( $block_attributes, $content ) {
'render_callback' => static function ( $block_attributes, $content ) {
return $content;
},
)
@@ -399,7 +399,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
$this->registry->register(
'core/inner',
array(
'render_callback' => static function() {
'render_callback' => static function () {
return 'b';
},
)
@@ -601,7 +601,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
add_filter(
'query_loop_block_query_vars',
static function( $query, $block, $page ) {
static function ( $query, $block, $page ) {
$query['post_type'] = 'book';
return $query;
},
@@ -768,7 +768,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
$this->registry->register(
'core/outer',
array(
'render_callback' => static function( $block_attributes, $content ) {
'render_callback' => static function ( $block_attributes, $content ) {
return $content;
},
)
@@ -777,7 +777,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
$this->registry->register(
'core/inner',
array(
'render_callback' => static function() {
'render_callback' => static function () {
return 'b';
},
)
+1 -1
View File
@@ -247,7 +247,7 @@ class Tests_Canonical extends WP_Canonical_UnitTestCase {
// Test short-circuit filter.
add_filter(
'pre_redirect_guess_404_permalink',
static function() {
static function () {
return 'wp';
}
);
@@ -40,7 +40,7 @@ class Tests_Category_Walker_Category extends WP_UnitTestCase {
add_filter(
'category_list_link_attributes',
static function( $atts ) use ( $value ) {
static function ( $atts ) use ( $value ) {
$atts['data-test'] = $value;
return $atts;
}
+10 -10
View File
@@ -910,7 +910,7 @@ class Tests_Cron extends WP_UnitTestCase {
* @covers ::wp_reschedule_event
*/
public function test_schedule_short_circuit_with_error_returns_false_when_wp_error_is_set_to_false() {
$return_error = function( $pre, $event, $wp_error ) {
$return_error = function ( $pre, $event, $wp_error ) {
$this->assertFalse( $wp_error );
return new WP_Error(
@@ -942,7 +942,7 @@ class Tests_Cron extends WP_UnitTestCase {
* @covers ::wp_reschedule_event
*/
public function test_schedule_short_circuit_with_error_returns_error_when_wp_error_is_set_to_true() {
$return_error = function( $pre, $event, $wp_error ) {
$return_error = function ( $pre, $event, $wp_error ) {
$this->assertTrue( $wp_error );
return new WP_Error(
@@ -1029,7 +1029,7 @@ class Tests_Cron extends WP_UnitTestCase {
* @covers ::wp_clear_scheduled_hook
*/
public function test_deprecated_argument_usage_of_wp_clear_scheduled_hook() {
$return_pre = function( $pre, $hook, $args, $wp_error ) {
$return_pre = function ( $pre, $hook, $args, $wp_error ) {
$this->assertSame( array( 1, 2, 3 ), $args );
$this->assertFalse( $wp_error );
@@ -1072,7 +1072,7 @@ class Tests_Cron extends WP_UnitTestCase {
* @covers ::wp_clear_scheduled_hook
*/
public function test_clear_scheduled_hook_returns_custom_pre_filter_error_when_wp_error_is_set_to_true() {
$return_error = function( $pre, $timestamp, $hook, $args, $wp_error ) {
$return_error = function ( $pre, $timestamp, $hook, $args, $wp_error ) {
$this->assertTrue( $wp_error );
return new WP_Error( 'error_code', 'error message' );
@@ -1107,7 +1107,7 @@ class Tests_Cron extends WP_UnitTestCase {
* @covers ::wp_unschedule_hook
*/
public function test_unschedule_short_circuit_with_error_returns_false_when_wp_error_is_set_to_false() {
$return_error = function( $pre, $hook, $wp_error ) {
$return_error = function ( $pre, $hook, $wp_error ) {
$this->assertFalse( $wp_error );
return new WP_Error(
@@ -1132,7 +1132,7 @@ class Tests_Cron extends WP_UnitTestCase {
* @covers ::wp_unschedule_hook
*/
public function test_unschedule_short_circuit_with_error_returns_error_when_wp_error_is_set_to_true() {
$return_error = function( $pre, $hook, $wp_error ) {
$return_error = function ( $pre, $hook, $wp_error ) {
$this->assertTrue( $wp_error );
return new WP_Error(
@@ -1194,7 +1194,7 @@ class Tests_Cron extends WP_UnitTestCase {
// Force update_option() to fail by setting the new value to match the existing:
add_filter(
'pre_update_option_cron',
static function() {
static function () {
return get_option( 'cron' );
}
);
@@ -1216,7 +1216,7 @@ class Tests_Cron extends WP_UnitTestCase {
// Force update_option() to fail by setting the new value to match the existing:
add_filter(
'pre_update_option_cron',
static function() {
static function () {
return get_option( 'cron' );
}
);
@@ -1241,7 +1241,7 @@ class Tests_Cron extends WP_UnitTestCase {
// Force update_option() to fail by setting the new value to match the existing:
add_filter(
'pre_update_option_cron',
static function() {
static function () {
return get_option( 'cron' );
}
);
@@ -1267,7 +1267,7 @@ class Tests_Cron extends WP_UnitTestCase {
// Force update_option() to fail by setting the new value to match the existing:
add_filter(
'pre_update_option_cron',
static function() {
static function () {
return get_option( 'cron' );
}
);
+1 -1
View File
@@ -2917,7 +2917,7 @@ HTML
wp_set_script_translations( 'common' );
$print_scripts = get_echo(
static function() {
static function () {
wp_print_scripts();
_print_scripts();
}
+3 -3
View File
@@ -533,7 +533,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
// The Last-Modified header should have the post's date when "withcomments" is not passed.
add_filter(
'wp_headers',
function( $headers ) use ( $last_week ) {
function ( $headers ) use ( $last_week ) {
$this->assertSame(
strtotime( $headers['Last-Modified'] ),
strtotime( $last_week ),
@@ -572,7 +572,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
// The Last-Modified header should have the comment's date when "withcomments=1" is passed.
add_filter(
'wp_headers',
function( $headers ) use ( $yesterday ) {
function ( $headers ) use ( $yesterday ) {
$this->assertSame(
strtotime( $headers['Last-Modified'] ),
strtotime( $yesterday ),
@@ -615,7 +615,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
// The Last-Modified header should have the date from today's post when it is the latest update.
add_filter(
'wp_headers',
function( $headers ) use ( $today ) {
function ( $headers ) use ( $today ) {
$this->assertSame(
strtotime( $headers['Last-Modified'] ),
strtotime( $today ),
+5 -5
View File
@@ -251,7 +251,7 @@ class Tests_File extends WP_UnitTestCase {
// Create a conflict by removing the randomness of the generated password.
add_filter(
'random_password',
static function() {
static function () {
return '123456';
},
10,
@@ -285,7 +285,7 @@ class Tests_File extends WP_UnitTestCase {
// Force random passwords to 12 characters.
add_filter(
'random_password',
static function() {
static function () {
return '1a2b3c4d5e6f';
},
10,
@@ -321,7 +321,7 @@ class Tests_File extends WP_UnitTestCase {
// Make the filter send the filename over the limit.
add_filter(
'wp_unique_filename',
static function( $filename ) use ( &$filenames_over_limit ) {
static function ( $filename ) use ( &$filenames_over_limit ) {
if ( strlen( $filename ) === 252 ) {
$filename .= '1';
++$filenames_over_limit;
@@ -357,7 +357,7 @@ class Tests_File extends WP_UnitTestCase {
// Force random passwords to 12 characters.
add_filter(
'random_password',
static function() {
static function () {
return '1a2b3c4d5e6f';
},
10,
@@ -375,7 +375,7 @@ class Tests_File extends WP_UnitTestCase {
// Make the filter send the filename over the limit.
add_filter(
'wp_unique_filename',
static function( $filename ) use ( &$filenames_over_limit ) {
static function ( $filename ) use ( &$filenames_over_limit ) {
if ( strlen( $filename ) === 252 ) {
$filename .= '1';
++$filenames_over_limit;
@@ -108,7 +108,7 @@ class Tests_Formatting_wpTrimExcerpt extends WP_UnitTestCase {
$has_filter = true;
add_filter(
'the_content',
static function( $content ) use ( &$has_filter ) {
static function ( $content ) use ( &$has_filter ) {
$has_filter = has_filter( 'the_content', 'wp_filter_content_tags' );
return $content;
}
+2 -2
View File
@@ -1726,7 +1726,7 @@ class Tests_Functions extends WP_UnitTestCase {
add_filter(
'upload_mimes',
static function( $mimes ) {
static function ( $mimes ) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
@@ -1764,7 +1764,7 @@ class Tests_Functions extends WP_UnitTestCase {
add_filter(
'upload_mimes',
static function( $mimes ) use ( $woff_mime_type ) {
static function ( $mimes ) use ( $woff_mime_type ) {
$mimes['woff'] = $woff_mime_type;
return $mimes;
}
+2 -2
View File
@@ -25,7 +25,7 @@ class Tests_Functions_wpFilesize extends WP_UnitTestCase {
add_filter(
'wp_filesize',
static function() {
static function () {
return 999;
}
);
@@ -34,7 +34,7 @@ class Tests_Functions_wpFilesize extends WP_UnitTestCase {
add_filter(
'pre_wp_filesize',
static function() {
static function () {
return 111;
}
);
@@ -491,14 +491,14 @@ class Tests_General_FeedLinksExtra extends WP_UnitTestCase {
public function test_feed_links_extra_should_respect_feed_type() {
add_filter(
'default_feed',
static function() {
static function () {
return 'foo';
}
);
add_filter(
'feed_content_type',
static function() {
static function () {
return 'testing/foo';
}
);
+1 -1
View File
@@ -593,7 +593,7 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase {
// Filter the response made by WP_Http::handle_redirects().
add_filter(
'pre_http_request',
function( $response, $parsed_args, $url ) use ( &$pre_http_request_filter_has_run ) {
function ( $response, $parsed_args, $url ) use ( &$pre_http_request_filter_has_run ) {
$pre_http_request_filter_has_run = true;
// Assert the redirect URL is correct.
+3 -3
View File
@@ -117,7 +117,7 @@ class Tests_HTTPS_Detection extends WP_UnitTestCase {
// Override to enforce no errors being detected.
add_filter(
'pre_wp_update_https_detection_errors',
static function() {
static function () {
return new WP_Error();
}
);
@@ -127,7 +127,7 @@ class Tests_HTTPS_Detection extends WP_UnitTestCase {
// Override to enforce an error being detected.
add_filter(
'pre_wp_update_https_detection_errors',
static function() {
static function () {
return new WP_Error(
'ssl_verification_failed',
'Bad SSL certificate.'
@@ -316,7 +316,7 @@ class Tests_HTTPS_Detection extends WP_UnitTestCase {
* @return callable Filter callback.
*/
private function filter_set_url_scheme( $scheme ) {
return static function( $url ) use ( $scheme ) {
return static function ( $url ) use ( $scheme ) {
return set_url_scheme( $url, $scheme );
};
}
+2 -2
View File
@@ -161,7 +161,7 @@ class Tests_HTTPS_Migration extends WP_UnitTestCase {
private function force_wp_is_using_https( $enabled ) {
$scheme = $enabled ? 'https' : 'http';
$replace_scheme = static function( $url ) use ( $scheme ) {
$replace_scheme = static function ( $url ) use ( $scheme ) {
return str_replace( array( 'http://', 'https://' ), $scheme . '://', $url );
};
@@ -172,7 +172,7 @@ class Tests_HTTPS_Migration extends WP_UnitTestCase {
private function force_option( $option, $value ) {
add_filter(
"option_$option",
static function() use ( $value ) {
static function () use ( $value ) {
return $value;
}
);
+1 -1
View File
@@ -683,7 +683,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
$check_file = path_join( dirname( $attached_file ), $check['file'] );
$imagick = new Imagick( $check_file );
$output = array_map(
static function( $value ) {
static function ( $value ) {
return (int) round( $value );
},
array_intersect_key( $imagick->getImagePixelColor( 100, 100 )->getColor( true /* normalized */ ), $rgb )
+2 -2
View File
@@ -692,7 +692,7 @@ class Tests_Image_Functions extends WP_UnitTestCase {
add_filter(
'wp_image_editors',
static function( $editors ) {
static function ( $editors ) {
return array( 'WP_Image_Editor_Mock' );
}
);
@@ -718,7 +718,7 @@ class Tests_Image_Functions extends WP_UnitTestCase {
public function test_wp_crop_image_should_return_correct_file_extension_if_output_format_was_modified() {
add_filter(
'image_editor_output_format',
static function() {
static function () {
return array_fill_keys( array( 'image/jpg', 'image/jpeg', 'image/png' ), 'image/webp' );
}
);
@@ -69,7 +69,7 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase {
public function test_image_editor_output_format_filter() {
add_filter(
'image_editor_output_format',
static function() {
static function () {
return array( 'image/jpeg' => 'image/webp' );
}
);
+17 -17
View File
@@ -33,7 +33,7 @@ class Tests_L10n_DetermineLocale extends WP_UnitTestCase {
public function test_short_circuit_no_string() {
add_filter(
'pre_determine_locale',
static function() {
static function () {
return 1234;
}
);
@@ -43,7 +43,7 @@ class Tests_L10n_DetermineLocale extends WP_UnitTestCase {
public function test_short_circuit_string() {
add_filter(
'pre_determine_locale',
static function() {
static function () {
return 'myNewLocale';
}
);
@@ -53,7 +53,7 @@ class Tests_L10n_DetermineLocale extends WP_UnitTestCase {
public function test_defaults_to_site_locale() {
add_filter(
'locale',
static function() {
static function () {
return 'siteLocale';
}
);
@@ -64,7 +64,7 @@ class Tests_L10n_DetermineLocale extends WP_UnitTestCase {
public function test_is_admin_no_user() {
add_filter(
'locale',
static function() {
static function () {
return 'siteLocale';
}
);
@@ -77,7 +77,7 @@ class Tests_L10n_DetermineLocale extends WP_UnitTestCase {
public function test_is_admin_user_locale() {
add_filter(
'locale',
static function() {
static function () {
return 'siteLocale';
}
);
@@ -91,7 +91,7 @@ class Tests_L10n_DetermineLocale extends WP_UnitTestCase {
public function test_json_request_user_locale() {
add_filter(
'locale',
static function() {
static function () {
return 'siteLocale';
}
);
@@ -107,7 +107,7 @@ class Tests_L10n_DetermineLocale extends WP_UnitTestCase {
public function test_json_request_user_locale_no_user() {
add_filter(
'locale',
static function() {
static function () {
return 'siteLocale';
}
);
@@ -121,7 +121,7 @@ class Tests_L10n_DetermineLocale extends WP_UnitTestCase {
public function test_json_request_missing_get_param() {
add_filter(
'locale',
static function() {
static function () {
return 'siteLocale';
}
);
@@ -136,7 +136,7 @@ class Tests_L10n_DetermineLocale extends WP_UnitTestCase {
public function test_json_request_incorrect_get_param() {
add_filter(
'locale',
static function() {
static function () {
return 'siteLocale';
}
);
@@ -152,7 +152,7 @@ class Tests_L10n_DetermineLocale extends WP_UnitTestCase {
public function test_get_param_but_no_json_request() {
add_filter(
'locale',
static function() {
static function () {
return 'siteLocale';
}
);
@@ -167,7 +167,7 @@ class Tests_L10n_DetermineLocale extends WP_UnitTestCase {
public function test_wp_login_get_param_not_on_login_page() {
add_filter(
'locale',
static function() {
static function () {
return 'siteLocale';
}
);
@@ -182,7 +182,7 @@ class Tests_L10n_DetermineLocale extends WP_UnitTestCase {
public function test_wp_login_get_param_on_login_page() {
add_filter(
'locale',
static function() {
static function () {
return 'siteLocale';
}
);
@@ -198,7 +198,7 @@ class Tests_L10n_DetermineLocale extends WP_UnitTestCase {
public function test_wp_login_get_param_on_login_page_empty_string() {
add_filter(
'locale',
static function() {
static function () {
return 'siteLocale';
}
);
@@ -214,7 +214,7 @@ class Tests_L10n_DetermineLocale extends WP_UnitTestCase {
public function test_wp_login_get_param_on_login_page_incorrect_string() {
add_filter(
'locale',
static function() {
static function () {
return 'siteLocale';
}
);
@@ -230,7 +230,7 @@ class Tests_L10n_DetermineLocale extends WP_UnitTestCase {
public function test_wp_login_cookie_not_on_login_page() {
add_filter(
'locale',
static function() {
static function () {
return 'siteLocale';
}
);
@@ -245,7 +245,7 @@ class Tests_L10n_DetermineLocale extends WP_UnitTestCase {
public function test_wp_login_cookie_on_login_page() {
add_filter(
'locale',
static function() {
static function () {
return 'siteLocale';
}
);
@@ -261,7 +261,7 @@ class Tests_L10n_DetermineLocale extends WP_UnitTestCase {
public function test_wp_login_cookie_on_login_page_empty_string() {
add_filter(
'locale',
static function() {
static function () {
return 'siteLocale';
}
);
+1 -1
View File
@@ -101,7 +101,7 @@ class Tests_Link_EditTermLink extends WP_UnitTestCase {
add_filter(
'edit_term_link',
function( $location, $term ) {
function ( $location, $term ) {
$this->assertIsInt( $term );
},
10,
+1 -1
View File
@@ -187,7 +187,7 @@ class Tests_Link_GetEditTermLink extends WP_UnitTestCase {
add_filter(
'get_edit_term_link',
function( $location, $term ) {
function ( $location, $term ) {
$this->assertIsInt( $term );
},
10,
+10 -10
View File
@@ -2357,7 +2357,7 @@ EOF;
add_filter(
'wp_content_img_tag',
static function( $filtered_image ) {
static function ( $filtered_image ) {
return "<span>$filtered_image</span>";
}
);
@@ -2381,7 +2381,7 @@ EOF;
add_filter(
'wp_content_img_tag',
static function( $filtered_image ) {
static function ( $filtered_image ) {
return "<span>$filtered_image</span>";
}
);
@@ -4020,7 +4020,7 @@ EOF;
add_filter( 'wp_img_tag_add_decoding_attr', '__return_false' );
add_filter(
'wp_get_attachment_image_attributes',
static function( $attr ) {
static function ( $attr ) {
unset( $attr['srcset'], $attr['sizes'], $attr['decoding'] );
return $attr;
}
@@ -4154,7 +4154,7 @@ EOF;
// Overwrite post content with an image.
add_filter(
'the_content',
static function() use ( &$image_within_content ) {
static function () use ( &$image_within_content ) {
// Replace content with an image tag, i.e. the 'wp_get_attachment_image' context is used while running 'the_content' filter.
$image_within_content = wp_get_attachment_image( self::$large_id, 'large', false );
return $image_within_content;
@@ -4221,7 +4221,7 @@ EOF;
$result = null;
add_filter(
'the_content',
static function( $content ) use ( &$result, $context ) {
static function ( $content ) use ( &$result, $context ) {
$result = wp_get_loading_attr_default( $context );
return $content;
}
@@ -4523,7 +4523,7 @@ EOF;
$result = null;
add_filter(
'the_content',
function( $content ) use ( &$result, $context ) {
function ( $content ) use ( &$result, $context ) {
$attr = $this->get_width_height_for_high_priority();
$result = wp_get_loading_optimization_attributes( 'img', $attr, $context );
return $content;
@@ -4805,7 +4805,7 @@ EOF;
// Add a filter that modifies the context.
add_filter(
'wp_get_attachment_image_context',
static function() {
static function () {
return 'my_custom_context';
}
);
@@ -5208,7 +5208,7 @@ EOF;
add_filter(
'wp_min_priority_img_pixels',
static function( $res ) {
static function ( $res ) {
return 2500; // 50*50=2500
}
);
@@ -5281,7 +5281,7 @@ EOF;
private function track_last_attachment_image_context( &$last_context ) {
add_filter(
'wp_get_attachment_image_context',
static function( $context ) use ( &$last_context ) {
static function ( $context ) use ( &$last_context ) {
$last_context = $context;
return $context;
},
@@ -5336,7 +5336,7 @@ EOF;
public function force_omit_loading_attr_threshold( $threshold ) {
add_filter(
'wp_omit_loading_attr_threshold',
static function() use ( $threshold ) {
static function () use ( $threshold ) {
return $threshold;
}
);
@@ -73,7 +73,7 @@ class Tests_Media_wpGenerateAttachmentMetadata extends WP_UnitTestCase {
// PSD mime type is not allowed by default on multisite.
add_filter(
'upload_mimes',
static function( $mimes ) {
static function ( $mimes ) {
$mimes['psd'] = 'application/octet-stream';
return $mimes;
}
@@ -25,7 +25,7 @@ class Tests_Media_Wp_Img_Tag_Add_Decoding_Attr extends WP_UnitTestCase {
if ( 'no value' !== $decoding ) {
add_filter(
'wp_img_tag_add_decoding_attr',
static function( $value ) use ( $decoding ) {
static function ( $value ) use ( $decoding ) {
return $decoding;
}
);
@@ -86,7 +86,7 @@ class Tests_Media_Wp_Img_Tag_Add_Decoding_Attr extends WP_UnitTestCase {
if ( 'no value' !== $decoding ) {
add_filter(
'wp_img_tag_add_decoding_attr',
static function( $value ) use ( $decoding ) {
static function ( $value ) use ( $decoding ) {
return $decoding;
}
);
+1 -1
View File
@@ -101,7 +101,7 @@ class Tests_Menu_Walker_Nav_Menu extends WP_UnitTestCase {
add_filter(
'nav_menu_link_attributes',
static function( $atts ) use ( $value ) {
static function ( $atts ) use ( $value ) {
$atts['data-test'] = $value;
return $atts;
}
@@ -186,7 +186,7 @@ class Tests_Option_WpSetOptionAutoloadValues extends WP_UnitTestCase {
// Force UPDATE queries to fail, leading to no autoload values being updated.
add_filter(
'query',
static function( $query ) {
static function ( $query ) {
if ( str_starts_with( $query, 'UPDATE ' ) ) {
return '';
}
+1 -1
View File
@@ -344,7 +344,7 @@ class Tests_Post_GetPages extends WP_UnitTestCase {
// Filter the query to return the wptests_pt post type.
add_filter(
'get_pages_query_args',
static function( $query_args, $parsed_args ) use ( &$query_args_values, &$parsed_args_values ) {
static function ( $query_args, $parsed_args ) use ( &$query_args_values, &$parsed_args_values ) {
$query_args['post_type'] = 'wptests_pt';
$query_args_values = $query_args;
$parsed_args_values = $parsed_args;
+1 -1
View File
@@ -883,7 +883,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase {
add_filter(
'wp_revisions_to_keep',
static function() {
static function () {
return 1;
}
);
+1 -1
View File
@@ -571,7 +571,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase {
private function track_last_attachment_image_context( &$last_context ) {
add_filter(
'wp_get_attachment_image_context',
static function( $context ) use ( &$last_context ) {
static function ( $context ) use ( &$last_context ) {
$last_context = $context;
return $context;
},
+1 -1
View File
@@ -33,7 +33,7 @@ class Tests_Post_Walker_Page extends WP_UnitTestCase {
add_filter(
'page_menu_link_attributes',
static function( $atts ) use ( $value ) {
static function ( $atts ) use ( $value ) {
$atts['data-test'] = $value;
return $atts;
}
@@ -41,7 +41,7 @@ class Tests_Post_WpGetAttachmentLink extends WP_UnitTestCase {
add_filter(
'wp_get_attachment_link_attributes',
static function( $attr ) use ( $attributes ) {
static function ( $attr ) use ( $attributes ) {
return array_merge( $attr, $attributes );
}
);
+2 -2
View File
@@ -730,7 +730,7 @@ class Tests_Query extends WP_UnitTestCase {
public function test_posts_clauses_filter_should_receive_filtered_clauses() {
add_filter(
'posts_join_paged',
static function() {
static function () {
return '/* posts_join_paged */';
}
);
@@ -755,7 +755,7 @@ class Tests_Query extends WP_UnitTestCase {
public function test_posts_clauses_request_filter_should_receive_filtered_clauses() {
add_filter(
'posts_join_request',
static function() {
static function () {
return '/* posts_join_request */';
}
);
+2 -2
View File
@@ -1641,14 +1641,14 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// Get the list of `is_*()` conditional tags.
$functions = array_filter(
get_class_methods( 'WP_Query' ),
static function( $function_name ) {
static function ( $function_name ) {
return str_starts_with( $function_name, 'is_' );
}
);
// Wrap each function name in an array.
$functions = array_map(
static function( $function_name ) {
static function ( $function_name ) {
return array( $function_name );
},
$functions
@@ -961,7 +961,7 @@ class WP_Test_REST_Application_Passwords_Controller extends WP_Test_REST_Control
$this->setup_app_password_authenticated_request();
add_action(
'application_password_did_authenticate',
static function() {
static function () {
$GLOBALS['wp_rest_application_password_uuid'] = 'invalid_uuid';
}
);
@@ -359,7 +359,7 @@ class WP_REST_Block_Directory_Controller_Test extends WP_Test_REST_Controller_Te
private function mock_remote_request( array $expected ) {
add_filter(
'pre_http_request',
static function() use ( $expected ) {
static function () use ( $expected ) {
$default = array(
'headers' => array(),
'response' => array(
@@ -429,7 +429,7 @@ class REST_Block_Renderer_Controller_Test extends WP_Test_REST_Controller_Testca
public function test_get_item_with_pre_render_block_filter() {
wp_set_current_user( self::$user_id );
$pre_render_filter = static function( $output, $block ) {
$pre_render_filter = static function ( $output, $block ) {
if ( $block['blockName'] === self::$block_name ) {
return '<p>Alternate content.</p>';
}
@@ -310,7 +310,7 @@ class WP_REST_Pattern_Directory_Controller_Test extends WP_Test_REST_Controller_
// Test that filter changes uncached values.
add_filter(
'rest_prepare_block_pattern',
static function( $response ) {
static function ( $response ) {
return 'initial value';
}
);
@@ -324,7 +324,7 @@ class WP_REST_Pattern_Directory_Controller_Test extends WP_Test_REST_Controller_
// Test that filter changes cached values (the previous request primed the cache).
add_filter(
'rest_prepare_block_pattern',
static function( $response ) {
static function ( $response ) {
return 'modified the cache';
},
11
@@ -537,7 +537,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase {
wp_set_current_user( self::$super_admin );
add_filter(
'pre_http_request',
static function() {
static function () {
/*
* Mocks the request to:
* https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request%5Bslug%5D=alex-says-this-block-definitely-doesnt-exist&request%5Bfields%5D%5Bsections%5D=0&request%5Bfields%5D%5Blanguage_packs%5D=1&request%5Blocale%5D=en_US&request%5Bwp_version%5D=5.9
@@ -2742,7 +2742,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase {
'single' => true,
'type' => 'boolean',
'show_in_rest' => true,
'sanitize_callback' => static function( $value ) {
'sanitize_callback' => static function ( $value ) {
return $value ? '1' : '0';
},
)
@@ -2278,7 +2278,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
*/
public function test_prepare_item_filters_content_when_needed() {
$filter_count = 0;
$filter_content = static function() use ( &$filter_count ) {
$filter_content = static function () use ( &$filter_count ) {
++$filter_count;
return '<p>Filtered content.</p>';
};
@@ -2314,7 +2314,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
*/
public function test_prepare_item_skips_content_filter_if_not_needed() {
$filter_count = 0;
$filter_content = static function() use ( &$filter_count ) {
$filter_content = static function () use ( &$filter_count ) {
++$filter_count;
return '<p>Filtered content.</p>';
};
+5 -5
View File
@@ -937,7 +937,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase {
* @ticket 56566
*/
public function test_link_embedding_returning_wp_error() {
$return_wp_error = static function() {
$return_wp_error = static function () {
return new WP_Error( 'some-error', 'This is not valid!' );
};
add_filter( 'rest_pre_dispatch', $return_wp_error );
@@ -1671,7 +1671,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase {
'/test',
array(
'methods' => array( 'GET' ),
'callback' => static function() {
'callback' => static function () {
return new WP_REST_Response( 'data', 204 );
},
'permission_callback' => '__return_true',
@@ -1682,7 +1682,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase {
'/test',
array(
'methods' => array( 'GET' ),
'callback' => static function() {
'callback' => static function () {
return new WP_REST_Response( 'data', 204 );
},
'permission_callback' => '__return_true',
@@ -2080,7 +2080,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase {
public function test_batch_v1_max_requests() {
add_filter(
'rest_get_max_batch_size',
static function() {
static function () {
return 5;
}
);
@@ -2188,7 +2188,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase {
array(
array(
'methods' => \WP_REST_Server::READABLE,
'callback' => static function() {
'callback' => static function () {
return new \WP_REST_Response( INF );
},
'permission_callback' => '__return_true',
@@ -161,7 +161,7 @@ class WP_Test_REST_Widget_Types_Controller extends WP_Test_REST_Controller_Testc
$data = $response->get_data();
$text_widgets = array_filter(
$data,
static function( $widget ) {
static function ( $widget ) {
return 'text' === $widget['id'];
}
);
@@ -189,7 +189,7 @@ class WP_Test_REST_Widget_Types_Controller extends WP_Test_REST_Controller_Testc
wp_register_sidebar_widget(
$widget_id,
'WP legacy widget',
static function() {}
static function () {}
);
wp_set_current_user( self::$admin_id );
$request = new WP_REST_Request( 'GET', '/wp/v2/widget-types/' . $widget_id );
@@ -220,7 +220,7 @@ class WP_Test_REST_Widget_Types_Controller extends WP_Test_REST_Controller_Testc
wp_register_sidebar_widget(
$widget_id,
'&#8216;Legacy &#8209; Archive &#8209; Widget&#8217;',
static function() {},
static function () {},
array(
'description' => '&#8220;A great &amp; interesting archive of your site&#8217;s posts!&#8221;',
)
@@ -296,7 +296,7 @@ class Tests_REST_WpRestUrlDetailsController extends WP_Test_REST_Controller_Test
add_filter(
'rest_url_details_http_request_args',
static function( $args, $url ) {
static function ( $args, $url ) {
return array_merge(
$args,
array(
@@ -339,7 +339,7 @@ class Tests_REST_WpRestUrlDetailsController extends WP_Test_REST_Controller_Test
// Force cache to return a known value as the remote URL http response body.
add_filter(
"pre_site_transient_{$transient_name}",
static function() {
static function () {
return '<html><head><title>This value from cache.</title></head><body></body></html>';
}
);
@@ -367,7 +367,7 @@ class Tests_REST_WpRestUrlDetailsController extends WP_Test_REST_Controller_Test
public function test_allows_filtering_data_retrieved_for_a_given_url() {
add_filter(
'rest_prepare_url_details',
static function( $response ) {
static function ( $response ) {
$data = $response->get_data();
@@ -417,7 +417,7 @@ class Tests_REST_WpRestUrlDetailsController extends WP_Test_REST_Controller_Test
*/
add_filter(
'rest_prepare_url_details',
static function( $response, $url ) {
static function ( $response, $url ) {
return new WP_REST_Response(
array(
'status' => 418,
+1 -1
View File
@@ -39,7 +39,7 @@ class Tests_Robots extends WP_UnitTestCase {
public function test_wp_robots_parses_directives_correctly() {
add_filter(
'wp_robots',
static function( array $robots ) {
static function ( array $robots ) {
// Directives that should have values must use strings.
$robots['directive-with-value'] = 'yes';
$robots['directive-with-numeric-value'] = '1';
+1 -1
View File
@@ -259,7 +259,7 @@ class Tests_Term_GetTermLink extends WP_UnitTestCase {
add_filter(
'term_link',
function( $location, $term ) {
function ( $location, $term ) {
$this->assertInstanceOf( 'WP_Term', $term );
},
10,
+2 -2
View File
@@ -98,7 +98,7 @@ class Tests_Theme_CustomHeader extends WP_UnitTestCase {
public function test_filter_header_image( $header_image, $expected ) {
add_filter(
'get_header_image',
static function() use ( $header_image ) {
static function () use ( $header_image ) {
return $header_image;
}
);
@@ -190,7 +190,7 @@ class Tests_Theme_CustomHeader extends WP_UnitTestCase {
add_filter(
'wp_min_priority_img_pixels',
static function() {
static function () {
return 2500; // 50*50=2500
}
);
@@ -600,7 +600,7 @@ class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase {
$global_styles_query_count = 0;
add_filter(
'query',
static function( $query ) use ( &$global_styles_query_count ) {
static function ( $query ) use ( &$global_styles_query_count ) {
if ( preg_match( '#post_type = \'wp_global_styles\'#', $query ) ) {
$global_styles_query_count++;
}
@@ -836,7 +836,7 @@ class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase {
$styles = $theme_json->get_styles_block_nodes();
$styles = array_filter(
$styles,
static function( $element ) {
static function ( $element ) {
return isset( $element['name'] ) && 'my/block-with-styles' === $element['name'];
}
);
+1 -1
View File
@@ -421,7 +421,7 @@ class Tests_User_Query_Cache extends WP_UnitTestCase {
$q1 = new WP_User_Query( $args );
$found1 = $q1->get_results();
$callback = static function( $user ) {
$callback = static function ( $user ) {
return (array) $user;
};
@@ -52,7 +52,7 @@ class Tests_User_RetrievePassword extends WP_UnitTestCase {
public function test_retrieve_password_should_return_wp_error_on_failed_email() {
add_filter(
'retrieve_password_notification_email',
static function() {
static function () {
return array( 'message' => '' );
}
);
+1 -1
View File
@@ -596,7 +596,7 @@ class Tests_Widgets extends WP_UnitTestCase {
add_filter(
"pre_option_{$widget->option_name}",
static function() {
static function () {
return new ArrayObject(
array(
2 => array( 'title' => 'Test Title' ),