|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #80162 array_key_exists() should support ArrayAccess
Submitted: 2020-09-29 23:11 UTC Modified: -
Avg. Score:4.2 ± 0.4
Reproduced:4 of 4 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: divinity76 at gmail dot com Assigned:
Status: Open Package: Unknown/Other Function
PHP Version: Next Minor Version OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: divinity76 at gmail dot com
New email:
PHP Version: OS:


 [2020-09-29 23:11 UTC] divinity76 at gmail dot com
i suggest changing `array_key_exists ( mixed $key , array $array )` to `array_key_exists ( mixed $key , array|ArrayAccess $array )` , it's awkward that array_key_exists can't check ArrayAccess objects

(and it has caused invalid bugreports in the past, ref and )

Test script:
class C implements ArrayAccess {
    public $data = array(
    public function offsetExists ( $offset ): bool{
        return array_key_exists($offset,$this->data);
    public function offsetGet ( $offset ){
        return $this->data[$offset];
    public function offsetSet ( $offset , $value ): void {
    public function offsetUnset ( $offset ): void {


$o=new C();


Expected result:

Actual result:
Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, C given in /in/ZrcrF:24
Stack trace:
#0 {main}
  thrown in /in/ZrcrF on line 24

Process exited with code 255.


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 17 14:01:29 2024 UTC