Re: Function/Constant autoloading
Hi,
Thanks, that looks similar to what I'm looking for. It doesn't seem, that any of the reply is really against autoloading of functions (and maybe constants), but are against the given implementations (because they are built on top of the outdated __autoload() function), what brings me back to my "overall" question: Why it doesn't exists, but autoloading of classes exists? That makes me feel, that, since classes exists, functions (and the youngest children namespace constants) are the unloved children of the multiparadigma approach.
Just to make an example, what goes on in my mind:
// register-autoload signature
spl_autoload_register($callback, $type = SPL_AUTOLOAD_CLASS);
// register an autoloader
spl_autoload_register(function ($name, $type) use ($myLoader) {
switch ($type) {
case SPL_AUTOLOAD_CLASS:
return $myLoader->loadClass($name);
break;
case SPL_AUTOLOAD_FUNCTION:
return $myLoader->loadFunction($name);
break;
case SPL_AUTOLOAD_CONSTANT:
return $myLoader->loadConstant($name);
break;
}
}, SPL_AUTOLOAD_CLASS | SPL_AUTOLOAD_FUNCTION | SPL_AUTOLOAD_CONSTANT);
class-only-autoloader can simply ignore the second argument $type
, thus I don't see any BC-break.
Am 26.07.2011 10:53, schrieb Ferenc Kovacs:
Thread (8 messages)