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/https-detection.php

    r51568 r51657  
    118118        add_filter(
    119119            'pre_wp_update_https_detection_errors',
    120             function() {
     120            static function() {
    121121                return new WP_Error();
    122122            }
     
    128128        add_filter(
    129129            'pre_wp_update_https_detection_errors',
    130             function() {
     130            static function() {
    131131                return new WP_Error(
    132132                    'ssl_verification_failed',
     
    346346     */
    347347    private function filter_set_url_scheme( $scheme ) {
    348         return function( $url ) use ( $scheme ) {
     348        return static function( $url ) use ( $scheme ) {
    349349            return set_url_scheme( $url, $scheme );
    350350        };
Note: See TracChangeset for help on using the changeset viewer.