Make WordPress Core


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

    r49095 r49108  
    764764            $qv['error'] = '404';
    765765        } else {
    766             $qv['p'] = intval( $qv['p'] );
     766            $qv['p'] = (int) $qv['p'];
    767767        }
    768768
     
    943943        }
    944944
    945         if ( '' != $qv['paged'] && ( intval( $qv['paged'] ) > 1 ) ) {
     945        if ( '' != $qv['paged'] && ( (int) $qv['paged'] > 1 ) ) {
    946946            $this->is_paged = true;
    947947        }
     
    16051605        $rand_with_seed = false;
    16061606        if ( preg_match( '/RAND\(([0-9]+)\)/i', $orderby, $matches ) ) {
    1607             $orderby        = sprintf( 'RAND(%s)', intval( $matches[1] ) );
     1607            $orderby        = sprintf( 'RAND(%s)', (int) $matches[1] );
    16081608            $allowed_keys[] = $orderby;
    16091609            $rand_with_seed = true;
     
    22642264            if ( is_numeric( $q['comment_count'] ) ) {
    22652265                $q['comment_count'] = array(
    2266                     'value' => intval( $q['comment_count'] ),
     2266                    'value' => (int) $q['comment_count'],
    22672267                );
    22682268            }
Note: See TracChangeset for help on using the changeset viewer.