Make WordPress Core


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