From dcff8a4f5a2e90ebb9ddf49e4c8aec7186969cf9 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 1 Jun 2014 21:18:49 +0200 Subject: [PATCH] PHP 5.3+: Replace custom autoloader with composer autoloader. --- tests/bootstrap.php | 40 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index cb9fc617..2472d3b2 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -7,37 +7,13 @@ date_default_timezone_set('UTC'); -// Set up include path accordingly. This is especially required because some -// class files of phpseclib require() other dependencies. -set_include_path(implode(PATH_SEPARATOR, array( - dirname(__FILE__) . '/../phpseclib/', - dirname(__FILE__) . '/', - get_include_path(), -))); - -function phpseclib_is_includable($suffix) -{ - foreach (explode(PATH_SEPARATOR, get_include_path()) as $prefix) { - $ds = substr($prefix, -1) == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR; - $file = $prefix . $ds . $suffix; - - if (file_exists($file)) { - return true; - } - } - - return false; +$loader_path = __DIR__ . '/../vendor/autoload.php'; +if (!file_exists($loader_path)) { + echo "Dependencies must be installed using composer:\n\n"; + echo "php composer.phar install --dev\n\n"; + echo "See http://getcomposer.org for help with installing composer\n"; + exit(1); } -function phpseclib_autoload($class) -{ - $file = str_replace('_', '/', $class) . '.php'; - - if (phpseclib_is_includable($file)) { - // @codingStandardsIgnoreStart - require $file; - // @codingStandardsIgnoreEnd - } -} - -spl_autoload_register('phpseclib_autoload'); +$loader = include $loader_path; +$loader->add('', __DIR__);