bug72031.phpt 666 B

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