Make WordPress Core

Changeset 55162


Ignore:
Timestamp:
01/30/2023 02:13:49 PM (14 months ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Rename parameters that use reserved keywords in wp-includes/formatting.php.

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 $class parameter to $classname in sanitize_html_class().

Follow-up to [54927].

See also: equivalent commits for other files.

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

File:
1 edited

Legend:

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

    r55051 r55162  
    24062406 * @since 2.8.0
    24072407 *
    2408  * @param string $class    The classname to be sanitized
    2409  * @param string $fallback Optional. The value to return if the sanitization ends up as an empty string.
    2410  *  Defaults to an empty string.
    2411  * @return string The sanitized value
    2412  */
    2413 function sanitize_html_class( $class, $fallback = '' ) {
     2408 * @param string $classname The classname to be sanitized.
     2409 * @param string $fallback  Optional. The value to return if the sanitization ends up as an empty string.
     2410 *                          Default empty string.
     2411 * @return string The sanitized value.
     2412 */
     2413function sanitize_html_class( $classname, $fallback = '' ) {
    24142414    // Strip out any %-encoded octets.
    2415     $sanitized = preg_replace( '|%[a-fA-F0-9][a-fA-F0-9]|', '', $class );
     2415    $sanitized = preg_replace( '|%[a-fA-F0-9][a-fA-F0-9]|', '', $classname );
    24162416
    24172417    // Limit to A-Z, a-z, 0-9, '_', '-'.
     
    24272427     *
    24282428     * @param string $sanitized The sanitized HTML class.
    2429      * @param string $class    HTML class before sanitization.
     2429     * @param string $classname HTML class before sanitization.
    24302430     * @param string $fallback  The fallback string.
    24312431     */
    2432     return apply_filters( 'sanitize_html_class', $sanitized, $class, $fallback );
     2432    return apply_filters( 'sanitize_html_class', $sanitized, $classname, $fallback );
    24332433}
    24342434
Note: See TracChangeset for help on using the changeset viewer.