Bug #74422 [Ana]: Round function returns false for non-numeric argument

From: Date: Wed, 12 Apr 2017 20:20:27 +0000
Subject: Bug #74422 [Ana]: Round function returns false for non-numeric argument
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208501@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74422&edit=1 ID: 74422 User updated by: jose dot carlos dot garcia dot 95 at gmail dot com Reported by: jose dot carlos dot garcia dot 95 at gmail dot com Summary: Round function returns false for non-numeric argument Status: Analyzed Type: Bug Package: *Math Functions Operating System: Ubuntu PHP Version: 7.0Git-2017-04-12 (Git) Block user comment: N Private report: N New Comment: But, if I try with a string or a boolean value, round return 0 and not false, so it's strange. I think that null value is a good option. Previous Comments: ------------------------------------------------------------------------ [2017-04-12 20:15:11] requinix@php.net Typically built-in functions return NULL when given an argument of the wrong type, but returning false is also permitted. http://php.net/manual/en/functions.internal.php Looks like round RETURN_FALSEs for values that aren't int or float. It should be fine to change that, right? ------------------------------------------------------------------------ [2017-04-12 17:46:44] jose dot carlos dot garcia dot 95 at gmail dot com Description: ------------ In round documentation specified that round everytime return a float value, but if I put an array as argument, round will return a boolean value. Test script: --------------- <?php $valores = [ array(), array("test" => "hola") ]; foreach($valores as $valor) { echo var_dump(round($valor)); } Expected result: ---------------- A float value, or maybe a change in round function that reports when a type is invalid. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74422&edit=1

« previous php.bugs (#208501) next »