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

    r48983 r49108  
    35693569    } else {
    35703570        $sign    = ( '+' === substr( $timezone, 0, 1 ) ) ? 1 : -1;
    3571         $hours   = intval( substr( $timezone, 1, 2 ) );
    3572         $minutes = intval( substr( $timezone, 3, 4 ) ) / 60;
     3571        $hours   = (int) substr( $timezone, 1, 2 );
     3572        $minutes = (int) substr( $timezone, 3, 4 ) / 60;
    35733573        $offset  = $sign * HOUR_IN_SECONDS * ( $hours + $minutes );
    35743574    }
     
    38213821
    38223822        /* translators: Maximum number of words used in a post excerpt. */
    3823         $excerpt_length = intval( _x( '55', 'excerpt_length' ) );
     3823        $excerpt_length = (int) _x( '55', 'excerpt_length' );
    38243824
    38253825        /**
     
    47264726                $value = 1;
    47274727            } else {
    4728                 $value = intval( $value );
     4728                $value = (int) $value;
    47294729            }
    47304730            break;
     
    50685068                $fragment = $_fragment;
    50695069            } else {
    5070                 $fragment = sprintf( $fragment, strval( $arg ) );
     5070                $fragment = sprintf( $fragment, (string) $arg );
    50715071            }
    50725072        }
Note: See TracChangeset for help on using the changeset viewer.