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/general-template.php

    r49092 r49108  
    13401340        $my_year  = substr( $m, 0, 4 );
    13411341        $my_month = $wp_locale->get_month( substr( $m, 4, 2 ) );
    1342         $my_day   = intval( substr( $m, 6, 2 ) );
     1342        $my_day   = (int) substr( $m, 6, 2 );
    13431343        $title    = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' );
    13441344    }
     
    22242224    // Let's figure out when we are.
    22252225    if ( ! empty( $monthnum ) && ! empty( $year ) ) {
    2226         $thismonth = zeroise( intval( $monthnum ), 2 );
     2226        $thismonth = zeroise( (int) $monthnum, 2 );
    22272227        $thisyear  = (int) $year;
    22282228    } elseif ( ! empty( $w ) ) {
     
    31503150        }
    31513151    } elseif ( is_author() ) {
    3152         $author_id = intval( get_query_var( 'author' ) );
     3152        $author_id = (int) get_query_var( 'author' );
    31533153
    31543154        $title = sprintf( $args['authortitle'], get_bloginfo( 'name' ), $args['separator'], get_the_author_meta( 'display_name', $author_id ) );
     
    34603460        if ( 'true' === get_user_option( 'rich_editing' ) || ! is_user_logged_in() ) { // Default to 'true' for logged out users.
    34613461            if ( $is_safari ) {
    3462                 $wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 );
     3462                $wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && (int) $match[1] >= 534 );
    34633463            } elseif ( $is_IE ) {
    34643464                $wp_rich_edit = ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Trident/7.0;' ) !== false );
     
    41964196    // Get max pages and current page out of the current query, if available.
    41974197    $total   = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
    4198     $current = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
     4198    $current = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1;
    41994199
    42004200    // Append the format placeholder to the base URL.
Note: See TracChangeset for help on using the changeset viewer.