Issues

ZF-7742: getOption not working with uppercase $key

Description


    public function getOption($key)
    {
        if ($this->hasOption($key)) {
            $options = $this->getOptions();
            $options = array_change_key_case($options, CASE_LOWER);
            return $options[strtolower($key)];
        }
        return null;
    }

hasOption() is case sensitve so it never gets to the strtolowerpart

2 possible solutions:

make getOption() like this:


    public function getOption($key)
    {
       $key = strtolower($key);
        if ($this->hasOption($key)) {
            $options = $this->getOptions();
            $options = array_change_key_case($options, CASE_LOWER);
            return $options[($key];
        }
        return null;
    }

Or make hasOption, since all options get loaded into lowercase keys anyway:


    public function hasOption($key)
    {
        return in_array(strtolower($key), $this->_optionKeys);
    }

Comments

This is related to ZF-6679

Basically, the intention was that getOptions would preserve the original case, but lookups (getOption and hasOption) would work if you supply a lowercase key or a case sensitive key.

But, passing a key with a capital letter does not work.

Unit tests and fix to allow passing keys with capital letters to getOption and hasOption. getOption didn't need a fix since it was already coded to be case-insensitive, but relied on hasOption which was case-sensitive.

I agree with Travis that hasOption is missing the strtolower functionality and therefore this bug occurs.

Fixed in trunk and 1.9 release branch

How come i don't see it in the repository?

Ah, but it is still missing in BootstrapAbstract.php