protected function detectLoop($parent, $child)
    {
        if ($child->name === $parent->name) {
            return true;
        }
        if (!isset($this->children[$child->name], $this->items[$parent->name])) {
            return false;
        }
        foreach ($this->children[$child->name] as $grandchild) {
            /* @var $grandchild Item */
            if ($this->detectLoop($parent, $grandchild)) {
                return true;
            }
        }

        return false;
    }
protected function detectLoop($parent, $child)
    {
        if ($child->name === $parent->name) {
            return true;
        }
        if (!isset($this->children[$child->name], $this->items[$parent->name])) {
            return false;
        }
        foreach ($this->children[$child->name] as $grandchild) {
            
            if ($this->detectLoop($parent, $grandchild)) {
                return true;
            }
        }

        return false;
    }
protected function detectLoop ( $ parent , $ child ) { if ( $ child -> name === $ parent -> name ) { return true ; } if ( ! isset ( $ this -> children [ $ child -> name ] , $ this -> items [ $ parent -> name ] ) ) { return false ; } foreach ( $ this -> children [ $ child -> name ] as $ grandchild ) { /* @var $grandchild Item */ if ( $ this -> detectLoop ( $ parent , $ grandchild ) ) { return true ; } } return false ; }
Checks whether there is a loop in the authorization item hierarchy.

@param Item $parent parent item
@param Item $child the child item that is to be added to the hierarchy
@return bool whether a loop exists
Checks whether there is a loop in the authorization item hierarchy .