bug46409.phpt 411 B

12345678910111213141516171819202122232425
  1. --TEST--
  2. Bug #46409 (__invoke method called outside of object context when using array_map)
  3. --FILE--
  4. <?php
  5. class Callback {
  6. protected $val = 'hello, world';
  7. public function __invoke() {
  8. return $this->val;
  9. }
  10. }
  11. $cb = new Callback();
  12. echo $cb(),"\n";
  13. $a = array(1, 2);
  14. $b = array_map($cb, $a);
  15. print_r($b);
  16. ?>
  17. --EXPECT--
  18. hello, world
  19. Array
  20. (
  21. [0] => hello, world
  22. [1] => hello, world
  23. )