private function checkOutEdges(array $edges)
    {
        foreach ($edges as $edge) {
            $node = $edge->getDestNode();
            $id = $node->getId();

            if (empty($this->checkedNodes[$id])) {
                // Don't check circular references for lazy edges
                if (!$node->getValue() || (!$edge->isLazy() && !$edge->isWeak())) {
                    $searchKey = array_search($id, $this->currentPath);
                    $this->currentPath[] = $id;

                    if (false !== $searchKey) {
                        throw new ServiceCircularReferenceException($id, \array_slice($this->currentPath, $searchKey));
                    }

                    $this->checkOutEdges($node->getOutEdges());
                }

                $this->checkedNodes[$id] = true;
                array_pop($this->currentPath);
            }
        }
    }
private function checkOutEdges(array $edges)
    {
        foreach ($edges as $edge) {
            $node = $edge->getDestNode();
            $id = $node->getId();

            if (empty($this->checkedNodes[$id])) {
                // Don't check circular references for lazy edges
                if (!$node->getValue() || (!$edge->isLazy() && !$edge->isWeak())) {
                    $searchKey = array_search($id, $this->currentPath);
                    $this->currentPath[] = $id;

                    if (false !== $searchKey) {
                        throw new ServiceCircularReferenceException($id, \array_slice($this->currentPath, $searchKey));
                    }

                    $this->checkOutEdges($node->getOutEdges());
                }

                $this->checkedNodes[$id] = true;
                array_pop($this->currentPath);
            }
        }
    }
private function checkOutEdges ( array $ edges ) { foreach ( $ edges as $ edge ) { $ node = $ edge -> getDestNode ( ) ; $ id = $ node -> getId ( ) ; if ( empty ( $ this -> checkedNodes [ $ id ] ) ) { // Don't check circular references for lazy edges if ( ! $ node -> getValue ( ) || ( ! $ edge -> isLazy ( ) && ! $ edge -> isWeak ( ) ) ) { $ searchKey = array_search ( $ id , $ this -> currentPath ) ; $ this -> currentPath [ ] = $ id ; if ( false !== $ searchKey ) { throw new ServiceCircularReferenceException ( $ id , \ array_slice ( $ this -> currentPath , $ searchKey ) ) ; } $ this -> checkOutEdges ( $ node -> getOutEdges ( ) ) ; } $ this -> checkedNodes [ $ id ] = true ; array_pop ( $ this -> currentPath ) ; } } }
Checks for circular references.

@param ServiceReferenceGraphEdge[] $edges An array of Edges

@throws ServiceCircularReferenceException when a circular reference is found
Checks for circular references .