diff --git a/src/wp-admin/edit-form-blocks.php b/src/wp-admin/edit-form-blocks.php index 66a6bbfc25..e200b29621 100644 --- a/src/wp-admin/edit-form-blocks.php +++ b/src/wp-admin/edit-form-blocks.php @@ -31,7 +31,7 @@ $current_screen->is_block_editor( true ); // Default to is-fullscreen-mode to avoid jumps in the UI. add_filter( 'admin_body_class', - static function( $classes ) { + static function ( $classes ) { return "$classes is-fullscreen-mode"; } ); diff --git a/src/wp-admin/includes/class-wp-community-events.php b/src/wp-admin/includes/class-wp-community-events.php index 09557c86a4..008611af21 100644 --- a/src/wp-admin/includes/class-wp-community-events.php +++ b/src/wp-admin/includes/class-wp-community-events.php @@ -483,7 +483,7 @@ class WP_Community_Events { $future_wordcamps = array_filter( $future_events, - static function( $wordcamp ) { + static function ( $wordcamp ) { return 'wordcamp' === $wordcamp['type']; } ); diff --git a/src/wp-admin/includes/class-wp-site-health-auto-updates.php b/src/wp-admin/includes/class-wp-site-health-auto-updates.php index d1655eb1d8..f8521ab2b0 100644 --- a/src/wp-admin/includes/class-wp-site-health-auto-updates.php +++ b/src/wp-admin/includes/class-wp-site-health-auto-updates.php @@ -42,7 +42,7 @@ class WP_Site_Health_Auto_Updates { $tests = array_filter( $tests ); $tests = array_map( - static function( $test ) { + static function ( $test ) { $test = (object) $test; if ( empty( $test->severity ) ) { diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php index aa8e25c8ed..6531736bd9 100644 --- a/src/wp-admin/includes/file.php +++ b/src/wp-admin/includes/file.php @@ -2726,7 +2726,7 @@ function wp_opcache_invalidate_directory( $dir ) { * with sub-directories represented as nested arrays. * @param string $path Absolute path to the directory. */ - $invalidate_directory = static function( $dirlist, $path ) use ( &$invalidate_directory ) { + $invalidate_directory = static function ( $dirlist, $path ) use ( &$invalidate_directory ) { $path = trailingslashit( $path ); foreach ( $dirlist as $name => $details ) { diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php index 6085b02c8f..fdb522c889 100644 --- a/src/wp-admin/includes/update-core.php +++ b/src/wp-admin/includes/update-core.php @@ -1805,7 +1805,7 @@ function _upgrade_422_find_genericons_files_in_folder( $directory ) { $dirs = glob( $directory . '*', GLOB_ONLYDIR ); $dirs = array_filter( $dirs, - static function( $dir ) { + static function ( $dir ) { /* * Skip any node_modules directories. * diff --git a/src/wp-admin/options-privacy.php b/src/wp-admin/options-privacy.php index 5c22d39d5d..1afb8c0601 100644 --- a/src/wp-admin/options-privacy.php +++ b/src/wp-admin/options-privacy.php @@ -23,7 +23,7 @@ $title = __( 'Privacy' ); add_filter( 'admin_body_class', - static function( $body_class ) { + static function ( $body_class ) { $body_class .= ' privacy-settings '; return $body_class; diff --git a/src/wp-admin/privacy-policy-guide.php b/src/wp-admin/privacy-policy-guide.php index 7e92a4dea6..b8f303aa7f 100644 --- a/src/wp-admin/privacy-policy-guide.php +++ b/src/wp-admin/privacy-policy-guide.php @@ -22,7 +22,7 @@ $title = __( 'Privacy Policy Guide' ); add_filter( 'admin_body_class', - static function( $body_class ) { + static function ( $body_class ) { $body_class .= ' privacy-settings '; return $body_class; diff --git a/src/wp-admin/site-editor.php b/src/wp-admin/site-editor.php index b7cdfbe0df..2da7222d7c 100644 --- a/src/wp-admin/site-editor.php +++ b/src/wp-admin/site-editor.php @@ -42,7 +42,7 @@ $current_screen->is_block_editor( true ); // Default to is-fullscreen-mode to avoid jumps in the UI. add_filter( 'admin_body_class', - static function( $classes ) { + static function ( $classes ) { return "$classes is-fullscreen-mode"; } ); diff --git a/src/wp-admin/upload.php b/src/wp-admin/upload.php index 13b54c5840..6d8c8462b7 100644 --- a/src/wp-admin/upload.php +++ b/src/wp-admin/upload.php @@ -144,7 +144,7 @@ if ( 'grid' === $mode ) { // Remove the error parameter added by deprecation of wp-admin/media.php. add_filter( 'removable_query_args', - function() { + function () { return array( 'error' ); }, 10, diff --git a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php index dedcb37882..8a560a8d49 100644 --- a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php +++ b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php @@ -187,7 +187,7 @@ if ( ! class_exists( 'TwentyTwenty_Customize' ) ) { 'settings' => 'accent_hue', 'description' => __( 'Apply a custom color for links, buttons, featured images.', 'twentytwenty' ), 'mode' => 'hue', - 'active_callback' => static function() use ( $wp_customize ) { + 'active_callback' => static function () use ( $wp_customize ) { return ( 'custom' === $wp_customize->get_setting( 'accent_hue_active' )->value() ); }, ) diff --git a/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize.php b/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize.php index d3af05ec42..903334089d 100644 --- a/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize.php +++ b/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize.php @@ -92,7 +92,7 @@ if ( ! class_exists( 'Twenty_Twenty_One_Customize' ) ) { array( 'capability' => 'edit_theme_options', 'default' => 'excerpt', - 'sanitize_callback' => static function( $value ) { + 'sanitize_callback' => static function ( $value ) { return 'excerpt' === $value || 'full' === $value ? $value : 'excerpt'; }, ) diff --git a/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php b/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php index 611ce3756f..39b3fb726f 100644 --- a/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php +++ b/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php @@ -153,7 +153,7 @@ class Twenty_Twenty_One_Dark_Mode { array( 'section' => 'colors', 'priority' => 100, - 'active_callback' => static function() { + 'active_callback' => static function () { return 127 >= Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( get_theme_mod( 'background_color', 'D1E4DD' ) ); }, ) @@ -165,7 +165,7 @@ class Twenty_Twenty_One_Dark_Mode { array( 'capability' => 'edit_theme_options', 'default' => false, - 'sanitize_callback' => static function( $value ) { + 'sanitize_callback' => static function ( $value ) { return (bool) $value; }, ) @@ -188,7 +188,7 @@ class Twenty_Twenty_One_Dark_Mode { 'label' => esc_html__( 'Dark Mode support', 'twentytwentyone' ), 'priority' => 110, 'description' => $description, - 'active_callback' => static function( $value ) { + 'active_callback' => static function ( $value ) { return 127 < Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( get_theme_mod( 'background_color', 'D1E4DD' ) ); }, ) @@ -200,7 +200,7 @@ class Twenty_Twenty_One_Dark_Mode { array( 'selector' => '#dark-mode-toggler', 'container_inclusive' => true, - 'render_callback' => function() { + 'render_callback' => function () { $attrs = ( $this->switch_should_render() ) ? array() : array( 'style' => 'display:none;' ); $this->the_html( $attrs ); }, diff --git a/src/wp-includes/block-supports/layout.php b/src/wp-includes/block-supports/layout.php index 519574238d..89713c772d 100644 --- a/src/wp-includes/block-supports/layout.php +++ b/src/wp-includes/block-supports/layout.php @@ -789,7 +789,7 @@ function wp_restore_group_inner_container( $block_content, $block ) { ); $updated_content = preg_replace_callback( $replace_regex, - static function( $matches ) { + static function ( $matches ) { return $matches[1] . '
' . $matches[2] . '
' . $matches[3]; }, $block_content diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 590f3706f7..3c88f7b4c3 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -532,7 +532,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { * * @return string Returns the block content. */ - $settings['render_callback'] = static function( $attributes, $content, $block ) use ( $template_path ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable + $settings['render_callback'] = static function ( $attributes, $content, $block ) use ( $template_path ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable ob_start(); require $template_path; return ob_get_clean(); diff --git a/src/wp-includes/blocks/index.php b/src/wp-includes/blocks/index.php index a966248c79..128a06bea2 100644 --- a/src/wp-includes/blocks/index.php +++ b/src/wp-includes/blocks/index.php @@ -87,7 +87,7 @@ function register_core_block_style_handles() { } } - $register_style = static function( $name, $filename, $style_handle ) use ( $blocks_url, $suffix, $wp_styles, $files ) { + $register_style = static function ( $name, $filename, $style_handle ) use ( $blocks_url, $suffix, $wp_styles, $files ) { $style_path = "{$name}/{$filename}{$suffix}.css"; $path = wp_normalize_path( BLOCKS_PATH . $style_path ); diff --git a/src/wp-includes/class-wp-customize-widgets.php b/src/wp-includes/class-wp-customize-widgets.php index 41a57dc66b..93006ef916 100644 --- a/src/wp-includes/class-wp-customize-widgets.php +++ b/src/wp-includes/class-wp-customize-widgets.php @@ -982,10 +982,10 @@ final class WP_Customize_Widgets { $args['transport'] = current_theme_supports( 'customize-selective-refresh-widgets' ) ? 'postMessage' : 'refresh'; } elseif ( preg_match( $this->setting_id_patterns['widget_instance'], $id, $matches ) ) { $id_base = $matches['id_base']; - $args['sanitize_callback'] = function( $value ) use ( $id_base ) { + $args['sanitize_callback'] = function ( $value ) use ( $id_base ) { return $this->sanitize_widget_instance( $value, $id_base ); }; - $args['sanitize_js_callback'] = function( $value ) use ( $id_base ) { + $args['sanitize_js_callback'] = function ( $value ) use ( $id_base ) { return $this->sanitize_widget_js_instance( $value, $id_base ); }; $args['transport'] = $this->is_widget_selective_refreshable( $matches['id_base'] ) ? 'postMessage' : 'refresh'; diff --git a/src/wp-includes/class-wp-http.php b/src/wp-includes/class-wp-http.php index 87a9342a92..056680ba40 100644 --- a/src/wp-includes/class-wp-http.php +++ b/src/wp-includes/class-wp-http.php @@ -463,7 +463,7 @@ class WP_Http { if ( $value instanceof WP_Http_Cookie ) { $attributes = array_filter( $value->get_attributes(), - static function( $attr ) { + static function ( $attr ) { return null !== $attr; } ); diff --git a/src/wp-includes/class-wp-navigation-fallback.php b/src/wp-includes/class-wp-navigation-fallback.php index fb97c643bb..bd9583d1fa 100644 --- a/src/wp-includes/class-wp-navigation-fallback.php +++ b/src/wp-includes/class-wp-navigation-fallback.php @@ -169,7 +169,7 @@ class WP_Navigation_Fallback { private static function get_most_recently_created_nav_menu( $classic_nav_menus ) { usort( $classic_nav_menus, - static function( $a, $b ) { + static function ( $a, $b ) { return $b->term_id - $a->term_id; } ); diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index 227398facd..95cbac23c3 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -2334,7 +2334,7 @@ class WP_Theme_JSON { // Prepend the variation selector to the current selector. $split_selectors = explode( ',', $shortened_selector ); $updated_selectors = array_map( - static function( $split_selector ) use ( $clean_style_variation_selector ) { + static function ( $split_selector ) use ( $clean_style_variation_selector ) { return $clean_style_variation_selector . $split_selector; }, $split_selectors @@ -2372,7 +2372,7 @@ class WP_Theme_JSON { $pseudo_matches = array_values( array_filter( $element_pseudo_allowed, - static function( $pseudo_selector ) use ( $selector ) { + static function ( $pseudo_selector ) use ( $selector ) { return str_contains( $selector, $pseudo_selector ); } ) @@ -3733,7 +3733,7 @@ class WP_Theme_JSON { $theme_vars = static::compute_theme_vars( $settings ); $vars = array_reduce( array_merge( $preset_vars, $theme_vars ), - function( $carry, $item ) { + function ( $carry, $item ) { $name = $item['name']; $carry[ "var({$name})" ] = $item['value']; return $carry; diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index fddd2b1aa1..05084329d3 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -3259,7 +3259,7 @@ function wp_rel_nofollow( $text ) { $text = stripslashes( $text ); $text = preg_replace_callback( '||i', - static function( $matches ) { + static function ( $matches ) { return wp_rel_callback( $matches, 'nofollow' ); }, $text @@ -3293,7 +3293,7 @@ function wp_rel_ugc( $text ) { $text = stripslashes( $text ); $text = preg_replace_callback( '||i', - static function( $matches ) { + static function ( $matches ) { return wp_rel_callback( $matches, 'nofollow ugc' ); }, $text @@ -4756,7 +4756,7 @@ EOF; $safe_text = (string) preg_replace_callback( $regex, - static function( $matches ) { + static function ( $matches ) { if ( ! isset( $matches[0] ) ) { return ''; } diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 6963de3a38..28975154c3 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -846,7 +846,7 @@ function wp_extract_urls( $content ) { $post_links = array_unique( array_map( - static function( $link ) { + static function ( $link ) { // Decode to replace valid entities, like &. $link = html_entity_decode( $link ); // Maintain backward compatibility by removing extraneous semi-colons (`;`). diff --git a/src/wp-includes/kses.php b/src/wp-includes/kses.php index 7eeadca569..f6bd75741d 100644 --- a/src/wp-includes/kses.php +++ b/src/wp-includes/kses.php @@ -1183,7 +1183,7 @@ function wp_kses_attr( $element, $attr, $allowed_html, $allowed_protocols ) { // Check if there are attributes that are required. $required_attrs = array_filter( $allowed_html[ $element_low ], - static function( $required_attr_limits ) { + static function ( $required_attr_limits ) { return isset( $required_attr_limits['required'] ) && true === $required_attr_limits['required']; } ); diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 2a8d6b41f6..e1af9227a5 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -6071,7 +6071,7 @@ function get_pages( $args = array() ) { */ $orderby = wp_parse_list( $parsed_args['sort_column'] ); $orderby = array_map( - static function( $orderby_field ) { + static function ( $orderby_field ) { $orderby_field = trim( $orderby_field ); if ( 'post_modified_gmt' === $orderby_field || 'modified_gmt' === $orderby_field ) { $orderby_field = str_replace( '_gmt', '', $orderby_field ); diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php index 81fc991ba9..4b960d6c6b 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php @@ -625,7 +625,7 @@ abstract class WP_REST_Controller { // Return the list of all requested fields which appear in the schema. return array_reduce( $requested_fields, - static function( $response_fields, $field ) use ( $fields ) { + static function ( $response_fields, $field ) use ( $fields ) { if ( in_array( $field, $fields, true ) ) { $response_fields[] = $field; return $response_fields; diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php index 4cbc5063e9..8d24b60db2 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php @@ -381,7 +381,7 @@ class WP_REST_Plugins_Controller extends WP_REST_Controller { $installed_locales = apply_filters( 'plugins_update_check_locales', $installed_locales ); $language_packs = array_map( - static function( $item ) { + static function ( $item ) { return (object) $item; }, $api->language_packs @@ -389,7 +389,7 @@ class WP_REST_Plugins_Controller extends WP_REST_Controller { $language_packs = array_filter( $language_packs, - static function( $pack ) use ( $installed_locales ) { + static function ( $pack ) use ( $installed_locales ) { return in_array( $pack->language, $installed_locales, true ); } ); diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php index 18d67dc2dd..41e15337ad 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php @@ -152,7 +152,7 @@ class WP_REST_Site_Health_Controller extends WP_REST_Controller { array( 'methods' => 'GET', 'callback' => array( $this, 'get_directory_sizes' ), - 'permission_callback' => function() { + 'permission_callback' => function () { return $this->validate_request_permission( 'directory_sizes' ) && ! is_multisite(); }, ) diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php index 9734ae6625..b01dd1649e 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php @@ -85,7 +85,7 @@ class WP_REST_Widget_Types_Controller extends WP_REST_Controller { 'form_data' => array( 'description' => __( 'Serialized widget form data to encode into instance settings.' ), 'type' => 'string', - 'sanitize_callback' => static function( $form_data ) { + 'sanitize_callback' => static function ( $form_data ) { $array = array(); wp_parse_str( $form_data, $array ); return $array; diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php index 267a75ffae..acbd88c489 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php @@ -861,7 +861,7 @@ class WP_REST_Widgets_Controller extends WP_REST_Controller { 'type' => 'string', 'context' => array(), 'arg_options' => array( - 'sanitize_callback' => static function( $form_data ) { + 'sanitize_callback' => static function ( $form_data ) { $array = array(); wp_parse_str( $form_data, $array ); return $array; diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index d99cc9b035..b51569f40c 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -2453,7 +2453,7 @@ function wp_common_block_scripts_and_styles() { function wp_filter_out_block_nodes( $nodes ) { return array_filter( $nodes, - static function( $node ) { + static function ( $node ) { return ! in_array( 'blocks', $node['path'], true ); }, ARRAY_FILTER_USE_BOTH @@ -2655,7 +2655,7 @@ function enqueue_block_styles_assets() { if ( wp_should_load_separate_core_block_assets() ) { add_filter( 'render_block', - static function( $html, $block ) use ( $block_name, $style_properties ) { + static function ( $html, $block ) use ( $block_name, $style_properties ) { if ( $block['blockName'] === $block_name ) { wp_enqueue_style( $style_properties['style_handle'] ); } @@ -2917,7 +2917,7 @@ function wp_maybe_inline_styles() { // Reorder styles array based on size. usort( $styles, - static function( $a, $b ) { + static function ( $a, $b ) { return ( $a['size'] <= $b['size'] ) ? -1 : 1; } ); @@ -3150,7 +3150,7 @@ function wp_enqueue_block_style( $block_name, $args ) { * is to ensure the content exists. * @return string Block content. */ - $callback = static function( $content ) use ( $args ) { + $callback = static function ( $content ) use ( $args ) { // Register the stylesheet. if ( ! empty( $args['src'] ) ) { wp_register_style( $args['handle'], $args['src'], $args['deps'], $args['ver'], $args['media'] ); @@ -3188,7 +3188,7 @@ function wp_enqueue_block_style( $block_name, $args ) { * @param array $block The full block, including name and attributes. * @return string Block content. */ - $callback_separate = static function( $content, $block ) use ( $block_name, $callback ) { + $callback_separate = static function ( $content, $block ) use ( $block_name, $callback ) { if ( ! empty( $block['blockName'] ) && $block_name === $block['blockName'] ) { return $callback( $content ); } diff --git a/src/wp-includes/update.php b/src/wp-includes/update.php index c5349832ac..e2ac6b8b54 100644 --- a/src/wp-includes/update.php +++ b/src/wp-includes/update.php @@ -553,7 +553,7 @@ function wp_update_plugins( $extra_stats = array() ) { } } - $sanitize_plugin_update_payload = static function( &$item ) { + $sanitize_plugin_update_payload = static function ( &$item ) { $item = (object) $item; unset( $item->translations, $item->compatibility ); diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php index aaba3a7e7e..fc40f4cd75 100644 --- a/src/wp-includes/user.php +++ b/src/wp-includes/user.php @@ -3899,7 +3899,7 @@ function wp_user_personal_data_exporter( $email_address ) { // Remove items that use reserved names. $extra_data = array_filter( $_extra_data, - static function( $item ) use ( $reserved_names ) { + static function ( $item ) use ( $reserved_names ) { return ! in_array( $item['name'], $reserved_names, true ); } ); diff --git a/tests/performance/wp-content/mu-plugins/server-timing.php b/tests/performance/wp-content/mu-plugins/server-timing.php index 9ae95561ec..4f9a0d04f1 100644 --- a/tests/performance/wp-content/mu-plugins/server-timing.php +++ b/tests/performance/wp-content/mu-plugins/server-timing.php @@ -2,7 +2,7 @@ add_filter( 'template_include', - static function( $template ) { + static function ( $template ) { global $timestart; @@ -15,7 +15,7 @@ add_filter( add_action( 'shutdown', - static function() use ( $server_timing_values, $template_start ) { + static function () use ( $server_timing_values, $template_start ) { global $timestart; diff --git a/tests/phpunit/tests/actions.php b/tests/phpunit/tests/actions.php index ae02973c5e..8b57382b9c 100644 --- a/tests/phpunit/tests/actions.php +++ b/tests/phpunit/tests/actions.php @@ -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 ); diff --git a/tests/phpunit/tests/admin/includesFile.php b/tests/phpunit/tests/admin/includesFile.php index 375f895c84..4a5295b29a 100644 --- a/tests/phpunit/tests/admin/includesFile.php +++ b/tests/phpunit/tests/admin/includesFile.php @@ -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; } diff --git a/tests/phpunit/tests/admin/includesPost.php b/tests/phpunit/tests/admin/includesPost.php index 4ce59dbabe..102449cc79 100644 --- a/tests/phpunit/tests/admin/includesPost.php +++ b/tests/phpunit/tests/admin/includesPost.php @@ -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; }, diff --git a/tests/phpunit/tests/admin/includesSchema.php b/tests/phpunit/tests/admin/includesSchema.php index f33dff148b..77b3e06a53 100644 --- a/tests/phpunit/tests/admin/includesSchema.php +++ b/tests/phpunit/tests/admin/includesSchema.php @@ -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'; } diff --git a/tests/phpunit/tests/admin/wpAutomaticUpdater.php b/tests/phpunit/tests/admin/wpAutomaticUpdater.php index eb91a97c09..1746d9490c 100644 --- a/tests/phpunit/tests/admin/wpAutomaticUpdater.php +++ b/tests/phpunit/tests/admin/wpAutomaticUpdater.php @@ -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, diff --git a/tests/phpunit/tests/admin/wpCommentsListTable.php b/tests/phpunit/tests/admin/wpCommentsListTable.php index dc440a117b..8ba12eed0e 100644 --- a/tests/phpunit/tests/admin/wpCommentsListTable.php +++ b/tests/phpunit/tests/admin/wpCommentsListTable.php @@ -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( diff --git a/tests/phpunit/tests/admin/wpSiteHealth.php b/tests/phpunit/tests/admin/wpSiteHealth.php index 0d7ccb6112..f8b2e2e0c8 100644 --- a/tests/phpunit/tests/admin/wpSiteHealth.php +++ b/tests/phpunit/tests/admin/wpSiteHealth.php @@ -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, diff --git a/tests/phpunit/tests/ajax/wpAjaxAddTag.php b/tests/phpunit/tests/ajax/wpAjaxAddTag.php index 6060b1db64..fbb65ff6ae 100755 --- a/tests/phpunit/tests/ajax/wpAjaxAddTag.php +++ b/tests/phpunit/tests/ajax/wpAjaxAddTag.php @@ -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; }, diff --git a/tests/phpunit/tests/ajax/wpAjaxAjaxTagSearch.php b/tests/phpunit/tests/ajax/wpAjaxAjaxTagSearch.php index fa41463c62..dbcc4cbe0f 100644 --- a/tests/phpunit/tests/ajax/wpAjaxAjaxTagSearch.php +++ b/tests/phpunit/tests/ajax/wpAjaxAjaxTagSearch.php @@ -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, diff --git a/tests/phpunit/tests/block-template.php b/tests/phpunit/tests/block-template.php index 3344b895bb..64260fb215 100644 --- a/tests/phpunit/tests/block-template.php +++ b/tests/phpunit/tests/block-template.php @@ -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 ''; }, diff --git a/tests/phpunit/tests/blocks/context.php b/tests/phpunit/tests/blocks/context.php index 68ead5d398..3edddcf8ef 100644 --- a/tests/phpunit/tests/blocks/context.php +++ b/tests/phpunit/tests/blocks/context.php @@ -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; }; diff --git a/tests/phpunit/tests/blocks/editor.php b/tests/phpunit/tests/blocks/editor.php index 1d008560e9..13dbf59556 100644 --- a/tests/phpunit/tests/blocks/editor.php +++ b/tests/phpunit/tests/blocks/editor.php @@ -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; } ); diff --git a/tests/phpunit/tests/blocks/getBlockTemplates.php b/tests/phpunit/tests/blocks/getBlockTemplates.php index 50554479d0..91f202a0b0 100644 --- a/tests/phpunit/tests/blocks/getBlockTemplates.php +++ b/tests/phpunit/tests/blocks/getBlockTemplates.php @@ -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 diff --git a/tests/phpunit/tests/blocks/register.php b/tests/phpunit/tests/blocks/register.php index 8ad1a88f3a..eb61f3c307 100644 --- a/tests/phpunit/tests/blocks/register.php +++ b/tests/phpunit/tests/blocks/register.php @@ -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; }; diff --git a/tests/phpunit/tests/blocks/renderCommentTemplate.php b/tests/phpunit/tests/blocks/renderCommentTemplate.php index 796bbcef86..0e29dc2241 100644 --- a/tests/phpunit/tests/blocks/renderCommentTemplate.php +++ b/tests/phpunit/tests/blocks/renderCommentTemplate.php @@ -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 = <<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'; }, ) diff --git a/tests/phpunit/tests/canonical.php b/tests/phpunit/tests/canonical.php index 6d16402112..10edea42bf 100644 --- a/tests/phpunit/tests/canonical.php +++ b/tests/phpunit/tests/canonical.php @@ -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'; } ); diff --git a/tests/phpunit/tests/category/walkerCategory.php b/tests/phpunit/tests/category/walkerCategory.php index 2728b11131..9e1ff4e094 100644 --- a/tests/phpunit/tests/category/walkerCategory.php +++ b/tests/phpunit/tests/category/walkerCategory.php @@ -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; } diff --git a/tests/phpunit/tests/cron.php b/tests/phpunit/tests/cron.php index 6369a244c6..ec97b366d0 100644 --- a/tests/phpunit/tests/cron.php +++ b/tests/phpunit/tests/cron.php @@ -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' ); } ); diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index ca88433713..37e751b294 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -2917,7 +2917,7 @@ HTML wp_set_script_translations( 'common' ); $print_scripts = get_echo( - static function() { + static function () { wp_print_scripts(); _print_scripts(); } diff --git a/tests/phpunit/tests/feed/rss2.php b/tests/phpunit/tests/feed/rss2.php index 6fd0ba8c15..9a45230d39 100644 --- a/tests/phpunit/tests/feed/rss2.php +++ b/tests/phpunit/tests/feed/rss2.php @@ -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 ), diff --git a/tests/phpunit/tests/file.php b/tests/phpunit/tests/file.php index 5102faab51..c99f1baffd 100644 --- a/tests/phpunit/tests/file.php +++ b/tests/phpunit/tests/file.php @@ -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; diff --git a/tests/phpunit/tests/formatting/wpTrimExcerpt.php b/tests/phpunit/tests/formatting/wpTrimExcerpt.php index 1cb4389ee9..ba5e99f7d8 100644 --- a/tests/phpunit/tests/formatting/wpTrimExcerpt.php +++ b/tests/phpunit/tests/formatting/wpTrimExcerpt.php @@ -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; } diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index 0a5703d94b..5c8a1aa25f 100644 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -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; } diff --git a/tests/phpunit/tests/functions/wpFilesize.php b/tests/phpunit/tests/functions/wpFilesize.php index f0e510ddc5..250f7e79c7 100644 --- a/tests/phpunit/tests/functions/wpFilesize.php +++ b/tests/phpunit/tests/functions/wpFilesize.php @@ -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; } ); diff --git a/tests/phpunit/tests/general/feedLinksExtra.php b/tests/phpunit/tests/general/feedLinksExtra.php index ee7f93640f..3bea946e1a 100644 --- a/tests/phpunit/tests/general/feedLinksExtra.php +++ b/tests/phpunit/tests/general/feedLinksExtra.php @@ -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'; } ); diff --git a/tests/phpunit/tests/http/http.php b/tests/phpunit/tests/http/http.php index 876a5ed60b..1648cca4ea 100644 --- a/tests/phpunit/tests/http/http.php +++ b/tests/phpunit/tests/http/http.php @@ -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. diff --git a/tests/phpunit/tests/https-detection.php b/tests/phpunit/tests/https-detection.php index 820f39fc6e..80f1684699 100644 --- a/tests/phpunit/tests/https-detection.php +++ b/tests/phpunit/tests/https-detection.php @@ -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 ); }; } diff --git a/tests/phpunit/tests/https-migration.php b/tests/phpunit/tests/https-migration.php index d06e1f0fba..ae66738603 100644 --- a/tests/phpunit/tests/https-migration.php +++ b/tests/phpunit/tests/https-migration.php @@ -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; } ); diff --git a/tests/phpunit/tests/image/editorImagick.php b/tests/phpunit/tests/image/editorImagick.php index 1209203904..30747f69f1 100644 --- a/tests/phpunit/tests/image/editorImagick.php +++ b/tests/phpunit/tests/image/editorImagick.php @@ -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 ) diff --git a/tests/phpunit/tests/image/functions.php b/tests/phpunit/tests/image/functions.php index 356b2dceac..f55b164496 100644 --- a/tests/phpunit/tests/image/functions.php +++ b/tests/phpunit/tests/image/functions.php @@ -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' ); } ); diff --git a/tests/phpunit/tests/image/intermediateSize.php b/tests/phpunit/tests/image/intermediateSize.php index 830359427a..e297bf8427 100644 --- a/tests/phpunit/tests/image/intermediateSize.php +++ b/tests/phpunit/tests/image/intermediateSize.php @@ -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' ); } ); diff --git a/tests/phpunit/tests/l10n/determineLocale.php b/tests/phpunit/tests/l10n/determineLocale.php index a2c3febd4a..51ab1c28b9 100644 --- a/tests/phpunit/tests/l10n/determineLocale.php +++ b/tests/phpunit/tests/l10n/determineLocale.php @@ -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'; } ); diff --git a/tests/phpunit/tests/link/editTermLink.php b/tests/phpunit/tests/link/editTermLink.php index 3128ddfe0e..2e0145e596 100644 --- a/tests/phpunit/tests/link/editTermLink.php +++ b/tests/phpunit/tests/link/editTermLink.php @@ -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, diff --git a/tests/phpunit/tests/link/getEditTermLink.php b/tests/phpunit/tests/link/getEditTermLink.php index 2df1aa7aac..d0303f1b1a 100644 --- a/tests/phpunit/tests/link/getEditTermLink.php +++ b/tests/phpunit/tests/link/getEditTermLink.php @@ -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, diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php index 545d1c854f..ebd2f767e1 100644 --- a/tests/phpunit/tests/media.php +++ b/tests/phpunit/tests/media.php @@ -2357,7 +2357,7 @@ EOF; add_filter( 'wp_content_img_tag', - static function( $filtered_image ) { + static function ( $filtered_image ) { return "$filtered_image"; } ); @@ -2381,7 +2381,7 @@ EOF; add_filter( 'wp_content_img_tag', - static function( $filtered_image ) { + static function ( $filtered_image ) { return "$filtered_image"; } ); @@ -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; } ); diff --git a/tests/phpunit/tests/media/wpGenerateAttachmentMetadata.php b/tests/phpunit/tests/media/wpGenerateAttachmentMetadata.php index 82fe7dabd6..fee7ebb577 100644 --- a/tests/phpunit/tests/media/wpGenerateAttachmentMetadata.php +++ b/tests/phpunit/tests/media/wpGenerateAttachmentMetadata.php @@ -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; } diff --git a/tests/phpunit/tests/media/wpImageTagAddDecodingAttr.php b/tests/phpunit/tests/media/wpImageTagAddDecodingAttr.php index 3ffe1bc6b4..7011d816da 100644 --- a/tests/phpunit/tests/media/wpImageTagAddDecodingAttr.php +++ b/tests/phpunit/tests/media/wpImageTagAddDecodingAttr.php @@ -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; } ); diff --git a/tests/phpunit/tests/menu/walker-nav-menu.php b/tests/phpunit/tests/menu/walker-nav-menu.php index 1fa255ef61..878bf12cc4 100644 --- a/tests/phpunit/tests/menu/walker-nav-menu.php +++ b/tests/phpunit/tests/menu/walker-nav-menu.php @@ -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; } diff --git a/tests/phpunit/tests/option/wpSetOptionAutoloadValues.php b/tests/phpunit/tests/option/wpSetOptionAutoloadValues.php index a49348db13..f474bd1093 100644 --- a/tests/phpunit/tests/option/wpSetOptionAutoloadValues.php +++ b/tests/phpunit/tests/option/wpSetOptionAutoloadValues.php @@ -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 ''; } diff --git a/tests/phpunit/tests/post/getPages.php b/tests/phpunit/tests/post/getPages.php index c0aa28564d..626f2a528c 100644 --- a/tests/phpunit/tests/post/getPages.php +++ b/tests/phpunit/tests/post/getPages.php @@ -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; diff --git a/tests/phpunit/tests/post/revisions.php b/tests/phpunit/tests/post/revisions.php index 8bdcb399b4..a4e45aefcf 100644 --- a/tests/phpunit/tests/post/revisions.php +++ b/tests/phpunit/tests/post/revisions.php @@ -883,7 +883,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { add_filter( 'wp_revisions_to_keep', - static function() { + static function () { return 1; } ); diff --git a/tests/phpunit/tests/post/thumbnails.php b/tests/phpunit/tests/post/thumbnails.php index 44801059a8..b06ec02570 100644 --- a/tests/phpunit/tests/post/thumbnails.php +++ b/tests/phpunit/tests/post/thumbnails.php @@ -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; }, diff --git a/tests/phpunit/tests/post/walkerPage.php b/tests/phpunit/tests/post/walkerPage.php index a5a632dcda..d8a2312a54 100644 --- a/tests/phpunit/tests/post/walkerPage.php +++ b/tests/phpunit/tests/post/walkerPage.php @@ -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; } diff --git a/tests/phpunit/tests/post/wpGetAttachmentLink.php b/tests/phpunit/tests/post/wpGetAttachmentLink.php index 2d658e002e..141b8a2427 100644 --- a/tests/phpunit/tests/post/wpGetAttachmentLink.php +++ b/tests/phpunit/tests/post/wpGetAttachmentLink.php @@ -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 ); } ); diff --git a/tests/phpunit/tests/query.php b/tests/phpunit/tests/query.php index 52c6ebfc12..37dd51a063 100644 --- a/tests/phpunit/tests/query.php +++ b/tests/phpunit/tests/query.php @@ -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 */'; } ); diff --git a/tests/phpunit/tests/query/conditionals.php b/tests/phpunit/tests/query/conditionals.php index 8eed70288b..05278ffd7a 100644 --- a/tests/phpunit/tests/query/conditionals.php +++ b/tests/phpunit/tests/query/conditionals.php @@ -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 diff --git a/tests/phpunit/tests/rest-api/rest-application-passwords-controller.php b/tests/phpunit/tests/rest-api/rest-application-passwords-controller.php index 0515c31512..96d1b193bb 100644 --- a/tests/phpunit/tests/rest-api/rest-application-passwords-controller.php +++ b/tests/phpunit/tests/rest-api/rest-application-passwords-controller.php @@ -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'; } ); diff --git a/tests/phpunit/tests/rest-api/rest-block-directory-controller.php b/tests/phpunit/tests/rest-api/rest-block-directory-controller.php index c3cac6011e..f61b317240 100644 --- a/tests/phpunit/tests/rest-api/rest-block-directory-controller.php +++ b/tests/phpunit/tests/rest-api/rest-block-directory-controller.php @@ -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( diff --git a/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php b/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php index 3c79da5651..3573ecb6e0 100644 --- a/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php +++ b/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php @@ -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 '

