10 /** @var bool Whether the autoloader has been registered. */
11 private static $registered = false;
14 * Registers PhpParser\Autoloader as an SPL autoloader.
16 * @param bool $prepend Whether to prepend the autoloader instead of appending
18 static public function register($prepend = false) {
19 if (self::$registered === true) {
23 spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
24 self::$registered = true;
28 * Handles autoloading of classes.
30 * @param string $class A class name.
32 static public function autoload($class) {
33 if (0 === strpos($class, 'PhpParser\\')) {
34 $fileName = __DIR__ . strtr(substr($class, 9), '\\', '/') . '.php';
35 if (file_exists($fileName)) {