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/
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php