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/src/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php

    r51289 r51657  
    382382
    383383        $language_packs = array_map(
    384             function( $item ) {
     384            static function( $item ) {
    385385                return (object) $item;
    386386            },
     
    390390        $language_packs = array_filter(
    391391            $language_packs,
    392             function( $pack ) use ( $installed_locales ) {
     392            static function( $pack ) use ( $installed_locales ) {
    393393                return in_array( $pack->language, $installed_locales, true );
    394394            }
Note: See TracChangeset for help on using the changeset viewer.