Alternate content.

'; } diff --git a/tests/phpunit/tests/rest-api/rest-pattern-directory-controller.php b/tests/phpunit/tests/rest-api/rest-pattern-directory-controller.php index d8f15013b9..eda42beebe 100644 --- a/tests/phpunit/tests/rest-api/rest-pattern-directory-controller.php +++ b/tests/phpunit/tests/rest-api/rest-pattern-directory-controller.php @@ -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 diff --git a/tests/phpunit/tests/rest-api/rest-plugins-controller.php b/tests/phpunit/tests/rest-api/rest-plugins-controller.php index 1375c81061..1da20c8315 100644 --- a/tests/phpunit/tests/rest-api/rest-plugins-controller.php +++ b/tests/phpunit/tests/rest-api/rest-plugins-controller.php @@ -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 diff --git a/tests/phpunit/tests/rest-api/rest-post-meta-fields.php b/tests/phpunit/tests/rest-api/rest-post-meta-fields.php index 2142e80582..11d06b86be 100644 --- a/tests/phpunit/tests/rest-api/rest-post-meta-fields.php +++ b/tests/phpunit/tests/rest-api/rest-post-meta-fields.php @@ -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'; }, ) diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php index 92d1262195..3b58464295 100644 --- a/tests/phpunit/tests/rest-api/rest-posts-controller.php +++ b/tests/phpunit/tests/rest-api/rest-posts-controller.php @@ -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 '

