Skip to content

Commit

Permalink
simplify error-reporting a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
mindplay-dk committed Feb 7, 2019
1 parent bfc797f commit 11af777
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,18 @@ public function get($name)
if (isset($this->activations[$name])) {
$activations = array_flip($this->activations);

ksort($activations, SORT_NUMERIC);
ksort($activations, SORT_NUMERIC); // order by activation depth

for ($i=1; $i<count($activations); $i++) {
if ($activations[$i] === $name) {
break;
} else {
unset($activations[$i]);
}
}
$activations = array_slice($activations, array_search($name, $activations, true));

$activations[] = $name;

$activation_path = implode(" -> ", $activations) . " -> {$name}";
$activation_path = implode(" -> ", $activations);

throw new ContainerException("Dependency cycle detected: " . $activation_path);
}

$this->activations[$name] = count($this->activations) + 1;
$this->activations[$name] = count($this->activations);

if (isset($this->factory[$name])) {
$this->values[$name] = $this->call($this->factory[$name], $this->factory_map[$name]);
Expand Down

0 comments on commit 11af777

Please sign in to comment.