1--TEST-- 2SPL: spl_autoload_unregister() with closures and invocables 3--FILE-- 4<?php 5$closure = function($class) { 6 echo "closure called with class $class\n"; 7}; 8 9class Autoloader { 10 private $dir; 11 public function __construct($dir) { 12 $this->dir = $dir; 13 } 14 public function __invoke($class) { 15 echo ("Autoloader('{$this->dir}') called with $class\n"); 16 } 17} 18 19class WorkingAutoloader { 20 public function __invoke($class) { 21 echo ("WorkingAutoloader() called with $class\n"); 22 eval("class $class { }"); 23 } 24} 25 26$al1 = new Autoloader('d1'); 27$al2 = new WorkingAutoloader('d2'); 28 29spl_autoload_register($closure); 30spl_autoload_register($al1); 31spl_autoload_register($al2); 32 33$x = new TestX; 34 35spl_autoload_unregister($closure); 36spl_autoload_unregister($al1); 37 38$y = new TestY; 39 40?> 41--EXPECT-- 42closure called with class TestX 43Autoloader('d1') called with TestX 44WorkingAutoloader() called with TestX 45WorkingAutoloader() called with TestY 46