Filtered content.

'; }; @@ -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 '

Filtered content.

'; }; diff --git a/tests/phpunit/tests/rest-api/rest-server.php b/tests/phpunit/tests/rest-api/rest-server.php index b752b83872..a642d37c56 100644 --- a/tests/phpunit/tests/rest-api/rest-server.php +++ b/tests/phpunit/tests/rest-api/rest-server.php @@ -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', diff --git a/tests/phpunit/tests/rest-api/rest-widget-types-controller.php b/tests/phpunit/tests/rest-api/rest-widget-types-controller.php index e9b46d444f..cac586447e 100644 --- a/tests/phpunit/tests/rest-api/rest-widget-types-controller.php +++ b/tests/phpunit/tests/rest-api/rest-widget-types-controller.php @@ -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, '‘Legacy ‑ Archive ‑ Widget’', - static function() {}, + static function () {}, array( 'description' => '“A great & interesting archive of your site’s posts!”', ) diff --git a/tests/phpunit/tests/rest-api/wpRestUrlDetailsController.php b/tests/phpunit/tests/rest-api/wpRestUrlDetailsController.php index d811821052..27f526f9d2 100644 --- a/tests/phpunit/tests/rest-api/wpRestUrlDetailsController.php +++ b/tests/phpunit/tests/rest-api/wpRestUrlDetailsController.php @@ -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 'This value from cache.'; } ); @@ -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, diff --git a/tests/phpunit/tests/robots.php b/tests/phpunit/tests/robots.php index 87b0e6fb90..356224e79b 100644 --- a/tests/phpunit/tests/robots.php +++ b/tests/phpunit/tests/robots.php @@ -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'; diff --git a/tests/phpunit/tests/term/getTermLink.php b/tests/phpunit/tests/term/getTermLink.php index 2a92d8afee..94307ba697 100644 --- a/tests/phpunit/tests/term/getTermLink.php +++ b/tests/phpunit/tests/term/getTermLink.php @@ -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, diff --git a/tests/phpunit/tests/theme/customHeader.php b/tests/phpunit/tests/theme/customHeader.php index f78f6fc2af..b994d7f2dc 100644 --- a/tests/phpunit/tests/theme/customHeader.php +++ b/tests/phpunit/tests/theme/customHeader.php @@ -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 } ); diff --git a/tests/phpunit/tests/theme/wpThemeJsonResolver.php b/tests/phpunit/tests/theme/wpThemeJsonResolver.php index 98f67fea5d..cc7cfa2f65 100644 --- a/tests/phpunit/tests/theme/wpThemeJsonResolver.php +++ b/tests/phpunit/tests/theme/wpThemeJsonResolver.php @@ -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']; } ); diff --git a/tests/phpunit/tests/user/queryCache.php b/tests/phpunit/tests/user/queryCache.php index d8d26286a7..7e63907f74 100644 --- a/tests/phpunit/tests/user/queryCache.php +++ b/tests/phpunit/tests/user/queryCache.php @@ -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; }; diff --git a/tests/phpunit/tests/user/retrievePassword.php b/tests/phpunit/tests/user/retrievePassword.php index 861a2d9e96..c0f6f28c30 100644 --- a/tests/phpunit/tests/user/retrievePassword.php +++ b/tests/phpunit/tests/user/retrievePassword.php @@ -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' => '' ); } ); diff --git a/tests/phpunit/tests/widgets.php b/tests/phpunit/tests/widgets.php index fd3826ec3d..ab4115cff2 100644 --- a/tests/phpunit/tests/widgets.php +++ b/tests/phpunit/tests/widgets.php @@ -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' ),