Make WordPress Core

Changeset 51657


Ignore:
Timestamp:
08/26/2021 12:57:08 PM (5 years ago)
Author:
hellofromTonya
Message:

Coding Standards: Use static closures when not using $this.

When a closure does not use $this, it can be made static for improved performance.

Static closures are supported in PHP since PHP 5.4. ​

Props jrf, hellofromTonya, swissspidy, SergeyBiryukov.
See #53359.

Location:
trunk
Files:
54 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-blocks.php

    r51595 r51657  
    3232add_filter(
    3333        'admin_body_class',
    34         function( $classes ) {
     34        static function( $classes ) {
    3535                return "$classes is-fullscreen-mode";
    3636        }
  • trunk/src/wp-admin/includes/class-wp-community-events.php

    r49929 r51657  
    475475                $future_wordcamps = array_filter(
    476476                        $future_events,
    477                         function( $wordcamp ) {
     477                        static function( $wordcamp ) {
    478478                                return 'wordcamp' === $wordcamp['type'];
    479479                        }
  • trunk/src/wp-admin/includes/class-wp-site-health-auto-updates.php

    r50979 r51657  
    4242                $tests = array_filter( $tests );
    4343                $tests = array_map(
    44                         function( $test ) {
     44                        static function( $test ) {
    4545                                $test = (object) $test;
    4646
  • trunk/src/wp-admin/includes/update-core.php

    r51521 r51657  
    16591659        $dirs = array_filter(
    16601660                $dirs,
    1661                 function( $dir ) {
     1661                static function( $dir ) {
    16621662                        // Skip any node_modules directories.
    16631663                        return false === strpos( $dir, 'node_modules' );
  • trunk/src/wp-admin/options-privacy.php

    r50631 r51657  
    2121add_filter(
    2222        'admin_body_class',
    23         function( $body_class ) {
     23        static function( $body_class ) {
    2424                $body_class .= ' privacy-settings ';
    2525
  • trunk/src/wp-admin/privacy-policy-guide.php

    r50161 r51657  
    2020add_filter(
    2121        'admin_body_class',
    22         function( $body_class ) {
     22        static function( $body_class ) {
    2323                $body_class .= ' privacy-settings ';
    2424
  • trunk/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php

    r51322 r51657  
    187187                                                'description'     => __( 'Apply a custom color for links, buttons, featured images.', 'twentytwenty' ),
    188188                                                'mode'            => 'hue',
    189                                                 'active_callback' => function() use ( $wp_customize ) {
     189                                                'active_callback' => static function() use ( $wp_customize ) {
    190190                                                        return ( 'custom' === $wp_customize->get_setting( 'accent_hue_active' )->value() );
    191191                                                },
  • trunk/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize.php

    r51294 r51657  
    9393                                        'capability'        => 'edit_theme_options',
    9494                                        'default'           => 'excerpt',
    95                                         'sanitize_callback' => function( $value ) {
     95                                        'sanitize_callback' => static function( $value ) {
    9696                                                return 'excerpt' === $value || 'full' === $value ? $value : 'excerpt';
    9797                                        },
  • trunk/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php

    r51294 r51657  
    154154                                        'section'         => 'colors',
    155155                                        'priority'        => 100,
    156                                         'active_callback' => function() {
     156                                        'active_callback' => static function() {
    157157                                                return 127 >= Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( get_theme_mod( 'background_color', 'D1E4DD' ) );
    158158                                        },
     
    166166                                'capability'        => 'edit_theme_options',
    167167                                'default'           => false,
    168                                 'sanitize_callback' => function( $value ) {
     168                                'sanitize_callback' => static function( $value ) {
    169169                                        return (bool) $value;
    170170                                },
     
    189189                                'priority'        => 110,
    190190                                'description'     => $description,
    191                                 'active_callback' => function( $value ) {
     191                                'active_callback' => static function( $value ) {
    192192                                        return 127 < Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( get_theme_mod( 'background_color', 'D1E4DD' ) );
    193193                                },
  • trunk/src/wp-includes/block-supports/duotone.php

    r50929 r51657  
    362362        $selectors        = explode( ',', $duotone_support );
    363363        $selectors_scoped = array_map(
    364                 function ( $selector ) use ( $duotone_id ) {
     364                static function ( $selector ) use ( $duotone_id ) {
    365365                        return '.' . $duotone_id . ' ' . trim( $selector );
    366366                },
  • trunk/src/wp-includes/block-supports/layout.php

    r51301 r51657  
    132132        $updated_content = preg_replace_callback(
    133133                $replace_regex,
    134                 function( $matches ) {
     134                static function( $matches ) {
    135135                        return $matches[1] . '<div class="wp-block-group__inner-container">' . $matches[2] . '</div>' . $matches[3];
    136136                },
  • trunk/src/wp-includes/block-template.php

    r51321 r51657  
    125125        usort(
    126126                $templates,
    127                 function ( $template_a, $template_b ) use ( $slug_priorities ) {
     127                static function ( $template_a, $template_b ) use ( $slug_priorities ) {
    128128                        return $slug_priorities[ $template_a->slug ] - $slug_priorities[ $template_b->slug ];
    129129                }
  • trunk/src/wp-includes/class-wp-theme-json.php

    r51538 r51657  
    637637                $declaration_block = array_reduce(
    638638                        $declarations,
    639                         function ( $carry, $element ) {
     639                        static function ( $carry, $element ) {
    640640                                return $carry .= $element['name'] . ': ' . $element['value'] . ';'; },
    641641                        ''
  • trunk/src/wp-includes/formatting.php

    r51624 r51657  
    31143114        $text = preg_replace_callback(
    31153115                '|<a (.+?)>|i',
    3116                 function( $matches ) {
     3116                static function( $matches ) {
    31173117                        return wp_rel_callback( $matches, 'nofollow' );
    31183118                },
     
    31483148        $text = preg_replace_callback(
    31493149                '|<a (.+?)>|i',
    3150                 function( $matches ) {
     3150                static function( $matches ) {
    31513151                        return wp_rel_callback( $matches, 'nofollow ugc' );
    31523152                },
  • trunk/src/wp-includes/rest-api.php

    r51648 r51657  
    32283228        $status = array_reduce(
    32293229                $error->get_all_error_data(),
    3230                 function ( $status, $error_data ) {
     3230                static function ( $status, $error_data ) {
    32313231                        return is_array( $error_data ) && isset( $error_data['status'] ) ? $error_data['status'] : $status;
    32323232                },
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php

    r51278 r51657  
    598598                return array_reduce(
    599599                        $requested_fields,
    600                         function( $response_fields, $field ) use ( $fields ) {
     600                        static function( $response_fields, $field ) use ( $fields ) {
    601601                                if ( in_array( $field, $fields, true ) ) {
    602602                                        $response_fields[] = $field;
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php

    r51289 r51657  
    382382
    383383                $language_packs = array_map(
    384                         function( $item ) {
     384                        static function( $item ) {
    385385                                return (object) $item;
    386386                        },
     
    390390                $language_packs = array_filter(
    391391                        $language_packs,
    392                         function( $pack ) use ( $installed_locales ) {
     392                        static function( $pack ) use ( $installed_locales ) {
    393393                                return in_array( $pack->language, $installed_locales, true );
    394394                        }
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php

    r51286 r51657  
    8686                                                'description'       => __( 'Serialized widget form data to encode into instance settings.' ),
    8787                                                'type'              => 'string',
    88                                                 'sanitize_callback' => function( $string ) {
     88                                                'sanitize_callback' => static function( $string ) {
    8989                                                        $array = array();
    9090                                                        wp_parse_str( $string, $array );
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php

    r51432 r51657  
    793793                                        'context'     => array(),
    794794                                        'arg_options' => array(
    795                                                 'sanitize_callback' => function( $string ) {
     795                                                'sanitize_callback' => static function( $string ) {
    796796                                                        $array = array();
    797797                                                        wp_parse_str( $string, $array );
  • trunk/src/wp-includes/script-loader.php

    r51551 r51657  
    26932693                usort(
    26942694                        $styles,
    2695                         function( $a, $b ) {
     2695                        static function( $a, $b ) {
    26962696                                return ( $a['size'] <= $b['size'] ) ? -1 : 1;
    26972697                        }
  • trunk/src/wp-includes/update.php

    r50921 r51657  
    518518        }
    519519
    520         $sanitize_plugin_update_payload = function( &$item ) {
     520        $sanitize_plugin_update_payload = static function( &$item ) {
    521521                $item = (object) $item;
    522522
  • trunk/src/wp-includes/user.php

    r51410 r51657  
    34603460                $extra_data = array_filter(
    34613461                        $_extra_data,
    3462                         function( $item ) use ( $reserved_names ) {
     3462                        static function( $item ) use ( $reserved_names ) {
    34633463                                return ! in_array( $item['name'], $reserved_names, true );
    34643464                        }
  • trunk/tests/phpunit/includes/abstract-testcase.php

    r51608 r51657  
    720720                $expected = map_deep(
    721721                        $expected,
    722                         function ( $value ) {
     722                        static function ( $value ) {
    723723                                return str_replace( "\r\n", "\n", $value );
    724724                        }
     
    727727                $actual = map_deep(
    728728                        $actual,
    729                         function ( $value ) {
     729                        static function ( $value ) {
    730730                                return str_replace( "\r\n", "\n", $value );
    731731                        }
  • trunk/tests/phpunit/includes/plural-form-function.php

    r48790 r51657  
    88 */
    99function tests_make_plural_form_function( $nplurals, $expression ) {
    10         $closure = function ( $n ) use ( $nplurals, $expression ) {
     10        $closure = static function ( $n ) use ( $nplurals, $expression ) {
    1111                $expression = str_replace( 'n', $n, $expression );
    1212
  • trunk/tests/phpunit/tests/actions/closures.php

    r46586 r51657  
    1313        function test_action_closure() {
    1414                $tag     = 'test_action_closure';
    15                 $closure = function( $a, $b ) {
     15                $closure = static function( $a, $b ) {
    1616                        $GLOBALS[ $a ] = $b;
    1717                };
     
    2626
    2727                $tag2     = 'test_action_closure_2';
    28                 $closure2 = function() {
     28                $closure2 = static function() {
    2929                        $GLOBALS['closure_no_args'] = true;
    3030                };
  • trunk/tests/phpunit/tests/admin/includesListTable.php

    r51639 r51657  
    361361                add_filter(
    362362                        'bulk_actions-edit-comments',
    363                         function() {
     363                        static function() {
    364364                                return array(
    365365                                        'delete'       => 'Delete',
  • trunk/tests/phpunit/tests/block-template-utils.php

    r51079 r51657  
    7171                function get_template_ids( $templates ) {
    7272                        return array_map(
    73                                 function( $template ) {
     73                                static function( $template ) {
    7474                                        return $template->id;
    7575                                },
  • trunk/tests/phpunit/tests/blocks/context.php

    r51568 r51657  
    116116                                        'gutenberg/contextWithoutDefault',
    117117                                ),
    118                                 'render_callback' => function( $attributes, $content, $block ) use ( &$provided_context ) {
     118                                'render_callback' => static function( $attributes, $content, $block ) use ( &$provided_context ) {
    119119                                        $provided_context[] = $block->context;
    120120
     
    156156                        array(
    157157                                'uses_context'    => array( 'postId', 'postType' ),
    158                                 'render_callback' => function( $attributes, $content, $block ) use ( &$provided_context ) {
     158                                'render_callback' => static function( $attributes, $content, $block ) use ( &$provided_context ) {
    159159                                        $provided_context[] = $block->context;
    160160
     
    189189                        array(
    190190                                'uses_context'    => array( 'example' ),
    191                                 'render_callback' => function( $attributes, $content, $block ) use ( &$provided_context ) {
     191                                'render_callback' => static function( $attributes, $content, $block ) use ( &$provided_context ) {
    192192                                        $provided_context[] = $block->context;
    193193
     
    197197                );
    198198
    199                 $filter_block_context = function( $context ) {
     199                $filter_block_context = static function( $context ) {
    200200                        $context['example'] = 'ok';
    201201                        return $context;
  • trunk/tests/phpunit/tests/blocks/register.php

    r51599 r51657  
    511511         */
    512512        public function test_filter_block_registration() {
    513                 $filter_registration = function( $args, $name ) {
     513                $filter_registration = static function( $args, $name ) {
    514514                        $args['attributes'] = array( $name => array( 'type' => 'boolean' ) );
    515515                        return $args;
     
    529529         */
    530530        public function test_filter_block_registration_metadata() {
    531                 $filter_metadata_registration = function( $metadata ) {
     531                $filter_metadata_registration = static function( $metadata ) {
    532532                        $metadata['apiVersion'] = 3;
    533533                        return $metadata;
     
    547547         */
    548548        public function test_filter_block_registration_metadata_settings() {
    549                 $filter_metadata_registration = function( $settings, $metadata ) {
     549                $filter_metadata_registration = static function( $settings, $metadata ) {
    550550                        $settings['api_version'] = $metadata['apiVersion'] + 1;
    551551                        return $settings;
  • trunk/tests/phpunit/tests/blocks/supportedStyles.php

    r51568 r51657  
    713713                $errors = array();
    714714                set_error_handler(
    715                         function ( $errno = 0, $errstr = '' ) use ( &$errors ) {
     715                        static function ( $errno = 0, $errstr = '' ) use ( &$errors ) {
    716716                                $errors[] = $errstr;
    717717                                return false;
  • trunk/tests/phpunit/tests/blocks/wpBlock.php

    r51568 r51657  
    276276                        'core/dynamic',
    277277                        array(
    278                                 'render_callback' => function() {
     278                                'render_callback' => static function() {
    279279                                        return 'b';
    280280                                },
     
    297297                        'core/greeting',
    298298                        array(
    299                                 'render_callback' => function( $attributes, $content, $block ) {
     299                                'render_callback' => static function( $attributes, $content, $block ) {
    300300                                        return sprintf( 'Hello from %s', $block->name );
    301301                                },
     
    367367                                        ),
    368368                                ),
    369                                 'render_callback' => function( $block_attributes ) {
     369                                'render_callback' => static function( $block_attributes ) {
    370370                                        return sprintf(
    371371                                                'Hello %s%s',
     
    392392                        'core/outer',
    393393                        array(
    394                                 'render_callback' => function( $block_attributes, $content ) {
     394                                'render_callback' => static function( $block_attributes, $content ) {
    395395                                        return $content;
    396396                                },
     
    400400                        'core/inner',
    401401                        array(
    402                                 'render_callback' => function() {
     402                                'render_callback' => static function() {
    403403                                        return 'b';
    404404                                },
  • trunk/tests/phpunit/tests/canonical.php

    r51568 r51657  
    248248                add_filter(
    249249                        'pre_redirect_guess_404_permalink',
    250                         function() {
     250                        static function() {
    251251                                return 'wp';
    252252                        }
  • trunk/tests/phpunit/tests/category/walkerCategory.php

    r51568 r51657  
    3939                add_filter(
    4040                        'category_list_link_attributes',
    41                         function( $atts ) use ( $value ) {
     41                        static function( $atts ) use ( $value ) {
    4242                                $atts['data-test'] = $value;
    4343                                return $atts;
  • trunk/tests/phpunit/tests/comment/commentsTemplate.php

    r51462 r51657  
    994994                add_filter(
    995995                        'comments_template_query_args',
    996                         function ( $args ) use ( &$offset, $query_args ) {
     996                        static function ( $args ) use ( &$offset, $query_args ) {
    997997                                $offset = $args['offset'];
    998998
     
    10041004                        add_filter(
    10051005                                'comments_template_top_level_query_args',
    1006                                 function ( $args ) use ( $top_level_query_args ) {
     1006                                static function ( $args ) use ( $top_level_query_args ) {
    10071007                                        return array_merge( $args, $top_level_query_args );
    10081008                                }
  • trunk/tests/phpunit/tests/cron.php

    r51619 r51657  
    10561056                add_filter(
    10571057                        'pre_update_option_cron',
    1058                         function() {
     1058                        static function() {
    10591059                                return get_option( 'cron' );
    10601060                        }
     
    10761076                add_filter(
    10771077                        'pre_update_option_cron',
    1078                         function() {
     1078                        static function() {
    10791079                                return get_option( 'cron' );
    10801080                        }
     
    10991099                add_filter(
    11001100                        'pre_update_option_cron',
    1101                         function() {
     1101                        static function() {
    11021102                                return get_option( 'cron' );
    11031103                        }
     
    11231123                add_filter(
    11241124                        'pre_update_option_cron',
    1125                         function() {
     1125                        static function() {
    11261126                                return get_option( 'cron' );
    11271127                        }
  • trunk/tests/phpunit/tests/dependencies/wpInlineScriptTag.php

    r50409 r51657  
    8181                add_filter(
    8282                        'wp_inline_script_attributes',
    83                         function ( $attributes ) {
     83                        static function ( $attributes ) {
    8484                                if ( isset( $attributes['id'] ) && 'utils-js-extra' === $attributes['id'] ) {
    8585                                        $attributes['async'] = true;
  • trunk/tests/phpunit/tests/dependencies/wpScriptTag.php

    r50409 r51657  
    6565                add_filter(
    6666                        'wp_script_attributes',
    67                         function ( $attributes ) {
     67                        static function ( $attributes ) {
    6868                                if ( isset( $attributes['id'] ) && 'utils-js-extra' === $attributes['id'] ) {
    6969                                        $attributes['async'] = true;
  • trunk/tests/phpunit/tests/https-detection.php

    r51568 r51657  
    118118                add_filter(
    119119                        'pre_wp_update_https_detection_errors',
    120                         function() {
     120                        static function() {
    121121                                return new WP_Error();
    122122                        }
     
    128128                add_filter(
    129129                        'pre_wp_update_https_detection_errors',
    130                         function() {
     130                        static function() {
    131131                                return new WP_Error(
    132132                                        'ssl_verification_failed',
     
    346346         */
    347347        private function filter_set_url_scheme( $scheme ) {
    348                 return function( $url ) use ( $scheme ) {
     348                return static function( $url ) use ( $scheme ) {
    349349                        return set_url_scheme( $url, $scheme );
    350350                };
  • trunk/tests/phpunit/tests/https-migration.php

    r50284 r51657  
    162162                $scheme = $enabled ? 'https' : 'http';
    163163
    164                 $replace_scheme = function( $url ) use ( $scheme ) {
     164                $replace_scheme = static function( $url ) use ( $scheme ) {
    165165                        return str_replace( array( 'http://', 'https://' ), $scheme . '://', $url );
    166166                };
     
    173173                add_filter(
    174174                        "option_$option",
    175                         function() use ( $value ) {
     175                        static function() use ( $value ) {
    176176                                return $value;
    177177                        }
  • trunk/tests/phpunit/tests/image/intermediateSize.php

    r51568 r51657  
    7070                add_filter(
    7171                        'image_editor_output_format',
    72                         function() {
     72                        static function() {
    7373                                return array( 'image/jpeg' => 'image/webp' );
    7474                        }
  • trunk/tests/phpunit/tests/l10n/loadScriptTextdomain.php

    r50456 r51657  
    5050                                array(
    5151                                        'site_url',
    52                                         function ( $site_url ) {
     52                                        static function ( $site_url ) {
    5353                                                return $site_url . '/wp';
    5454                                        },
     
    6363                                array(
    6464                                        'plugins_url',
    65                                         function () {
     65                                        static function () {
    6666                                                return 'https://plugins.example.com';
    6767                                        },
     
    7676                                array(
    7777                                        'content_url',
    78                                         function () {
     78                                        static function () {
    7979                                                return 'https://content.example.com';
    8080                                        },
     
    8989                                array(
    9090                                        'content_url',
    91                                         function () {
     91                                        static function () {
    9292                                                return '/';
    9393                                        },
     
    102102                                array(
    103103                                        'plugins_url',
    104                                         function () {
     104                                        static function () {
    105105                                                return '/';
    106106                                        },
     
    115115                                array(
    116116                                        'site_url',
    117                                         function () {
     117                                        static function () {
    118118                                                return '/wp';
    119119                                        },
  • trunk/tests/phpunit/tests/menu/walker-nav-menu.php

    r51568 r51657  
    9595                add_filter(
    9696                        'nav_menu_link_attributes',
    97                         function( $atts ) use ( $value ) {
     97                        static function( $atts ) use ( $value ) {
    9898                                $atts['data-test'] = $value;
    9999                                return $atts;
  • trunk/tests/phpunit/tests/post/revisions.php

    r51568 r51657  
    595595                add_filter(
    596596                        'wp_revisions_to_keep',
    597                         function () use ( $expected ) {
     597                        static function () use ( $expected ) {
    598598                                return $expected;
    599599                        }
     
    620620                add_filter(
    621621                        'wp_revisions_to_keep',
    622                         function () use ( $generic ) {
     622                        static function () use ( $generic ) {
    623623                                return $generic;
    624624                        }
     
    631631                add_filter(
    632632                        "wp_{$post->post_type}_revisions_to_keep",
    633                         function () use ( $expected ) {
     633                        static function () use ( $expected ) {
    634634                                return $expected;
    635635                        }
  • trunk/tests/phpunit/tests/post/walkerPage.php

    r51568 r51657  
    3434                add_filter(
    3535                        'page_menu_link_attributes',
    36                         function( $atts ) use ( $value ) {
     36                        static function( $atts ) use ( $value ) {
    3737                                $atts['data-test'] = $value;
    3838                                return $atts;
  • trunk/tests/phpunit/tests/rest-api/rest-application-passwords-controller.php

    r51568 r51657  
    938938                add_action(
    939939                        'application_password_did_authenticate',
    940                         function() {
     940                        static function() {
    941941                                $GLOBALS['wp_rest_application_password_uuid'] = 'invalid_uuid';
    942942                        }
  • trunk/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php

    r51568 r51657  
    436436                wp_set_current_user( self::$user_id );
    437437
    438                 $pre_render_filter = function( $output, $block ) {
     438                $pre_render_filter = static function( $output, $block ) {
    439439                        if ( $block['blockName'] === self::$block_name ) {
    440440                                return '<p>Alternate content.</p>';
  • trunk/tests/phpunit/tests/rest-api/rest-pattern-directory-controller.php

    r51461 r51657  
    273273                add_filter(
    274274                        'rest_prepare_block_pattern',
    275                         function( $response ) {
     275                        static function( $response ) {
    276276                                return 'initial value';
    277277                        }
     
    287287                add_filter(
    288288                        'rest_prepare_block_pattern',
    289                         function( $response ) {
     289                        static function( $response ) {
    290290                                return 'modified the cache';
    291291                        },
  • trunk/tests/phpunit/tests/rest-api/rest-post-meta-fields.php

    r51571 r51657  
    27092709                                'type'              => 'boolean',
    27102710                                'show_in_rest'      => true,
    2711                                 'sanitize_callback' => function( $value ) {
     2711                                'sanitize_callback' => static function( $value ) {
    27122712                                        return $value ? '1' : '0';
    27132713                                },
  • trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php

    r51568 r51657  
    21382138        public function test_prepare_item_filters_content_when_needed() {
    21392139                $filter_count   = 0;
    2140                 $filter_content = function() use ( &$filter_count ) {
     2140                $filter_content = static function() use ( &$filter_count ) {
    21412141                        $filter_count++;
    21422142                        return '<p>Filtered content.</p>';
     
    21742174        public function test_prepare_item_skips_content_filter_if_not_needed() {
    21752175                $filter_count   = 0;
    2176                 $filter_content = function() use ( &$filter_count ) {
     2176                $filter_content = static function() use ( &$filter_count ) {
    21772177                        $filter_count++;
    21782178                        return '<p>Filtered content.</p>';
  • trunk/tests/phpunit/tests/rest-api/rest-request.php

    r51577 r51657  
    476476                                'args' => array(
    477477                                        'failparam' => array(
    478                                                 'sanitize_callback' => function () {
     478                                                'sanitize_callback' => static function () {
    479479                                                        $error = new WP_Error( 'invalid', 'Invalid.' );
    480480                                                        $error->add( 'invalid', 'Super Invalid.' );
     
    511511                                'args' => array(
    512512                                        'failparam' => array(
    513                                                 'sanitize_callback' => function () {
     513                                                'sanitize_callback' => static function () {
    514514                                                        return new WP_Error( 'invalid', 'Invalid.', 'mydata' );
    515515                                                },
     
    739739                                'args' => array(
    740740                                        'failparam' => array(
    741                                                 'validate_callback' => function () {
     741                                                'validate_callback' => static function () {
    742742                                                        $error = new WP_Error( 'invalid', 'Invalid.' );
    743743                                                        $error->add( 'invalid', 'Super Invalid.' );
     
    774774                                'args' => array(
    775775                                        'failparam' => array(
    776                                                 'validate_callback' => function () {
     776                                                'validate_callback' => static function () {
    777777                                                        return new WP_Error( 'invalid', 'Invalid.', 'mydata' );
    778778                                                },
  • trunk/tests/phpunit/tests/rest-api/rest-server.php

    r51577 r51657  
    13931393                        array(
    13941394                                'methods'             => array( 'GET' ),
    1395                                 'callback'            => function () {
     1395                                'callback'            => static function () {
    13961396                                        return new WP_REST_Response();
    13971397                                },
     
    14151415                        array(
    14161416                                'methods'             => array( 'GET' ),
    1417                                 'callback'            => function () {
     1417                                'callback'            => static function () {
    14181418                                        return new WP_REST_Response( 'data', 204 );
    14191419                                },
     
    15061506                        array(
    15071507                                'methods'             => array( 'GET' ),
    1508                                 'callback'            => function() {
     1508                                'callback'            => static function() {
    15091509                                        return new WP_REST_Response( 'data', 204 );
    15101510                                },
     
    15171517                        array(
    15181518                                'methods'             => array( 'GET' ),
    1519                                 'callback'            => function() {
     1519                                'callback'            => static function() {
    15201520                                        return new WP_REST_Response( 'data', 204 );
    15211521                                },
     
    19291929                        array(
    19301930                                'methods'             => array( 'POST', 'DELETE' ),
    1931                                 'callback'            => function ( WP_REST_Request $request ) {
     1931                                'callback'            => static function ( WP_REST_Request $request ) {
    19321932                                        return new WP_REST_Response( 'test' );
    19331933                                },
  • trunk/tests/phpunit/tests/rest-api/rest-widget-types-controller.php

    r51235 r51657  
    150150                $text_widgets = array_filter(
    151151                        $data,
    152                         function( $widget ) {
     152                        static function( $widget ) {
    153153                                return 'text' === $widget['id'];
    154154                        }
     
    178178                        $widget_id,
    179179                        'WP legacy widget',
    180                         function() {}
     180                        static function() {}
    181181                );
    182182                wp_set_current_user( self::$admin_id );
     
    209209                        $widget_id,
    210210                        '&#8216;Legacy &#8209; Archive &#8209; Widget&#8217;',
    211                         function() {},
     211                        static function() {},
    212212                        array(
    213213                                'description' => '&#8220;A great &amp; interesting archive of your site&#8217;s posts!&#8221;',
  • trunk/tests/phpunit/tests/rest-api/rest-widgets-controller.php

    r51568 r51657  
    109109                        'testwidget',
    110110                        'WP test widget',
    111                         function () {
     111                        static function () {
    112112                                $settings = get_option( 'widget_testwidget' );
    113113
     
    128128                        'testwidget',
    129129                        'WP test widget',
    130                         function () {
     130                        static function () {
    131131                                $settings = wp_parse_args(
    132132                                        get_option( 'widget_testwidget' ),
  • trunk/tests/phpunit/tests/robots.php

    r51568 r51657  
    4444                add_filter(
    4545                        'wp_robots',
    46                         function( array $robots ) {
     46                        static function( array $robots ) {
    4747                                // Directives that should have values must use strings.
    4848                                $robots['directive-with-value']         = 'yes';
Note: See TracChangeset for help on using the changeset viewer.