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/rewrite.php

    r48695 r49108  
    401401    if ( preg_match( '/^([0-9]{4})\-([0-9]{2})/', $post->post_date, $matches ) && isset( $query_vars['year'] ) && ( 'monthnum' === $compare || 'day' === $compare ) ) {
    402402        // $matches[1] is the year the post was published.
    403         if ( intval( $query_vars['year'] ) !== intval( $matches[1] ) ) {
     403        if ( (int) $query_vars['year'] !== (int) $matches[1] ) {
    404404            return $query_vars;
    405405        }
    406406
    407407        // $matches[2] is the month the post was published.
    408         if ( 'day' === $compare && isset( $query_vars['monthnum'] ) && intval( $query_vars['monthnum'] ) !== intval( $matches[2] ) ) {
     408        if ( 'day' === $compare && isset( $query_vars['monthnum'] ) && (int) $query_vars['monthnum'] !== (int) $matches[2] ) {
    409409            return $query_vars;
    410410        }
     
    438438    // If we've gotten to this point, we have a slug/date clash. First, adjust for nextpage.
    439439    if ( '' !== $maybe_page ) {
    440         $query_vars['page'] = intval( $maybe_page );
     440        $query_vars['page'] = (int) $maybe_page;
    441441    }
    442442
Note: See TracChangeset for help on using the changeset viewer.