1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-27 12:24:39 +01:00
PHP-Parser/lib/PHPParser/Autoloader.php
2011-06-05 18:47:52 +02:00

30 lines
677 B
PHP

<?php
class PHPParser_Autoloader
{
/**
* Registers PHPParser_Autoloader as an SPL autoloader.
*/
static public function register()
{
ini_set('unserialize_callback_func', 'spl_autoload_call');
spl_autoload_register(array(new self, 'autoload'));
}
/**
* 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;
}
}
}