Make WordPress Core


Ignore:
Timestamp:
10/08/2020 09:13:57 PM (6 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/class-wp-date-query.php

    r48586 r49108  
    875875                                // Y
    876876                                $datetime = array(
    877                                         'year' => intval( $matches[1] ),
     877                                        'year' => (int) $matches[1],
    878878                                );
    879879
     
    881881                                // Y-m
    882882                                $datetime = array(
    883                                         'year'  => intval( $matches[1] ),
    884                                         'month' => intval( $matches[2] ),
     883                                        'year'  => (int) $matches[1],
     884                                        'month' => (int) $matches[2],
    885885                                );
    886886
     
    888888                                // Y-m-d
    889889                                $datetime = array(
    890                                         'year'  => intval( $matches[1] ),
    891                                         'month' => intval( $matches[2] ),
    892                                         'day'   => intval( $matches[3] ),
     890                                        'year'  => (int) $matches[1],
     891                                        'month' => (int) $matches[2],
     892                                        'day'   => (int) $matches[3],
    893893                                );
    894894
     
    896896                                // Y-m-d H:i
    897897                                $datetime = array(
    898                                         'year'   => intval( $matches[1] ),
    899                                         'month'  => intval( $matches[2] ),
    900                                         'day'    => intval( $matches[3] ),
    901                                         'hour'   => intval( $matches[4] ),
    902                                         'minute' => intval( $matches[5] ),
     898                                        'year'   => (int) $matches[1],
     899                                        'month'  => (int) $matches[2],
     900                                        'day'    => (int) $matches[3],
     901                                        'hour'   => (int) $matches[4],
     902                                        'minute' => (int) $matches[5],
    903903                                );
    904904                        }
Note: See TracChangeset for help on using the changeset viewer.