Skip to content

Commit

Permalink
Added support for autoload $prepend
Browse files Browse the repository at this point in the history
  • Loading branch information
hason authored and nikic committed Mar 27, 2014
1 parent 91f6880 commit 2605b83
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/PhpParser/Autoloader.php
Expand Up @@ -8,18 +8,20 @@
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';
Expand Down

0 comments on commit 2605b83

Please sign in to comment.