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.
Built from https://develop.svn.wordpress.org/trunk@56559


git-svn-id: http://core.svn.wordpress.org/trunk@56071 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2023-09-12 15:23:18 +00:00
parent 251a9c7653
commit e5490118af
32 changed files with 45 additions and 45 deletions

View File

@ -31,7 +31,7 @@ $current_screen->is_block_editor( true );
// Default to is-fullscreen-mode to avoid jumps in the UI. // Default to is-fullscreen-mode to avoid jumps in the UI.
add_filter( add_filter(
'admin_body_class', 'admin_body_class',
static function( $classes ) { static function ( $classes ) {
return "$classes is-fullscreen-mode"; return "$classes is-fullscreen-mode";
} }
); );

View File

@ -483,7 +483,7 @@ class WP_Community_Events {
$future_wordcamps = array_filter( $future_wordcamps = array_filter(
$future_events, $future_events,
static function( $wordcamp ) { static function ( $wordcamp ) {
return 'wordcamp' === $wordcamp['type']; return 'wordcamp' === $wordcamp['type'];
} }
); );

View File

@ -42,7 +42,7 @@ class WP_Site_Health_Auto_Updates {
$tests = array_filter( $tests ); $tests = array_filter( $tests );
$tests = array_map( $tests = array_map(
static function( $test ) { static function ( $test ) {
$test = (object) $test; $test = (object) $test;
if ( empty( $test->severity ) ) { if ( empty( $test->severity ) ) {

View File

@ -2726,7 +2726,7 @@ function wp_opcache_invalidate_directory( $dir ) {
* with sub-directories represented as nested arrays. * with sub-directories represented as nested arrays.
* @param string $path Absolute path to the directory. * @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 ); $path = trailingslashit( $path );
foreach ( $dirlist as $name => $details ) { foreach ( $dirlist as $name => $details ) {

View File

@ -1805,7 +1805,7 @@ function _upgrade_422_find_genericons_files_in_folder( $directory ) {
$dirs = glob( $directory . '*', GLOB_ONLYDIR ); $dirs = glob( $directory . '*', GLOB_ONLYDIR );
$dirs = array_filter( $dirs = array_filter(
$dirs, $dirs,
static function( $dir ) { static function ( $dir ) {
/* /*
* Skip any node_modules directories. * Skip any node_modules directories.
* *

View File

@ -23,7 +23,7 @@ $title = __( 'Privacy' );
add_filter( add_filter(
'admin_body_class', 'admin_body_class',
static function( $body_class ) { static function ( $body_class ) {
$body_class .= ' privacy-settings '; $body_class .= ' privacy-settings ';
return $body_class; return $body_class;

View File

@ -22,7 +22,7 @@ $title = __( 'Privacy Policy Guide' );
add_filter( add_filter(
'admin_body_class', 'admin_body_class',
static function( $body_class ) { static function ( $body_class ) {
$body_class .= ' privacy-settings '; $body_class .= ' privacy-settings ';
return $body_class; return $body_class;

View File

@ -42,7 +42,7 @@ $current_screen->is_block_editor( true );
// Default to is-fullscreen-mode to avoid jumps in the UI. // Default to is-fullscreen-mode to avoid jumps in the UI.
add_filter( add_filter(
'admin_body_class', 'admin_body_class',
static function( $classes ) { static function ( $classes ) {
return "$classes is-fullscreen-mode"; return "$classes is-fullscreen-mode";
} }
); );

View File

@ -144,7 +144,7 @@ if ( 'grid' === $mode ) {
// Remove the error parameter added by deprecation of wp-admin/media.php. // Remove the error parameter added by deprecation of wp-admin/media.php.
add_filter( add_filter(
'removable_query_args', 'removable_query_args',
function() { function () {
return array( 'error' ); return array( 'error' );
}, },
10, 10,

View File

@ -187,7 +187,7 @@ if ( ! class_exists( 'TwentyTwenty_Customize' ) ) {
'settings' => 'accent_hue', 'settings' => 'accent_hue',
'description' => __( 'Apply a custom color for links, buttons, featured images.', 'twentytwenty' ), 'description' => __( 'Apply a custom color for links, buttons, featured images.', 'twentytwenty' ),
'mode' => 'hue', '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() ); return ( 'custom' === $wp_customize->get_setting( 'accent_hue_active' )->value() );
}, },
) )

View File

@ -92,7 +92,7 @@ if ( ! class_exists( 'Twenty_Twenty_One_Customize' ) ) {
array( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => 'excerpt', 'default' => 'excerpt',
'sanitize_callback' => static function( $value ) { 'sanitize_callback' => static function ( $value ) {
return 'excerpt' === $value || 'full' === $value ? $value : 'excerpt'; return 'excerpt' === $value || 'full' === $value ? $value : 'excerpt';
}, },
) )

View File

@ -153,7 +153,7 @@ class Twenty_Twenty_One_Dark_Mode {
array( array(
'section' => 'colors', 'section' => 'colors',
'priority' => 100, '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' ) ); 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( array(
'capability' => 'edit_theme_options', 'capability' => 'edit_theme_options',
'default' => false, 'default' => false,
'sanitize_callback' => static function( $value ) { 'sanitize_callback' => static function ( $value ) {
return (bool) $value; return (bool) $value;
}, },
) )
@ -188,7 +188,7 @@ class Twenty_Twenty_One_Dark_Mode {
'label' => esc_html__( 'Dark Mode support', 'twentytwentyone' ), 'label' => esc_html__( 'Dark Mode support', 'twentytwentyone' ),
'priority' => 110, 'priority' => 110,
'description' => $description, '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' ) ); 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( array(
'selector' => '#dark-mode-toggler', 'selector' => '#dark-mode-toggler',
'container_inclusive' => true, 'container_inclusive' => true,
'render_callback' => function() { 'render_callback' => function () {
$attrs = ( $this->switch_should_render() ) ? array() : array( 'style' => 'display:none;' ); $attrs = ( $this->switch_should_render() ) ? array() : array( 'style' => 'display:none;' );
$this->the_html( $attrs ); $this->the_html( $attrs );
}, },

View File

@ -789,7 +789,7 @@ function wp_restore_group_inner_container( $block_content, $block ) {
); );
$updated_content = preg_replace_callback( $updated_content = preg_replace_callback(
$replace_regex, $replace_regex,
static function( $matches ) { static function ( $matches ) {
return $matches[1] . '<div class="wp-block-group__inner-container">' . $matches[2] . '</div>' . $matches[3]; return $matches[1] . '<div class="wp-block-group__inner-container">' . $matches[2] . '</div>' . $matches[3];
}, },
$block_content $block_content

View File

@ -532,7 +532,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) {
* *
* @return string Returns the block content. * @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(); ob_start();
require $template_path; require $template_path;
return ob_get_clean(); return ob_get_clean();

View File

@ -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"; $style_path = "{$name}/{$filename}{$suffix}.css";
$path = wp_normalize_path( BLOCKS_PATH . $style_path ); $path = wp_normalize_path( BLOCKS_PATH . $style_path );

View File

@ -982,10 +982,10 @@ final class WP_Customize_Widgets {
$args['transport'] = current_theme_supports( 'customize-selective-refresh-widgets' ) ? 'postMessage' : 'refresh'; $args['transport'] = current_theme_supports( 'customize-selective-refresh-widgets' ) ? 'postMessage' : 'refresh';
} elseif ( preg_match( $this->setting_id_patterns['widget_instance'], $id, $matches ) ) { } elseif ( preg_match( $this->setting_id_patterns['widget_instance'], $id, $matches ) ) {
$id_base = $matches['id_base']; $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 ); 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 ); return $this->sanitize_widget_js_instance( $value, $id_base );
}; };
$args['transport'] = $this->is_widget_selective_refreshable( $matches['id_base'] ) ? 'postMessage' : 'refresh'; $args['transport'] = $this->is_widget_selective_refreshable( $matches['id_base'] ) ? 'postMessage' : 'refresh';

View File

@ -463,7 +463,7 @@ class WP_Http {
if ( $value instanceof WP_Http_Cookie ) { if ( $value instanceof WP_Http_Cookie ) {
$attributes = array_filter( $attributes = array_filter(
$value->get_attributes(), $value->get_attributes(),
static function( $attr ) { static function ( $attr ) {
return null !== $attr; return null !== $attr;
} }
); );

View File

@ -169,7 +169,7 @@ class WP_Navigation_Fallback {
private static function get_most_recently_created_nav_menu( $classic_nav_menus ) { private static function get_most_recently_created_nav_menu( $classic_nav_menus ) {
usort( usort(
$classic_nav_menus, $classic_nav_menus,
static function( $a, $b ) { static function ( $a, $b ) {
return $b->term_id - $a->term_id; return $b->term_id - $a->term_id;
} }
); );

View File

@ -2334,7 +2334,7 @@ class WP_Theme_JSON {
// Prepend the variation selector to the current selector. // Prepend the variation selector to the current selector.
$split_selectors = explode( ',', $shortened_selector ); $split_selectors = explode( ',', $shortened_selector );
$updated_selectors = array_map( $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; return $clean_style_variation_selector . $split_selector;
}, },
$split_selectors $split_selectors
@ -2372,7 +2372,7 @@ class WP_Theme_JSON {
$pseudo_matches = array_values( $pseudo_matches = array_values(
array_filter( array_filter(
$element_pseudo_allowed, $element_pseudo_allowed,
static function( $pseudo_selector ) use ( $selector ) { static function ( $pseudo_selector ) use ( $selector ) {
return str_contains( $selector, $pseudo_selector ); return str_contains( $selector, $pseudo_selector );
} }
) )
@ -3733,7 +3733,7 @@ class WP_Theme_JSON {
$theme_vars = static::compute_theme_vars( $settings ); $theme_vars = static::compute_theme_vars( $settings );
$vars = array_reduce( $vars = array_reduce(
array_merge( $preset_vars, $theme_vars ), array_merge( $preset_vars, $theme_vars ),
function( $carry, $item ) { function ( $carry, $item ) {
$name = $item['name']; $name = $item['name'];
$carry[ "var({$name})" ] = $item['value']; $carry[ "var({$name})" ] = $item['value'];
return $carry; return $carry;

View File

@ -3259,7 +3259,7 @@ function wp_rel_nofollow( $text ) {
$text = stripslashes( $text ); $text = stripslashes( $text );
$text = preg_replace_callback( $text = preg_replace_callback(
'|<a (.+?)>|i', '|<a (.+?)>|i',
static function( $matches ) { static function ( $matches ) {
return wp_rel_callback( $matches, 'nofollow' ); return wp_rel_callback( $matches, 'nofollow' );
}, },
$text $text
@ -3293,7 +3293,7 @@ function wp_rel_ugc( $text ) {
$text = stripslashes( $text ); $text = stripslashes( $text );
$text = preg_replace_callback( $text = preg_replace_callback(
'|<a (.+?)>|i', '|<a (.+?)>|i',
static function( $matches ) { static function ( $matches ) {
return wp_rel_callback( $matches, 'nofollow ugc' ); return wp_rel_callback( $matches, 'nofollow ugc' );
}, },
$text $text
@ -4756,7 +4756,7 @@ EOF;
$safe_text = (string) preg_replace_callback( $safe_text = (string) preg_replace_callback(
$regex, $regex,
static function( $matches ) { static function ( $matches ) {
if ( ! isset( $matches[0] ) ) { if ( ! isset( $matches[0] ) ) {
return ''; return '';
} }

View File

@ -846,7 +846,7 @@ function wp_extract_urls( $content ) {
$post_links = array_unique( $post_links = array_unique(
array_map( array_map(
static function( $link ) { static function ( $link ) {
// Decode to replace valid entities, like &amp;. // Decode to replace valid entities, like &amp;.
$link = html_entity_decode( $link ); $link = html_entity_decode( $link );
// Maintain backward compatibility by removing extraneous semi-colons (`;`). // Maintain backward compatibility by removing extraneous semi-colons (`;`).

View File

@ -1183,7 +1183,7 @@ function wp_kses_attr( $element, $attr, $allowed_html, $allowed_protocols ) {
// Check if there are attributes that are required. // Check if there are attributes that are required.
$required_attrs = array_filter( $required_attrs = array_filter(
$allowed_html[ $element_low ], $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']; return isset( $required_attr_limits['required'] ) && true === $required_attr_limits['required'];
} }
); );

View File

@ -6071,7 +6071,7 @@ function get_pages( $args = array() ) {
*/ */
$orderby = wp_parse_list( $parsed_args['sort_column'] ); $orderby = wp_parse_list( $parsed_args['sort_column'] );
$orderby = array_map( $orderby = array_map(
static function( $orderby_field ) { static function ( $orderby_field ) {
$orderby_field = trim( $orderby_field ); $orderby_field = trim( $orderby_field );
if ( 'post_modified_gmt' === $orderby_field || 'modified_gmt' === $orderby_field ) { if ( 'post_modified_gmt' === $orderby_field || 'modified_gmt' === $orderby_field ) {
$orderby_field = str_replace( '_gmt', '', $orderby_field ); $orderby_field = str_replace( '_gmt', '', $orderby_field );

View File

@ -625,7 +625,7 @@ abstract class WP_REST_Controller {
// Return the list of all requested fields which appear in the schema. // Return the list of all requested fields which appear in the schema.
return array_reduce( return array_reduce(
$requested_fields, $requested_fields,
static function( $response_fields, $field ) use ( $fields ) { static function ( $response_fields, $field ) use ( $fields ) {
if ( in_array( $field, $fields, true ) ) { if ( in_array( $field, $fields, true ) ) {
$response_fields[] = $field; $response_fields[] = $field;
return $response_fields; return $response_fields;

View File

@ -381,7 +381,7 @@ class WP_REST_Plugins_Controller extends WP_REST_Controller {
$installed_locales = apply_filters( 'plugins_update_check_locales', $installed_locales ); $installed_locales = apply_filters( 'plugins_update_check_locales', $installed_locales );
$language_packs = array_map( $language_packs = array_map(
static function( $item ) { static function ( $item ) {
return (object) $item; return (object) $item;
}, },
$api->language_packs $api->language_packs
@ -389,7 +389,7 @@ class WP_REST_Plugins_Controller extends WP_REST_Controller {
$language_packs = array_filter( $language_packs = array_filter(
$language_packs, $language_packs,
static function( $pack ) use ( $installed_locales ) { static function ( $pack ) use ( $installed_locales ) {
return in_array( $pack->language, $installed_locales, true ); return in_array( $pack->language, $installed_locales, true );
} }
); );

View File

@ -152,7 +152,7 @@ class WP_REST_Site_Health_Controller extends WP_REST_Controller {
array( array(
'methods' => 'GET', 'methods' => 'GET',
'callback' => array( $this, 'get_directory_sizes' ), 'callback' => array( $this, 'get_directory_sizes' ),
'permission_callback' => function() { 'permission_callback' => function () {
return $this->validate_request_permission( 'directory_sizes' ) && ! is_multisite(); return $this->validate_request_permission( 'directory_sizes' ) && ! is_multisite();
}, },
) )

View File

@ -85,7 +85,7 @@ class WP_REST_Widget_Types_Controller extends WP_REST_Controller {
'form_data' => array( 'form_data' => array(
'description' => __( 'Serialized widget form data to encode into instance settings.' ), 'description' => __( 'Serialized widget form data to encode into instance settings.' ),
'type' => 'string', 'type' => 'string',
'sanitize_callback' => static function( $form_data ) { 'sanitize_callback' => static function ( $form_data ) {
$array = array(); $array = array();
wp_parse_str( $form_data, $array ); wp_parse_str( $form_data, $array );
return $array; return $array;

View File

@ -861,7 +861,7 @@ class WP_REST_Widgets_Controller extends WP_REST_Controller {
'type' => 'string', 'type' => 'string',
'context' => array(), 'context' => array(),
'arg_options' => array( 'arg_options' => array(
'sanitize_callback' => static function( $form_data ) { 'sanitize_callback' => static function ( $form_data ) {
$array = array(); $array = array();
wp_parse_str( $form_data, $array ); wp_parse_str( $form_data, $array );
return $array; return $array;

View File

@ -2453,7 +2453,7 @@ function wp_common_block_scripts_and_styles() {
function wp_filter_out_block_nodes( $nodes ) { function wp_filter_out_block_nodes( $nodes ) {
return array_filter( return array_filter(
$nodes, $nodes,
static function( $node ) { static function ( $node ) {
return ! in_array( 'blocks', $node['path'], true ); return ! in_array( 'blocks', $node['path'], true );
}, },
ARRAY_FILTER_USE_BOTH ARRAY_FILTER_USE_BOTH
@ -2655,7 +2655,7 @@ function enqueue_block_styles_assets() {
if ( wp_should_load_separate_core_block_assets() ) { if ( wp_should_load_separate_core_block_assets() ) {
add_filter( add_filter(
'render_block', '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 ) { if ( $block['blockName'] === $block_name ) {
wp_enqueue_style( $style_properties['style_handle'] ); wp_enqueue_style( $style_properties['style_handle'] );
} }
@ -2917,7 +2917,7 @@ function wp_maybe_inline_styles() {
// Reorder styles array based on size. // Reorder styles array based on size.
usort( usort(
$styles, $styles,
static function( $a, $b ) { static function ( $a, $b ) {
return ( $a['size'] <= $b['size'] ) ? -1 : 1; 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. * is to ensure the content exists.
* @return string Block content. * @return string Block content.
*/ */
$callback = static function( $content ) use ( $args ) { $callback = static function ( $content ) use ( $args ) {
// Register the stylesheet. // Register the stylesheet.
if ( ! empty( $args['src'] ) ) { if ( ! empty( $args['src'] ) ) {
wp_register_style( $args['handle'], $args['src'], $args['deps'], $args['ver'], $args['media'] ); 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. * @param array $block The full block, including name and attributes.
* @return string Block content. * @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'] ) { if ( ! empty( $block['blockName'] ) && $block_name === $block['blockName'] ) {
return $callback( $content ); return $callback( $content );
} }

View File

@ -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; $item = (object) $item;
unset( $item->translations, $item->compatibility ); unset( $item->translations, $item->compatibility );

View File

@ -3899,7 +3899,7 @@ function wp_user_personal_data_exporter( $email_address ) {
// Remove items that use reserved names. // Remove items that use reserved names.
$extra_data = array_filter( $extra_data = array_filter(
$_extra_data, $_extra_data,
static function( $item ) use ( $reserved_names ) { static function ( $item ) use ( $reserved_names ) {
return ! in_array( $item['name'], $reserved_names, true ); return ! in_array( $item['name'], $reserved_names, true );
} }
); );

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.4-alpha-56558'; $wp_version = '6.4-alpha-56559';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.