ZF-221: Zend_Filter::isDigits() operates erratically


Zend_Filter::isDigits() sometimes returns false on values that are digits. The solution is simple:

public static function isDigits($value)
---    return ctype_digit($value);
+++    return ctype_digit((string) $value);

I marked this major because I use this for all ID validation in my applications.


Can you give some examples where it fails?

{quote} Fatal error: Uncaught exception 'Exception' with message 'Expected second ID' in /path/to/ExampleController.php:312 Stack trace:

0 /path/to/ExampleController.php(184): ExampleController->doSomething('7', 19)[...]


public function doSomething($firstId, $secondId)
        throw new Exception("Expected first ID");

        throw new Exception("Expected second ID");

Changing Zend_Filter::isDigits() as indicated results in correct execution. See….

You might also change to


which is what I went ahead and did.

I meant to say see the last two comments of…

So much for dynamic typing. :-) A bug in PHP?