Make WordPress Core


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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                                },
Note: See TracChangeset for help on using the changeset viewer.