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. Built from https://develop.svn.wordpress.org/trunk@49108 git-svn-id: http://core.svn.wordpress.org/trunk@48870 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -1320,7 +1320,7 @@ function rest_is_boolean( $maybe_bool ) {
|
||||
* @return bool True if an integer, otherwise false.
|
||||
*/
|
||||
function rest_is_integer( $maybe_integer ) {
|
||||
return is_numeric( $maybe_integer ) && round( floatval( $maybe_integer ) ) === floatval( $maybe_integer );
|
||||
return is_numeric( $maybe_integer ) && round( (float) $maybe_integer ) === (float) $maybe_integer;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2012,7 +2012,7 @@ function rest_sanitize_value_from_schema( $value, $args, $param = '' ) {
|
||||
}
|
||||
|
||||
if ( 'string' === $args['type'] ) {
|
||||
return strval( $value );
|
||||
return (string) $value;
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
||||
Reference in New Issue
Block a user