Bug #74422 [Opn->Ana]: Round function returns false for non-numeric argument
| From: | requinix@php.net | Date: | Wed, 12 Apr 2017 20:15:15 +0000 |
| Subject: | Bug #74422 [Opn->Ana]: Round function returns false for non-numeric argument | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-208500@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
Updated by: requinix@php.net
Reported by: jose dot carlos dot garcia dot 95 at gmail dot com
-Summary: Round function sometimes return no float values
+Summary: Round function returns false for non-numeric
argument
-Status: Open
+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:
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?
Previous Comments:
------------------------------------------------------------------------
[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