Skip to content
Browse files

[Loader] Re-worked algorithm to be compatible with PHP 5.3.3

is_subclass_of don't work as expected in earlier versions of PHP like 5.3.3
  • Loading branch information...
1 parent 7c65b29 commit 4859008594c1e40cb05c56ac641901c1d77880cf @Maks3w Maks3w committed May 28, 2012
Showing with 13 additions and 8 deletions.
  1. +9 −7 library/Zend/Loader/PluginClassLoader.php
  2. +4 −1 tests/Zend/Loader/PluginClassLoaderTest.php
View
16 library/Zend/Loader/PluginClassLoader.php
@@ -140,13 +140,15 @@ public function registerPlugins($map)
}
foreach ($map as $name => $class) {
- if ((is_int($name) || is_numeric($name))
- && (is_object($class) || class_exists($class))
- && is_subclass_of($class, 'Traversable')
- ) {
- $subMap = new $class();
- $this->registerPlugins($subMap);
- continue;
+ if (is_int($name) || is_numeric($name)) {
+ if (!is_object($class) && class_exists($class)) {
+ $class = new $class();
+ }
+
+ if ($class instanceof Traversable) {
+ $this->registerPlugins($class);
+ continue;
+ }
}
$this->registerPlugin($name, $class);
View
5 tests/Zend/Loader/PluginClassLoaderTest.php
@@ -33,6 +33,9 @@
*/
class PluginClassLoaderTest extends \PHPUnit_Framework_TestCase
{
+ /** @var PluginClassLoader */
+ public $loader;
+
public function setUp()
{
// Clear any static maps
@@ -262,8 +265,8 @@ public function testMapPrecedenceIsExplicitTrumpsConstructorTrumpsStaticTrumpsIn
public function testRegisterPluginsCanAcceptArrayElementWithClassNameProvidingAMap()
{
- $this->loader->registerPlugins(array('ZendTest\Loader\TestAsset\TestPluginMap'));
$pluginMap = new TestAsset\TestPluginMap;
+ $this->loader->registerPlugins(array('ZendTest\Loader\TestAsset\TestPluginMap'));
$this->assertEquals($pluginMap->map, $this->loader->getRegisteredPlugins());
}

0 comments on commit 4859008

Please sign in to comment.
Something went wrong with that request. Please try again.