diff --git a/library/Zend/Filter/Digits.php b/library/Zend/Filter/Digits.php index eea9b58a7a8..c5e856fbd58 100644 --- a/library/Zend/Filter/Digits.php +++ b/library/Zend/Filter/Digits.php @@ -18,14 +18,17 @@ class Digits extends AbstractFilter * * Returns the string $value, removing all but digit characters * - * If the value provided is non-scalar, the value will remain unfiltered + * If the value provided is not integer, float or string, the value will remain unfiltered * * @param string $value * @return string|mixed */ public function filter($value) { - if (!is_scalar($value)) { + if (is_int($value)) { + return (string) $value; + } + if (! (is_float($value) || is_string($value))) { return $value; } $value = (string) $value; diff --git a/tests/ZendTest/Filter/DigitsTest.php b/tests/ZendTest/Filter/DigitsTest.php index 7c478b3cd68..a405f07fda8 100644 --- a/tests/ZendTest/Filter/DigitsTest.php +++ b/tests/ZendTest/Filter/DigitsTest.php @@ -90,7 +90,9 @@ public function returnUnfilteredDataProvider() array(array( 'abc123', 'abc 123' - )) + )), + array(true), + array(false), ); } @@ -102,6 +104,6 @@ public function testReturnUnfiltered($input) { $filter = new DigitsFilter(); - $this->assertEquals($input, $filter($input)); + $this->assertSame($input, $filter($input)); } }