xref: /PHP-7.0/ext/standard/tests/array/bug72031.phpt (revision c0d8dc5b)
1--TEST--
2Bug #72031: array_column() against an array of objects discards all values matching null
3--FILE--
4<?php
5
6class myObj {
7    public $prop;
8    public function __construct($prop) {
9        $this->prop = $prop;
10    }
11}
12
13$objects = [
14    new myObj(-1),
15    new myObj(0),
16    new myObj(1),
17    new myObj(2),
18    new myObj(null),
19    new myObj(true),
20    new myObj(false),
21    new myObj('abc'),
22    new myObj(''),
23];
24
25var_dump(array_column($objects, 'prop'));
26
27?>
28--EXPECT--
29array(9) {
30  [0]=>
31  int(-1)
32  [1]=>
33  int(0)
34  [2]=>
35  int(1)
36  [3]=>
37  int(2)
38  [4]=>
39  NULL
40  [5]=>
41  bool(true)
42  [6]=>
43  bool(false)
44  [7]=>
45  string(3) "abc"
46  [8]=>
47  string(0) ""
48}
49