Fixed autoloader registration for tests if phpunit is installed as package together with Twig

This commit is contained in:
Martin Hasoň
2013-02-12 09:12:17 +01:00
parent 80fd11cbbe
commit 19869ce00c
2 changed files with 9 additions and 3 deletions
+8 -2
View File
@@ -18,11 +18,17 @@ class Twig_Autoloader
{ {
/** /**
* Registers Twig_Autoloader as an SPL 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'); 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);
}
} }
/** /**
+1 -1
View File
@@ -10,4 +10,4 @@
*/ */
require_once dirname(__FILE__).'/../lib/Twig/Autoloader.php'; require_once dirname(__FILE__).'/../lib/Twig/Autoloader.php';
Twig_Autoloader::register(); Twig_Autoloader::register(true);