Issues

ZF-2964: Zend_Filter_Inflector cause PHP-error when "nothing to do"

Description

Sample:

$bla = new Zend_Filter_Inflector('abc');
$bla->addRules(array(':xys'=>array()));
echo $bla->filter (array('xy'=>'ab'));

This causes a php-error

Notice: /Zend/Zend/Filter/Inflector.php line 451 - Undefined variable: processedParts
Debug Warning: /Zend/Zend/Filter/Inflector.php line 451 - array_keys() [function.array-keys]: The first argument should be an array
Notice: /Zend/Zend/Filter/Inflector.php line 451 - Undefined variable: processedParts
Debug Warning: /Zend/Zend/Filter/Inflector.php line 451 - array_values() [function.array-values]: The argument should be an array
Debug Warning: /Zend/Zend/Filter/Inflector.php line 451 - preg_replace() [function.preg-replace]: Empty regular expression

and the return value is null. I my mind it should be abc or at least an empty string.

I had a look at line 451


and when I debug it, it seems to me, that the array _processedParts_ doesnt exists, if there are no replacements to do (see first notice "undefined variable"). In the example above there is a rule and there is something in _filter()_, but they dont match. The most simple example is this

$bla = new Zend_Filter_Inflector(''); var_dump($bla->filter (array()));```

The array is never initialized. The file revision is 8226 (trunk).

Comments

Fixed in trunk in r9045.

Lemme know if that fixes it..

-ralph

Fixed in 1.5.3 with r10431