Mercurial > hg > isophonics-drupal-site
diff vendor/nikic/php-parser/lib/PhpParser/Autoloader.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/nikic/php-parser/lib/PhpParser/Autoloader.php Wed Nov 29 16:09:58 2017 +0000 @@ -0,0 +1,40 @@ +<?php + +namespace PhpParser; + +/** + * @codeCoverageIgnore + */ +class Autoloader +{ + /** @var bool Whether the autoloader has been registered. */ + private static $registered = false; + + /** + * Registers PhpParser\Autoloader as an SPL autoloader. + * + * @param bool $prepend Whether to prepend the autoloader instead of appending + */ + static public function register($prepend = false) { + if (self::$registered === true) { + return; + } + + spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend); + self::$registered = true; + } + + /** + * Handles autoloading of classes. + * + * @param string $class A class name. + */ + static public function autoload($class) { + if (0 === strpos($class, 'PhpParser\\')) { + $fileName = __DIR__ . strtr(substr($class, 9), '\\', '/') . '.php'; + if (file_exists($fileName)) { + require $fileName; + } + } + } +}