src/Rbac/DbManager.php
protected function detectLoop($parent, $child)
    {
        if ($child->name === $parent->name) {
            return reject(true);
        }

        return $this->getChildren($child->name)
            ->then(function($children) use ($parent) {
                $promises = [];
                foreach ($children as $grandchild) {
                    $promises[] = $this->detectLoop($parent, $grandchild);
                }
                return !empty($promises)
                    ? all($promises)->then(function() { return false; })
                    : false;
            }, function() {
                return false;
            });
    }
protected function detectLoop($parent, $child)
    {
        if ($child->name === $parent->name) {
            return reject(true);
        }

        return $this->getChildren($child->name)
            ->then(function($children) use ($parent) {
                $promises = [];
                foreach ($children as $grandchild) {
                    $promises[] = $this->detectLoop($parent, $grandchild);
                }
                return !empty($promises)
                    ? all($promises)->then(function() { return false; })
                    : false;
            }, function() {
                return false;
            });
    }
Checks whether there is a loop in the authorization item hierarchy.
@param Item $parent the parent item
@param Item $child the child item to be added to the hierarchy
@return ExtendedPromiseInterface with bool whether a loop exists