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

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2 into cach…
Browse files Browse the repository at this point in the history
…e_filesystemSpeedup
  • Loading branch information
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 5 deletions.
13 changes: 13 additions & 0 deletions src/Definition/CompilerDefinition.php
Expand Up @@ -107,6 +107,19 @@ protected function processClass($class)
}
}

$rTarget = $rClass;
$supertypes = array();
do {
$supertypes = array_merge($supertypes, $rTarget->getInterfaceNames());
if (!($rTargetParent = $rTarget->getParentClass())) {
break;
}
$supertypes[] = $rTargetParent->getName();
$rTarget = $rTargetParent;
} while (true);

$def['supertypes'] = $supertypes;

if ($def['instantiator'] == null) {
if ($rClass->isInstantiable()) {
$def['instantiator'] = '__construct';
Expand Down
2 changes: 1 addition & 1 deletion src/Di.php
Expand Up @@ -208,7 +208,7 @@ public function newInstance($name, array $params = array(), $isShared = true)

if ($injectionMethods || $supertypeInjectionMethods) {
foreach ($injectionMethods as $injectionMethod => $methodIsRequired) {
if ($injectionMethod !== '__construct'){
if ($injectionMethod !== '__construct') {
$this->handleInjectionMethodForInstance($instance, $injectionMethod, $params, $alias, $methodIsRequired);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidCallbackException.php
@@ -1,6 +1,6 @@
<?php
namespace Zend\Di\Exception;

class InvalidCallbackException extends InvalidArgumentException
class InvalidCallbackException extends InvalidArgumentException
{
}
5 changes: 2 additions & 3 deletions src/ServiceLocator/Generator.php
Expand Up @@ -171,7 +171,7 @@ public function getCodeGenerator($filename = null)

// Create fetch of stored service
if ($im->hasSharedInstance($name, $params)) {
$getterBody .= sprintf("if (isset(\$this->services['%s'])) {\n", $name);
$getterBody .= sprintf("if (isset(\$this->services['%s'])) {\n", $name);
$getterBody .= sprintf("%sreturn \$this->services['%s'];\n}\n\n", $indent, $name);
}

Expand Down Expand Up @@ -275,8 +275,7 @@ protected function reduceAliases(array $aliasList)
{
$reduced = array();
$aliases = array_keys($aliasList);
foreach ($aliasList as $alias => $service)
{
foreach ($aliasList as $alias => $service) {
if (in_array($service, $aliases)) {
do {
$service = $aliasList[$service];
Expand Down
13 changes: 13 additions & 0 deletions test/Definition/CompilerDefinitionTest.php
Expand Up @@ -42,4 +42,17 @@ public function testCompilerCompilesAgainstConstructorInjectionAssets()
$definition->getMethodParameters('ZendTest\Di\TestAsset\CompilerClasses\C', 'setB')
);
}

public function testCompilerSupertypes()
{
$definition = new CompilerDefinition;
$definition->addDirectory(__DIR__ . '/../TestAsset/CompilerClasses');
$definition->compile();
$this->assertCount(0, $definition->getClassSupertypes('ZendTest\Di\TestAsset\CompilerClasses\C'));
$this->assertCount(1, $definition->getClassSupertypes('ZendTest\Di\TestAsset\CompilerClasses\D'));
$this->assertCount(2, $definition->getClassSupertypes('ZendTest\Di\TestAsset\CompilerClasses\E'));
$this->assertContains('ZendTest\Di\TestAsset\CompilerClasses\C', $definition->getClassSupertypes('ZendTest\Di\TestAsset\CompilerClasses\D'));
$this->assertContains('ZendTest\Di\TestAsset\CompilerClasses\C', $definition->getClassSupertypes('ZendTest\Di\TestAsset\CompilerClasses\E'));
$this->assertContains('ZendTest\Di\TestAsset\CompilerClasses\D', $definition->getClassSupertypes('ZendTest\Di\TestAsset\CompilerClasses\E'));
}
}
8 changes: 8 additions & 0 deletions test/TestAsset/CompilerClasses/E.php
@@ -0,0 +1,8 @@
<?php

namespace ZendTest\Di\TestAsset\CompilerClasses;

class E extends D
{

}

0 comments on commit 34ecc47

Please sign in to comment.