Make WordPress Core

Changeset 53198


Ignore:
Timestamp:
04/17/2022 03:35:34 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Rename parameters that use reserved keywords in wp-admin/includes/meta-boxes.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 $xfn_relationship in xfn_check().
  • Renames the $value parameter to $xfn_value for clarity.
  • Includes minor code layout changes for better readability.

Reference: XFN: Getting Started.

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

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

File:
1 edited

Legend:

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

    r52978 r53198  
    11871187 * @global object $link
    11881188 *
    1189  * @param string $class
    1190  * @param string $value
     1189 * @param string $xfn_relationship
     1190 * @param string $xfn_value
    11911191 * @param mixed  $deprecated Never used.
    11921192 */
    1193 function xfn_check( $class, $value = '', $deprecated = '' ) {
     1193function xfn_check( $xfn_relationship, $xfn_value = '', $deprecated = '' ) {
    11941194    global $link;
    11951195
     
    12011201    $rels     = preg_split( '/\s+/', $link_rel );
    12021202
    1203     if ( '' !== $value && in_array( $value, $rels, true ) ) {
     1203    if ( '' !== $xfn_value && in_array( $xfn_value, $rels, true ) ) {
    12041204        echo ' checked="checked"';
    12051205    }
    12061206
    1207     if ( '' === $value ) {
    1208         if ( 'family' === $class && strpos( $link_rel, 'child' ) === false && strpos( $link_rel, 'parent' ) === false && strpos( $link_rel, 'sibling' ) === false && strpos( $link_rel, 'spouse' ) === false && strpos( $link_rel, 'kin' ) === false ) {
     1207    if ( '' === $xfn_value ) {
     1208        if ( 'family' === $xfn_relationship
     1209            && strpos( $link_rel, 'child' ) === false
     1210            && strpos( $link_rel, 'parent' ) === false
     1211            && strpos( $link_rel, 'sibling' ) === false
     1212            && strpos( $link_rel, 'spouse' ) === false
     1213            && strpos( $link_rel, 'kin' ) === false
     1214        ) {
    12091215            echo ' checked="checked"';
    12101216        }
    1211         if ( 'friendship' === $class && strpos( $link_rel, 'friend' ) === false && strpos( $link_rel, 'acquaintance' ) === false && strpos( $link_rel, 'contact' ) === false ) {
     1217
     1218        if ( 'friendship' === $xfn_relationship
     1219            && strpos( $link_rel, 'friend' ) === false
     1220            && strpos( $link_rel, 'acquaintance' ) === false
     1221            && strpos( $link_rel, 'contact' ) === false ) {
    12121222            echo ' checked="checked"';
    12131223        }
    1214         if ( 'geographical' === $class && strpos( $link_rel, 'co-resident' ) === false && strpos( $link_rel, 'neighbor' ) === false ) {
     1224
     1225        if ( 'geographical' === $xfn_relationship
     1226            && strpos( $link_rel, 'co-resident' ) === false
     1227            && strpos( $link_rel, 'neighbor' ) === false
     1228        ) {
    12151229            echo ' checked="checked"';
    12161230        }
    1217         if ( 'identity' === $class && in_array( 'me', $rels, true ) ) {
     1231
     1232        if ( 'identity' === $xfn_relationship
     1233            && in_array( 'me', $rels, true )
     1234        ) {
    12181235            echo ' checked="checked"';
    12191236        }
Note: See TracChangeset for help on using the changeset viewer.