2011-06-05 18:47:52 +02:00
|
|
|
<?php
|
|
|
|
|
2011-11-27 12:53:48 +01:00
|
|
|
/**
|
|
|
|
* @codeCoverageIgnore
|
|
|
|
*/
|
2011-06-05 18:47:52 +02:00
|
|
|
class PHPParser_Autoloader
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Registers PHPParser_Autoloader as an SPL autoloader.
|
|
|
|
*/
|
|
|
|
static public function register()
|
|
|
|
{
|
|
|
|
ini_set('unserialize_callback_func', 'spl_autoload_call');
|
2011-11-06 17:07:38 +01:00
|
|
|
spl_autoload_register(array(__CLASS__, 'autoload'));
|
2011-06-05 18:47:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles autoloading of classes.
|
|
|
|
*
|
|
|
|
* @param string $class A class name.
|
|
|
|
*/
|
|
|
|
static public function autoload($class)
|
|
|
|
{
|
|
|
|
if (0 !== strpos($class, 'PHPParser')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$file = dirname(dirname(__FILE__)) . '/' . strtr($class, '_', '/') . '.php';
|
|
|
|
if (is_file($file)) {
|
|
|
|
require $file;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|