Skip to content

Commit

Permalink
[DepdenencyInjection] Prevent self-referencing aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek authored and fabpot committed Feb 12, 2011
1 parent 6b25015 commit 315f96d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ContainerBuilder.php
Expand Up @@ -427,6 +427,10 @@ public function setAlias($alias, $id)
throw new \InvalidArgumentException('$id must be a string, or an Alias object.');
}

if ($alias === strtolower($id)) {
throw new \InvalidArgumentException('An alias can not reference itself, got a circular reference on "'.$alias.'".');
}

unset($this->definitions[$alias]);

$this->aliases[$alias] = $id;
Expand Down

0 comments on commit 315f96d

Please sign in to comment.