From 2605b8319e910bd9e6f9e505002108a1483ba9aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Wed, 12 Feb 2014 14:06:32 +0100 Subject: [PATCH] Added support for autoload $prepend --- lib/PhpParser/Autoloader.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/PhpParser/Autoloader.php b/lib/PhpParser/Autoloader.php index 447481fb..8e31421e 100644 --- a/lib/PhpParser/Autoloader.php +++ b/lib/PhpParser/Autoloader.php @@ -8,18 +8,20 @@ namespace PhpParser; class Autoloader { /** - * Registers PhpParser\Autoloader as an SPL autoloader. - */ - static public function register() { + * Registers PhpParser\Autoloader as an SPL autoloader. + * + * @param bool $prepend Whether to prepend the autoloader instead of appending + */ + static public function register($prepend = false) { ini_set('unserialize_callback_func', 'spl_autoload_call'); - spl_autoload_register(array(__CLASS__, 'autoload')); + spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend); } /** - * Handles autoloading of classes. - * - * @param string $class A class name. - */ + * Handles autoloading of classes. + * + * @param string $class A class name. + */ static public function autoload($class) { if (0 === strpos($class, 'PhpParser\\')) { $fileName = dirname(__DIR__) . '/' . rtrim(strtr($class, '\\', '/'), '_') . '.php';