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

Commit

Permalink
Merge branch 'hotfix/3329'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Jan 4, 2013
2 parents d51a556 + d4059d3 commit 8553b0b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
9 changes: 2 additions & 7 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ public function configure(Di $di)
if (isset($this->data['definition'])) {
$this->configureDefinition($di, $this->data['definition']);
}

if (isset($this->data['instance'])) {
$this->configureInstance($di, $this->data['instance']);
}

}

/**
Expand All @@ -90,8 +88,8 @@ public function configureDefinition(Di $di, $definition)
$definitions[] = $definition;
}
}
$definitions = new DefinitionList($definitions);
$di->setDefinitionList($definitions);
$definitionList = new DefinitionList($definitions);
$di->setDefinitionList($definitionList);
} elseif (isset($definitionData['use_annotations']) && $definitionData['use_annotations']) {
/* @var $runtimeDefinition Definition\RuntimeDefinition */
$runtimeDefinition = $di
Expand Down Expand Up @@ -146,9 +144,7 @@ public function configureDefinition(Di $di, $definition)
}
}
}

}

}

/**
Expand Down Expand Up @@ -200,7 +196,6 @@ public function configureInstance(Di $di, $instanceData)
}
}
}

}

}
32 changes: 17 additions & 15 deletions src/DefinitionList.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,11 @@ public function getClassSupertypes($class)
foreach ($this as $definition) {
if ($definition->hasClass($class)) {
$supertypes = array_merge($supertypes, $definition->getClassSupertypes($class));
if (!$definition instanceof Definition\PartialMarker) {
return $supertypes;
if ($definition instanceof Definition\PartialMarker) {
continue;
}

return $supertypes;
}
}
return $supertypes;
Expand All @@ -165,9 +167,9 @@ public function getInstantiator($class)
$value = $definition->getInstantiator($class);
if ($value === null && $definition instanceof Definition\PartialMarker) {
continue;
} else {
return $value;
}

return $value;
}
}

Expand All @@ -184,9 +186,9 @@ public function hasMethods($class)
if ($definition->hasClass($class)) {
if ($definition->hasMethods($class) === false && $definition instanceof Definition\PartialMarker) {
continue;
} else {
return $definition->hasMethods($class);
}

return $definition->hasMethods($class);
}
}

Expand All @@ -198,14 +200,14 @@ public function hasMethods($class)
*/
public function hasMethod($class, $method)
{
if (!$this->hasMethods($class)) {
return false;
}

/** @var $definition Definition\DefinitionInterface */
foreach ($this as $definition) {
if ($definition->hasClass($class)) {
if ($definition->hasMethods($class) === false && $definition instanceof Definition\PartialMarker) {
continue;
} else {
return $definition->hasMethod($class, $method);
}
if ($definition->hasMethod($class, $method)) {
return true;
}
}

Expand All @@ -221,11 +223,11 @@ public function getMethods($class)
$methods = array();
foreach ($this as $definition) {
if ($definition->hasClass($class)) {
if ($definition instanceof Definition\PartialMarker) {
$methods = array_merge($definition->getMethods($class), $methods);
} else {
if (!$definition instanceof Definition\PartialMarker) {
return array_merge($definition->getMethods($class), $methods);
}

$methods = array_merge($definition->getMethods($class), $methods);
}
}

Expand Down
13 changes: 13 additions & 0 deletions test/DefinitionListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ public function testGetClassSupertypes()
$definitionList = new DefinitionList(array($definitionClassA, $definitionClassB));

$this->assertEquals($superTypesA, $definitionList->getClassSupertypes("A"));
}

public function testHasMethod()
{
$definitionClass = new ClassDefinition('foo');
$definitionClass->addMethod('doFoo');
$definitionList = new DefinitionList(array($definitionClass));

$this->assertTrue($definitionList->hasMethod('foo', 'doFoo'));
$this->assertFalse($definitionList->hasMethod('foo', 'doBar'));

$definitionClass->addMethod('doBar');

$this->assertTrue($definitionList->hasMethod('foo', 'doBar'));
}
}

0 comments on commit 8553b0b

Please sign in to comment.