Make WordPress Core

Changeset 53193


Ignore:
Timestamp:
04/17/2022 02:08:54 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Rename parameters that use reserved keywords in wp-admin/includes/menu.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 $classes in add_cssclass().
  • Renames the $add parameter to $class_to_add for clarity.
  • Includes minor code layout changes for better readability.

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192].

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

File:
1 edited

Legend:

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

    r47848 r53193  
    188188
    189189/**
    190  * @param string $add
    191  * @param string $class
     190 * @param string $class_to_add
     191 * @param string $classes
    192192 * @return string
    193193 */
    194 function add_cssclass( $add, $class ) {
    195     $class = empty( $class ) ? $add : $class .= ' ' . $add;
    196     return $class;
     194function add_cssclass( $class_to_add, $classes ) {
     195    if ( empty( $classes ) ) {
     196        return $class_to_add;
     197    }
     198
     199    return $classes . ' ' . $class_to_add;
    197200}
    198201
     
    352355
    353356$menu = add_menu_classes( $menu );
     357                       
Note: See TracChangeset for help on using the changeset viewer.