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/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                        }
Note: See TracChangeset for help on using the changeset viewer.