|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #80799 Support ArrayAccess in array_column()
Submitted: 2021-02-25 12:17 UTC Modified: 2021-03-01 14:15 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: saribekyantaron at gmail dot com Assigned:
Status: Open Package: Class/Object related
PHP Version: Next Minor Version OS: Any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: saribekyantaron at gmail dot com
New email:
PHP Version: OS:


 [2021-02-25 12:17 UTC] saribekyantaron at gmail dot com
From manual page:
The first parameter describes: 
A multi-dimensional array or an array of objects from which to pull a column of values from. If an array of objects is provided, then public properties can be directly pulled. In order for protected or private properties to be pulled, the class must implement both the __get() and __isset() magic methods.
But I think if object's class implements interface \ArrayAccess, no need to define magic methods (set, get, isset) for allowing them to be used in array-management functions: like array_columns. I mean that Array*** interfaces can be enough (I will prefer required) to use objects or object arrays in array_*** functions.

Test script:
class SimpleArrayLikeClass implements \ArrayAccess
    public function offsetExists($name)
        return array_key_exists($name, $this->attributes());

    public function offsetGet($name)
        return $this->attributes()[$name] ?? null;

    // if object need to be used as array this 2 methods need to be used instead of __isset() and __get() 

Expected result:
In future versions became deprecated to use objects as array, if they not implemented Array*** interfaces, instead of magic methods


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-01 14:15 UTC]
-Summary: Wrong behavior for function array_column +Summary: Support ArrayAccess in array_column()
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Mar 25 05:04:10 2023 UTC