Make WordPress Core

Changeset 53243


Ignore:
Timestamp:
04/22/2022 10:41:59 AM (2 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Rename parameters that use reserved keywords in wp_die_*_handler filters.

While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.

This commit renames the $function parameter to $callback in wp_die_*_handler filters, which aims to make it easier to use a non-reserved parameter name for anyone utilizing these filters.

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #55327.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r53202 r53243  
    36573657         * @since 3.4.0
    36583658         *
    3659          * @param callable $function Callback function name.
     3659         * @param callable $callback Callback function name.
    36603660         */
    3661         $function = apply_filters( 'wp_die_ajax_handler', '_ajax_wp_die_handler' );
     3661        $callback = apply_filters( 'wp_die_ajax_handler', '_ajax_wp_die_handler' );
    36623662    } elseif ( wp_is_json_request() ) {
    36633663        /**
     
    36663666         * @since 5.1.0
    36673667         *
    3668          * @param callable $function Callback function name.
     3668         * @param callable $callback Callback function name.
    36693669         */
    3670         $function = apply_filters( 'wp_die_json_handler', '_json_wp_die_handler' );
     3670        $callback = apply_filters( 'wp_die_json_handler', '_json_wp_die_handler' );
    36713671    } elseif ( defined( 'REST_REQUEST' ) && REST_REQUEST && wp_is_jsonp_request() ) {
    36723672        /**
     
    36753675         * @since 5.2.0
    36763676         *
    3677          * @param callable $function Callback function name.
     3677         * @param callable $callback Callback function name.
    36783678         */
    3679         $function = apply_filters( 'wp_die_jsonp_handler', '_jsonp_wp_die_handler' );
     3679        $callback = apply_filters( 'wp_die_jsonp_handler', '_jsonp_wp_die_handler' );
    36803680    } elseif ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) {
    36813681        /**
     
    36843684         * @since 3.4.0
    36853685         *
    3686          * @param callable $function Callback function name.
     3686         * @param callable $callback Callback function name.
    36873687         */
    3688         $function = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' );
     3688        $callback = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' );
    36893689    } elseif ( wp_is_xml_request()
    36903690        || isset( $wp_query ) &&
     
    36973697         * @since 5.2.0
    36983698         *
    3699          * @param callable $function Callback function name.
     3699         * @param callable $callback Callback function name.
    37003700         */
    3701         $function = apply_filters( 'wp_die_xml_handler', '_xml_wp_die_handler' );
     3701        $callback = apply_filters( 'wp_die_xml_handler', '_xml_wp_die_handler' );
    37023702    } else {
    37033703        /**
     
    37063706         * @since 3.0.0
    37073707         *
    3708          * @param callable $function Callback function name.
     3708         * @param callable $callback Callback function name.
    37093709         */
    3710         $function = apply_filters( 'wp_die_handler', '_default_wp_die_handler' );
    3711     }
    3712 
    3713     call_user_func( $function, $message, $title, $args );
     3710        $callback = apply_filters( 'wp_die_handler', '_default_wp_die_handler' );
     3711    }
     3712
     3713    call_user_func( $callback, $message, $title, $args );
    37143714}
    37153715
Note: See TracChangeset for help on using the changeset viewer.