From 1732edfb63f6aad479d4c8e1916a6de1b12cece9 Mon Sep 17 00:00:00 2001 From: Mike Willbanks Date: Fri, 24 Feb 2012 08:27:14 -0600 Subject: [PATCH 1/4] updated the autoloader factory to only check the subclass of with versions 5.3.7 and greater --- src/AutoloaderFactory.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/AutoloaderFactory.php b/src/AutoloaderFactory.php index 8d7d1a0..32aa105 100644 --- a/src/AutoloaderFactory.php +++ b/src/AutoloaderFactory.php @@ -102,7 +102,10 @@ public static function factory($options = null) ); } - if (!is_subclass_of($class, 'Zend\Loader\SplAutoloader')) { + // unfortunately is_subclass_of is broken on some 5.3 versions + // additionally instanceof is also broken for this use case + if (version_compare(PHP_VERSION, '5.3.6', '>')) { + if (!is_subclass_of($class, 'Zend\Loader\SplAutoloader')) { require_once 'Exception/InvalidArgumentException.php'; throw new Exception\InvalidArgumentException( sprintf('Autoloader class %s must implement Zend\\Loader\\SplAutoloader', $class) From da1ce8b8511504e32b2828c084517b10da3e0b80 Mon Sep 17 00:00:00 2001 From: Mike Willbanks Date: Fri, 24 Feb 2012 08:31:59 -0600 Subject: [PATCH 2/4] fixed parse error --- src/AutoloaderFactory.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/AutoloaderFactory.php b/src/AutoloaderFactory.php index 32aa105..c3536f0 100644 --- a/src/AutoloaderFactory.php +++ b/src/AutoloaderFactory.php @@ -105,11 +105,12 @@ public static function factory($options = null) // unfortunately is_subclass_of is broken on some 5.3 versions // additionally instanceof is also broken for this use case if (version_compare(PHP_VERSION, '5.3.6', '>')) { - if (!is_subclass_of($class, 'Zend\Loader\SplAutoloader')) { - require_once 'Exception/InvalidArgumentException.php'; - throw new Exception\InvalidArgumentException( - sprintf('Autoloader class %s must implement Zend\\Loader\\SplAutoloader', $class) - ); + if (!is_subclass_of($class, 'Zend\Loader\SplAutoloader')) { + require_once 'Exception/InvalidArgumentException.php'; + throw new Exception\InvalidArgumentException( + sprintf('Autoloader class %s must implement Zend\\Loader\\SplAutoloader', $class) + ); + } } if ($class === static::STANDARD_AUTOLOADER) { From 4fe59bb94ca5f5e2c71664397122e33178a62dc3 Mon Sep 17 00:00:00 2001 From: Mike Willbanks Date: Fri, 24 Feb 2012 08:48:18 -0600 Subject: [PATCH 3/4] added markTestSkipped for invalid interface autoloader --- test/AutoloaderFactoryTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/AutoloaderFactoryTest.php b/test/AutoloaderFactoryTest.php index 9660649..d7bbf26 100644 --- a/test/AutoloaderFactoryTest.php +++ b/test/AutoloaderFactoryTest.php @@ -88,6 +88,9 @@ public function testRegisteringValidMapFilePopulatesAutoloader() */ public function testFactoryCatchesInvalidClasses() { + if (version_compare(PHP_VERSION, '5.3.6', '<=')) { + $this->markTestSkipped('Cannot test invalid interface loader with versions less than or equal to 5.3.6'); + } include __DIR__ . '/_files/InvalidInterfaceAutoloader.php'; AutoloaderFactory::factory(array( 'InvalidInterfaceAutoloader' => array() From 096b36e9871ba28e78251a22e2d55f01846acfbc Mon Sep 17 00:00:00 2001 From: Mike Willbanks Date: Fri, 24 Feb 2012 14:05:30 -0600 Subject: [PATCH 4/4] changed how version compare worked --- src/AutoloaderFactory.php | 2 +- test/AutoloaderFactoryTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/AutoloaderFactory.php b/src/AutoloaderFactory.php index c3536f0..d3e08d3 100644 --- a/src/AutoloaderFactory.php +++ b/src/AutoloaderFactory.php @@ -104,7 +104,7 @@ public static function factory($options = null) // unfortunately is_subclass_of is broken on some 5.3 versions // additionally instanceof is also broken for this use case - if (version_compare(PHP_VERSION, '5.3.6', '>')) { + if (version_compare(PHP_VERSION, '5.3.7', '>=')) { if (!is_subclass_of($class, 'Zend\Loader\SplAutoloader')) { require_once 'Exception/InvalidArgumentException.php'; throw new Exception\InvalidArgumentException( diff --git a/test/AutoloaderFactoryTest.php b/test/AutoloaderFactoryTest.php index d7bbf26..9220c03 100644 --- a/test/AutoloaderFactoryTest.php +++ b/test/AutoloaderFactoryTest.php @@ -88,8 +88,8 @@ public function testRegisteringValidMapFilePopulatesAutoloader() */ public function testFactoryCatchesInvalidClasses() { - if (version_compare(PHP_VERSION, '5.3.6', '<=')) { - $this->markTestSkipped('Cannot test invalid interface loader with versions less than or equal to 5.3.6'); + if (!version_compare(PHP_VERSION, '5.3.7', '>=')) { + $this->markTestSkipped('Cannot test invalid interface loader with versions less than 5.3.7'); } include __DIR__ . '/_files/InvalidInterfaceAutoloader.php'; AutoloaderFactory::factory(array(