Make WordPress Core


Ignore:
Timestamp:
10/08/2020 09:13:57 PM (4 years ago)
Author:
SergeyBiryukov
Message:

General: Replace older-style PHP type conversion functions with type casts.

This improves performance, readability, and consistency throughout core.

  • intval()(int)
  • strval()(string)
  • floatval()(float)

Props ayeshrajans.
Fixes #42918.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php

    r47428 r49108  
    172172        }
    173173
    174         $this->post_id = intval( $matches['id'] );
     174        $this->post_id = (int) $matches['id'];
    175175        add_action( 'wp_update_nav_menu_item', array( $this, 'flush_cached_value' ), 10, 2 );
    176176
     
    369369        foreach ( array( 'object_id', 'menu_item_parent', 'nav_menu_term_id' ) as $key ) {
    370370            if ( ! is_int( $this->value[ $key ] ) ) {
    371                 $this->value[ $key ] = intval( $this->value[ $key ] );
     371                $this->value[ $key ] = (int) $this->value[ $key ];
    372372            }
    373373        }
     
    685685        $menu_item_value             = array_merge( $default, $menu_item_value );
    686686        $menu_item_value             = wp_array_slice_assoc( $menu_item_value, array_keys( $default ) );
    687         $menu_item_value['position'] = intval( $menu_item_value['position'] );
     687        $menu_item_value['position'] = (int) $menu_item_value['position'];
    688688
    689689        foreach ( array( 'object_id', 'menu_item_parent', 'nav_menu_term_id' ) as $key ) {
    690690            // Note we need to allow negative-integer IDs for previewed objects not inserted yet.
    691             $menu_item_value[ $key ] = intval( $menu_item_value[ $key ] );
     691            $menu_item_value[ $key ] = (int) $menu_item_value[ $key ];
    692692        }
    693693
     
    799799                }
    800800
    801                 if ( intval( $value['nav_menu_term_id'] ) !== $nav_menu_setting->previous_term_id ) {
     801                if ( (int) $value['nav_menu_term_id'] !== $nav_menu_setting->previous_term_id ) {
    802802                    $this->update_status = 'error';
    803803                    $this->update_error  = new WP_Error( 'unexpected_previous_term_id' );
     
    825825                }
    826826
    827                 if ( intval( $value['menu_item_parent'] ) !== $parent_nav_menu_item_setting->previous_post_id ) {
     827                if ( (int) $value['menu_item_parent'] !== $parent_nav_menu_item_setting->previous_post_id ) {
    828828                    $this->update_status = 'error';
    829829                    $this->update_error  = new WP_Error( 'unexpected_previous_post_id' );
Note: See TracChangeset for help on using the changeset viewer.