ZF-10691: Zend_Filter_StringTrim constructor does not set up options properly

Description

This is what is supplied in 1.11.0 Zend_Filter_StringTrim


    /**
     * Sets filter options
     *
     * @param  string|array|Zend_Config $charList
     * @return void
     */
     public function __construct($charList = null) {
        if ($charList instanceof Zend_Config) {
            $charList = $charList->toArray();
        } else if (!is_array($charList)) {
            $options          = func_get_args();
            $temp['charlist'] = array_shift($options);
            $options          = $temp;
        }

        if (array_key_exists('charlist', $options)) {
            $this->setCharList($options['charlist']);
        }
    }

if an array is given for the constructor parameter the local variable $options is never set and php gives a notice "Undefined variable: options on line 61". In addition, if the typical options array is given to the constructor, the options are never set for the filter. Furthermore if an instance of Zend_Config is supplied as the constructors parameter, it is converted to an array and then disregarded.

I am guessing the constructor was meant to be more like this Updated to reflect Ramon Henrique Ornelas comments and patch


    /**
     * Sets filter options
     *
     * @param  string|array|Zend_Config $options
     * @return void
     */
    public function __construct($options = null)
    {
        if ($options instanceof Zend_Config) {
            $options = $options->toArray();
        } else if (!is_array($options)) {
            $options          = func_get_args();
            $temp['charlist'] = array_shift($options);
            $options          = $temp;
        }

        if (array_key_exists('charlist', $options)) {
            $this->setCharList($options['charlist']);
        }
    }

Comments

{quote} $options['charlist'] = array_shift(func_get_args()); //?? I don't quite understand the purpose of this {quote}

This improvement only was done in php 5.3. See http://php.net/manual/en/… http://stackoverflow.com/questions/2309626/…

Greetings Ramon

Attach patch with tests.

Updated fix to reflect Ramon Henrique Ornelas comments and patch Altered phpDoc to reflect change of parameter name

Fixed in trunk r23396 merged to release branch 1.11 r23401 - thanks.