private function visit(Vertex $definition)
{
$definition->state = Vertex::IN_PROGRESS;
foreach ($definition->dependencyList as $dependency) {
if (!isset($this->nodeList[$dependency])) {
throw new \RuntimeException(sprintf('Fixture "%s" has a dependency of fixture "%s", but it not listed to be loaded.', get_class($definition->value), $dependency));
}
$childDefinition = $this->nodeList[$dependency];
// allow self referencing classes
if ($definition === $childDefinition) {
continue;
}
switch ($childDefinition->state) {
case Vertex::VISITED:
break;
case Vertex::IN_PROGRESS:
if (!$this->allowCyclicDependencies) {
throw new CircularReferenceException(sprintf('Graph contains cyclic dependency between the classes "%s" and' . ' "%s". An example of this problem would be the following: ' . 'Class C has class B as its dependency. Then, class B has class A has its dependency. ' . 'Finally, class A has class C as its dependency.', $definition->value->getName(), $childDefinition->value->getName()));
}
break;
case Vertex::NOT_VISITED:
$this->visit($childDefinition);
}
}
$definition->state = Vertex::VISITED;
$this->sortedNodeList[] = $definition->value;
}