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
Posted by Rob Allen (rob) on 2012-11-06T21:18:16.000+0000
Will a test for is_null() result in a warning if $this->_aFeatures[$feature] doesn't exist?
Posted by Simon Echle (echle) on 2012-11-07T07:20:09.000+0000
Litte testing resultet in the expected warnings. The condition should contain a test for isset() to fix this. The code could look like this:
Thx to lazy evaluation the is_null expression wont be touched if the array key doesnt exist.
Posted by Rob Allen (rob) on 2012-11-16T15:23:56.000+0000
Fixed on trunk (25128) and release-1.12 (25129)