|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77119 array_column has changed behaviour for classes
Submitted: 2018-11-08 01:47 UTC Modified: 2018-11-08 04:41 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: josh at engramdesign dot com dot au Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 7.0.32 OS: Centos
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: josh at engramdesign dot com dot au
New email:
PHP Version: OS:


 [2018-11-08 01:47 UTC] josh at engramdesign dot com dot au
A recent update to 7.0.32 has caused this bug. Please refer to the reproducible example where an array of classes is supplied to `array_column`.

This worked fine in previous 7.0.x versions.

Test script:
$class = new \stdClass();
$class->name = 'Test';

$names = array_column([$class], 'name');

Expected result:
object(stdClass)#769 (1) { ["name"]=> string(4) "Test" }
array(0) { }

Actual result:
object(stdClass)#769 (1) { ["name"]=> string(4) "Test" }
array(1) { [0]=> string(4) "Test" }


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-11-08 02:02 UTC]
> This worked fine in previous 7.0.x versions.

3v4l disagrees:
 [2018-11-08 02:14 UTC]
-Status: Open +Status: Not a bug
 [2018-11-08 02:14 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

In specific check the documentation of the function you are using including the possible changelog
 [2018-11-08 02:32 UTC] josh at engramdesign dot com dot au
Then why does the output for "Output for hhvm-3.17.3 - 3.22.0, 7.0.0 - 7.3.0rc4" show the following?

object(stdClass)#1 (1) {
  string(4) "Test"
array(1) {
  string(4) "Test"

I will note that 3v4l doesn't have 7.0.32 available to test, and it works as expected in 7.0.31.
 [2018-11-08 03:09 UTC]
Your expected behavior is incorrect. What the function is doing, and as you pointed out has been doing since 7.0.0, it was it should be doing: returning an array with the "name" properties extracted from the array of objects that was passed as the first argument.
 [2018-11-08 03:15 UTC] josh at engramdesign dot com dot au
Well, I'm an idiot. The expected and actual results are around the wrong way. So sorry about that. I can't see anywhere to edit my original post either (sorry, not used to this bug tracker).

So what its returning is an empty array when it shouldn't be.

Does that make more sense now?
 [2018-11-08 04:41 UTC]
It's working for me...
 [2019-02-01 14:26 UTC] cravciucandy at gmail dot com
The same problems are in PHP 7.0.33 built: Dec 11 2018 06:07:07
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Aug 15 13:03:41 2022 UTC