zendframework / zend-filter

Filter component from Zend Framework
BSD 3-Clause "New" or "Revised" License
68 stars 35 forks source link

Type options for Boolean filter are not handled properly #48

Closed dstockto closed 7 years ago

dstockto commented 7 years ago

The filter is using types as a bitmap, but then adding those values rather than using boolean math. This means initializing the filter with an array of the same type more than once, or the same type in different representations will result in completely unintended type.

$filter = new Boolean([Boolean::TYPE_BOOLEAN, Boolean::TYPE_BOOLEAN]);

or

$filter = new Boolean(['boolean', Boolean::TYPE_BOOLEAN]);

or

$filter = new Boolean(['boolean', 'boolean']);

The same holds true for every defined constant as well as any strings that map to those constants. In the examples above, rather than the expected Boolean type on the filter, it will be seen as though the user specified the integer type. This happens with any combination of any of the types as long as there are one or more duplicated representations of a particular type.

PR with fix incoming shortly.