1--TEST-- 2SPL: spl_autoload_functions() with closures and invocables 3--FILE-- 4<?php 5$closure = function($class) { 6 echo "a called\n"; 7}; 8 9class Autoloader { 10 private $dir; 11 public function __construct($dir) { 12 $this->dir = $dir; 13 } 14 public function __invoke($class) { 15 var_dump("{$this->dir}/$class.php"); 16 } 17} 18 19$al1 = new Autoloader('d1'); 20$al2 = new Autoloader('d2'); 21 22spl_autoload_register($closure); 23spl_autoload_register($al1); 24spl_autoload_register($al2); 25 26var_dump(spl_autoload_functions()); 27 28?> 29--EXPECTF-- 30array(3) { 31 [0]=> 32 object(Closure)#%d (1) { 33 ["parameter"]=> 34 array(1) { 35 ["$class"]=> 36 string(10) "<required>" 37 } 38 } 39 [1]=> 40 object(Autoloader)#%d (1) { 41 ["dir":"Autoloader":private]=> 42 string(2) "d1" 43 } 44 [2]=> 45 object(Autoloader)#%d (1) { 46 ["dir":"Autoloader":private]=> 47 string(2) "d2" 48 } 49} 50