From b8b7dbe7a459c3fe705ca0da8600c1a8544b27cc Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Wed, 27 Jun 2012 03:05:35 +0700 Subject: Allow extra SPL autoloader --- tests/mocks/autoloader.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'tests/mocks') diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php index e3ff7a8bd..1fcba788f 100644 --- a/tests/mocks/autoloader.php +++ b/tests/mocks/autoloader.php @@ -69,20 +69,25 @@ function autoload($class) } } - $file = isset($file) ? $file : $dir.$class.'.php'; + $file = (isset($file)) ? $file : $dir.$class.'.php'; if ( ! file_exists($file)) { $trace = debug_backtrace(); - // If the autoload call came from `class_exists` or `file_exists`, - // we skipped and return FALSE if ($trace[2]['function'] === 'class_exists' OR $trace[2]['function'] === 'file_exists') { + // If the autoload call came from `class_exists` or `file_exists`, + // we skipped and return FALSE + return FALSE; + } + elseif (($autoloader = spl_autoload_functions()) && end($autoloader) !== __FUNCTION__) + { + // If there was other custom autoloader, passed away return FALSE; } - throw new InvalidArgumentException("Unable to load {$class}."); + throw new InvalidArgumentException("Unable to load $class."); } include_once($file); -- cgit v1.2.3-24-g4f1b From 8f490da4cb6ad4ffa2c75cfcbd0e7896cdb4cd8c Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Wed, 27 Jun 2012 03:31:22 +0700 Subject: Comply styleguide --- tests/mocks/autoloader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/mocks') diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php index 1fcba788f..be1c2220c 100644 --- a/tests/mocks/autoloader.php +++ b/tests/mocks/autoloader.php @@ -87,7 +87,7 @@ function autoload($class) return FALSE; } - throw new InvalidArgumentException("Unable to load $class."); + throw new InvalidArgumentException("Unable to load {$class}."); } include_once($file); -- cgit v1.2.3-24-g4f1b