Home » Database » DB_DataObject » Bug #620
limit: No Valid Arguments (for float, double and real)
Details
| Submitted | 2004-01-24 13:05 UTC |
|---|---|
| From | maka3d at yahoo dot com dot br |
| Assigned | alan_k |
| Status | Closed |
| Package | DB_DataObject |
| PHP Version | Irrelevant |
| OS | irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2004-01-24 13:05 UTC] maka3d at yahoo dot com dot br
Description:
------------
if call $db_dataObject->limit((double)2,10)
error limit: No Valid Arguments is raised
dataObject.php at line 659 should check if the real, float and double value are integer.
patch:
if ((!is_int($a) && ((string)((int)$a) !== (string)$a))
[2004-01-26 11:45 UTC] maka3d at yahoo dot com dot br
I agree that calling limit 2.0, 10 is horrible.
But what you are doing is a type checking, not a value checking. PHP is not strong typing but you are forcing it.
You have to check if the number is an integer, not if it's of type int. As you did after && checking if the string is a valid number. What I'm proposing is to check(like you check for string) if the input is a valid number. Doing this:
if ((!is_int($a) && ((string)((int)$a) !== (string)$a))
you accept double and float values like 2.0, 3.0 but raise an error if the value is 2.1, 2.4 or "2.6" ...
Remember, don't do type checking, do value checking. Don't kill the PHP natural behavior.