diff --git a/PHPUnit/Extensions/Constraint/ArrayHasKeyValuePair.php b/PHPUnit/Extensions/Constraint/ArrayHasKeyValuePair.php index 2b5d21e..8c29c73 100644 --- a/PHPUnit/Extensions/Constraint/ArrayHasKeyValuePair.php +++ b/PHPUnit/Extensions/Constraint/ArrayHasKeyValuePair.php @@ -34,10 +34,10 @@ public function __construct($key, $value) */ protected function matches($other) { - if (array_key_exists($this->key, $other) && $other[$this->key] === $this->value) { - return true; + if (!(is_array($other) || $other instanceof ArrayAccess)) { + return false; } - return false; + return (array_key_exists($this->key, $other) && ($other[$this->key] === $this->value)); } /**