From 19869ce00ca6eb7b7f0f700776d35bf88f6936f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20Haso=C5=88?= Date: Tue, 12 Feb 2013 09:12:17 +0100 Subject: [PATCH] Fixed autoloader registration for tests if phpunit is installed as package together with Twig --- lib/Twig/Autoloader.php | 10 ++++++++-- test/bootstrap.php | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/Twig/Autoloader.php b/lib/Twig/Autoloader.php index d1e005b..736605d 100644 --- a/lib/Twig/Autoloader.php +++ b/lib/Twig/Autoloader.php @@ -18,11 +18,17 @@ class Twig_Autoloader { /** * Registers Twig_Autoloader as an SPL autoloader. + * + * @param Bolean $prepend Whether to prepend the autoloader or not. */ - public static function register() + public static function register($prepend = false) { ini_set('unserialize_callback_func', 'spl_autoload_call'); - spl_autoload_register(array(new self, 'autoload')); + if ($prepend && version_compare(phpversion(), '5.3.0RC1', '>=')) { + spl_autoload_register(array(new self, 'autoload'), true, $prepend); + } else { + spl_autoload_register(array(new self, 'autoload'), true); + } } /** diff --git a/test/bootstrap.php b/test/bootstrap.php index 36eb46a..aecb976 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -10,4 +10,4 @@ */ require_once dirname(__FILE__).'/../lib/Twig/Autoloader.php'; -Twig_Autoloader::register(); +Twig_Autoloader::register(true); -- 1.7.2.5