Skip to content
This repository was archived by the owner on Feb 6, 2020. It is now read-only.

Commit 40740cd

Browse files
author
fhein
committed
Removed reference to Tarjan. Added explanation why there are different
methods on how to resolve a single alias and how to resolve an array containing a mass of aliases.
1 parent 74f7ca5 commit 40740cd

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/ServiceManager.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,12 @@ private function validateServiceNames(array $config)
859859

860860
/**
861861
* Assuming that the alias name is valid (see above) resolve/add it.
862+
*
863+
* This is done differently from bulk mapping aliases for performance reasons, as the
864+
* algorithms for mapping a single item efficiently are different from those of mapping
865+
* many.
866+
*
867+
* @see mapAliasesToTargets() below
862868
*
863869
* @param string $alias
864870
* @param string $target
@@ -888,13 +894,12 @@ private function mapAliasToTarget($alias, $target)
888894
/**
889895
* Assuming that all provided alias keys are valid resolve them.
890896
*
891-
* This as an adaptation of Tarjan's strongly connected components
892-
* algorithm. We detect cycles as well reduce the graph so that
893-
* each alias key gets associated with the resolved service.
894897
* This function maps $this->aliases in place.
895898
*
896899
* This algorithm is fast for mass updates through configure().
897900
* It is not appropriate if just a single alias is added.
901+
*
902+
* @see mapAliasToTarget above
898903
*
899904
*/
900905
private function mapAliasesToTargets()
@@ -906,7 +911,6 @@ private function mapAliasesToTargets()
906911
}
907912
$tCursor = $this->aliases[$alias];
908913
$aCursor = $alias;
909-
$stack = [];
910914
while (isset($this->aliases[$tCursor])) {
911915
$tagged[$aCursor] = true;
912916
$this->aliases[$aCursor] = $this->aliases[$tCursor];

0 commit comments

Comments
 (0)