Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/autoloader-factory-phpversion' of https://github…
Browse files Browse the repository at this point in the history
….com/mwillbanks/zf2 into hotfix/autoloader-factory-phpversion
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/AutoloaderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,15 @@ public static function factory($options = null)
);
}

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)
);
// 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.7', '>=')) {
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) {
Expand Down
3 changes: 3 additions & 0 deletions test/AutoloaderFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ public function testRegisteringValidMapFilePopulatesAutoloader()
*/
public function testFactoryCatchesInvalidClasses()
{
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(
'InvalidInterfaceAutoloader' => array()
Expand Down

0 comments on commit f9dc85c

Please sign in to comment.