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/tests/phpunit/includes/utils.php

    r47122 r49108  
    300300function dmp( ...$args ) {
    301301        foreach ( $args as $thing ) {
    302                 echo ( is_scalar( $thing ) ? strval( $thing ) : var_export( $thing, true ) ), "\n";
     302                echo ( is_scalar( $thing ) ? (string) $thing : var_export( $thing, true ) ), "\n";
    303303        }
    304304}
    … …  
    320320        foreach ( $array as $k => $v ) {
    321321                if ( is_numeric( $k ) ) {
    322                         $index = strval( $k );
     322                        $index = (string) $k;
    323323                } else {
    324324                        $index = "'" . addcslashes( $k, "\n\r\t'\\" ) . "'";
Note: See TracChangeset for help on using the changeset viewer.