Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Digit filter should ignore boolean input #6277

Merged
merged 2 commits into from
May 20, 2014

Conversation

dstockto
Copy link

The digits filter should only be filtering things that can represent digits. Booleans do not represent digits and should pass through unchanged.

*
* @param string $value
* @return string|mixed
*/
public function filter($value)
{
if (!is_scalar($value)) {
if (! (is_int($value) || is_float($value) || is_string($value))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in our IRC conversation yesterday, I'd argue that if $value is an integer, you should do a return (string) $value;, and skip the regex. Integers are always series of digits; the main thing is ensuring that a string value is returned in that case, so that subsequent filters can operate on it.

@Ocramius Ocramius self-assigned this May 20, 2014
@Ocramius Ocramius added this to the 2.3.2 milestone May 20, 2014
@Ocramius Ocramius merged commit ec6dfa9 into zendframework:develop May 20, 2014
Ocramius added a commit that referenced this pull request May 20, 2014
@Ocramius
Copy link
Member

Merged manually into master via cherry-pick.

gianarb pushed a commit to zendframework/zend-filter that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-filter that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants