WordPress.org

Make WordPress Core


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

    r49103 r49108  
    13211321 */
    13221322function rest_is_integer( $maybe_integer ) {
    1323     return is_numeric( $maybe_integer ) && round( floatval( $maybe_integer ) ) === floatval( $maybe_integer );
     1323    return is_numeric( $maybe_integer ) && round( (float) $maybe_integer ) === (float) $maybe_integer;
    13241324}
    13251325
     
    20132013
    20142014    if ( 'string' === $args['type'] ) {
    2015         return strval( $value );
     2015        return (string) $value;
    20162016    }
    20172017
Note: See TracChangeset for help on using the changeset viewer.