Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56190 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10390 invoked from network); 9 Nov 2011 13:49:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Nov 2011 13:49:09 -0000 Authentication-Results: pb1.pair.com header.from=ivan.enderlin@hoa-project.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=ivan.enderlin@hoa-project.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain hoa-project.net from 87.106.212.190 cause and error) X-PHP-List-Original-Sender: ivan.enderlin@hoa-project.net X-Host-Fingerprint: 87.106.212.190 s15355703.onlinehome-server.info Linux 2.6 Received: from [87.106.212.190] ([87.106.212.190:43831] helo=s15355703.onlinehome-server.info) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 55/01-01735-3D48ABE4 for ; Wed, 09 Nov 2011 08:49:08 -0500 Received: from Hwhost2.local (unknown [134.157.87.223]) by s15355703.onlinehome-server.info (Postfix) with ESMTPA id 2D004E40A6; Wed, 9 Nov 2011 14:48:35 +0100 (CET) Message-ID: <4EBA84CF.50704@hoa-project.net> Date: Wed, 09 Nov 2011 14:49:03 +0100 Reply-To: ivan.enderlin@hoa-project.net User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: Christian Kaps CC: internals@lists.php.net References: <4EB81703.7030605@hoa-project.net> <4EB81C84.8010609@hoa-project.net> <4EB820BB.2030009@lsces.co.uk> <4EB822D4.4060306@hoa-project.net> <4EB89C36.5000503@garfieldtech.com> <4EB8A22B.8000607@lerdorf.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] SplClassLoader RFC Voting phase From: ivan.enderlin@hoa-project.net ("Ivan Enderlin @ Hoa") On 09/11/11 11:24, Christian Kaps wrote: > Hi, Hi Christian :-), > > I'm fine with the most of the implementation. But I have some > suggestions to optimize it. > > 1. The interface should be named SplClassLoader and the register and > unregister methods should be removed. > > It should be possible to define class loader implementations without > registering them as autoloader because autoloading isn't the only way > to load classes. A class loader could as example return the > ReflectionClass instance for the loaded class. I think the current > interface is to restrictive in this case. As compromise it would be > possible to define a SplClassAutoloader interface too. This interface > extends the SplClassLoader interface and defines the methods register > and unregister. > > interface SplClassAutoloader extends SplClassLoader { > > public function register($prepend = false); > > public function unregister(); > } > > As a side note, the two interfaces doesn't violate the Single > responsibility principle. > > I know the reference implementation is named as SplClassLoader but > this should be renamed into SplDefaultAutoloader or SplPsrAutoloader > if implements the SplClassAutoloader or as SplPsrClassloader or > SplDefaultClassloader if implements the SplClassLoader interface. Why not \Psr\Loader\Default? (I'm not trolling). > > 2. The function spl_autoload_register() should accept all > SplClassLoader implementations. > > I know it's already possible with the following syntax: > > $classLoader = new MyCustomClassLoader(); > spl_autoload_register(array($classLoader, 'load')); > > But the following syntax seems more consistent to me: > > $classLoader = new MyCustomClassLoader(); > spl_autoload_register($classLoader); Yes, that will be a good update I think! It could be a parallel work of SplClassLoader RFC, no? Quite easy I think. Best regards. -- Ivan Enderlin Developer of Hoa http://hoa.42/ or http://hoa-project.net/ PhD. student at LIFC/DISC (Vesontio) and INRIA (Cassis) http://lifc.univ-fcomte.fr/ and http://www.inria.fr/ Member of HTML and WebApps Working Group of W3C http://w3.org/