ZF-12450: Zend_Http_UserAgent_AbstractDevice hasFeature-Function does not work for (Boolean)false-values

Description

If the value of a feature is (Boolean)false the hasFeature-Function returns false.

Currently looks like this:


public function hasFeature($feature)
{
    return (!empty($this->_aFeatures[$feature]));
}

I would recommend using "is_null" instead of "empty":


public function hasFeature($feature)
{
    return(!is_null($this->_aFeatures[$feature]));
}

Comments

Will a test for is_null() result in a warning if $this->_aFeatures[$feature] doesn't exist?

Litte testing resultet in the expected warnings. The condition should contain a test for isset() to fix this. The code could look like this:


public function hasFeature($feature)
{
    return(isset($this->_aFeatures[$feature]) && !is_null($this->_aFeatures[$feature]));
}

Thx to lazy evaluation the is_null expression wont be touched if the array key doesnt exist.

Fixed on trunk (25128) and release-1.12 (25129)