2014-08-28 10:45:55 +02:00
|
|
|
<?php
|
|
|
|
namespace Szurubooru;
|
|
|
|
|
|
|
|
final class AutoLoader
|
|
|
|
{
|
|
|
|
public static function init()
|
|
|
|
{
|
2014-09-09 12:34:57 +02:00
|
|
|
spl_autoload_register([__CLASS__, 'includeClassName']);
|
2014-08-28 10:45:55 +02:00
|
|
|
}
|
|
|
|
|
2014-09-09 12:34:57 +02:00
|
|
|
public static function includeClassName($className)
|
2014-08-28 10:45:55 +02:00
|
|
|
{
|
2014-09-01 21:25:13 +02:00
|
|
|
if (strpos($className, 'Szurubooru') === false)
|
|
|
|
return;
|
2014-08-28 10:45:55 +02:00
|
|
|
$className = str_replace('\\', DIRECTORY_SEPARATOR, $className);
|
|
|
|
$className = str_replace('Szurubooru', '', $className);
|
|
|
|
if (strpos($className, 'Tests') !== false)
|
|
|
|
$className = dirname(__DIR__) . DIRECTORY_SEPARATOR . str_replace('Tests', 'tests', $className);
|
|
|
|
else
|
|
|
|
$className = __DIR__ . DIRECTORY_SEPARATOR . $className;
|
|
|
|
$className .= '.php';
|
2014-09-09 12:34:57 +02:00
|
|
|
include($className);
|
2014-08-28 10:45:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AutoLoader::init();
|
2014-09-14 16:17:52 +02:00
|
|
|
|
|
|
|
require_once(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');
|
2014-09-16 13:27:12 +02:00
|
|
|
|
|
|
|
function turnErrorsIntoExceptions()
|
|
|
|
{
|
|
|
|
set_error_handler(
|
|
|
|
function($errno, $errstr, $errfile, $errline, array $errcontext)
|
|
|
|
{
|
|
|
|
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
turnErrorsIntoExceptions();
|