Make WordPress Core


Ignore:
Timestamp:
08/26/2021 12:57:08 PM (4 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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            '‘Legacy ‑ Archive ‑ Widget’',
    211             function() {},
     211            static function() {},
    212212            array(
    213213                'description' => '“A great & interesting archive of your site’s posts!”',
Note: See TracChangeset for help on using the changeset viewer.