Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44267 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38975 invoked from network); 13 Jun 2009 18:12:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jun 2009 18:12:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 209.85.216.193 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 209.85.216.193 mail-px0-f193.google.com Received: from [209.85.216.193] ([209.85.216.193:64975] helo=mail-px0-f193.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 14/25-12802-0FBE33A4 for ; Sat, 13 Jun 2009 14:12:01 -0400 Received: by pxi31 with SMTP id 31so50797pxi.29 for ; Sat, 13 Jun 2009 11:11:57 -0700 (PDT) Received: by 10.114.182.15 with SMTP id e15mr7937679waf.195.1244916716811; Sat, 13 Jun 2009 11:11:56 -0700 (PDT) Received: from monster.local ([76.84.30.125]) by mx.google.com with ESMTPS id n33sm3127859wag.32.2009.06.13.11.11.55 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 13 Jun 2009 11:11:56 -0700 (PDT) Message-ID: <4A33EBE9.9060604@chiaraquartet.net> Date: Sat, 13 Jun 2009 13:11:53 -0500 User-Agent: Thunderbird 2.0.0.6 (Macintosh/20070807) MIME-Version: 1.0 To: Christian Seiler CC: php-dev List References: <4A3343A1.4060701@chiaraquartet.net> <4A338AC9.1090100@gmx.net> <4A33D8B8.30203@chiaraquartet.net> <4A33DDDE.4070409@gmx.net> <4A33E2A2.4090305@chiaraquartet.net> <4A33E7D3.1050904@gmx.net> In-Reply-To: <4A33E7D3.1050904@gmx.net> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] bug 48541 - critical for PHP 5.3 From: greg@chiaraquartet.net (Greg Beaver) Christian Seiler wrote: > Hi Greg, > > >> (I meant commit when I said patch, sorry :) >> >> http://news.php.net/php.cvs/58696 >> and >> http://news.php.net/php.cvs/58697 >> > > Thanks, looks fine to me. However, I noticed that closures don't work > with spl_autoload_unregister() and spl_autoload_functions(). Also, > classes that define __invoke work with spl_autoload_functions() but not > with spl_autoload_unregister() - unless array ($o, '__invoke') is given > to spl_autoload_register() directly, then the same will work for unregister. > Hi, I first replied off-list accidentally. I wonder if the problem is that spl_autoload_register should not just be checking to see if zcallable is IS_OBJECT, but also if it is an instance of Closure. That should clear up the examples below (spl_autoload_register($blah) where $blah is not a closure should not work). spl_autoload_unregister probably just needs a cut/paste of the code I committed to spl_autoload_register for munging a closure name with the addition of Closure instanceof check. Also, those examples would make great .phpt tests :). Greg > Or, to sum it up: > > i) Real Closures > > $c = function ($class) { var_dump ('foo'); } > spl_autoload_register ($c); > > var_dump (spl_autoload_functions ()); // '{closure}' > > spl_autoload_unregister ($c); // no effect > > ii) Invokables > > WORKS: > > > class Autoloader { > private $dir; > public function __construct ($dir) { > $this->dir = $dir; > } > public function __invoke ($class) { > var_dump ("{$this->dir}/$class.php"); > } > } > > $al1 = new Autoloader ('d1'); > $al2 = new Autoloader ('d2'); > > spl_autoload_register (array ($al1, '__invoke')); > spl_autoload_register (array ($al2, '__invoke')); > > var_dump (spl_autoload_functions ()); > > spl_autoload_unregister (array ($al1, '__invoke')); > > $x = new Test; > > ?> > > SEMI-WORKS: > > > class Autoloader { > private $dir; > public function __construct ($dir) { > $this->dir = $dir; > } > public function __invoke ($class) { > var_dump ("{$this->dir}/$class.php"); > } > } > > $al1 = new Autoloader ('d1'); > $al2 = new Autoloader ('d2'); > > spl_autoload_register ($al1); > spl_autoload_register ($al2); > > var_dump (spl_autoload_functions ()); > // gives array ($object, '__invoke') instead of > // directly $object - but that's at least equivalent > > spl_autoload_unregister ($al1); > // no effect > spl_autoload_unregister (array ($al1, '__invoke')); > // no effect > > $x = new Test; > > ?> > > Regards, > Christian >