Make WordPress Core


Ignore:
Timestamp:
08/26/2021 12:57:08 PM (3 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/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                }
Note: See TracChangeset for help on using the changeset viewer.