Determine if a path is beneath another path.

This is strictly string comparison; it does no path validation or path
checking.

@param string $child
@param string $parent
@return boolean
423651
public static function isBeneath(string $child, string $parent)
    {
        if ((strlen($child) >= strlen($parent))
            && strpos($child, $parent) === 0) {
                return true;
        }

        return false;
    }
189391
public function hasChildren()
    {
        if ($this->isDot()) {
            return false;
        }
        if (is_link($this->getPathname()) && !($this->flags & self::FOLLOW_SYMLINKS)) {
            return false;
        }
        return $this->isDir();
    }
643063
public static <T> boolean isDescendantOfOrEqualTo(TreeDef.Parented<T> treeDef, T child, T parent) {
		if (child.equals(parent)) {
			return true;
		} else {
			return isDescendantOf(treeDef, child, parent);
		}
	}
267389
public function findChildrenTreeByParentId($parent_id)
    {
        $qb = $this->createQueryBuilder();

        $qb = $this->alterQueryBuilderWithParentRoot($qb, $parent_id);

        $qb->orderBy($qb->getRootAliases()[0] . '.lft', 'ASC');

        return $this->getResultFromQueryBuilder($qb);
    }
766882
protected function addChild($parent, $child)
    {
        if (is_string($parent)) {
            $parent = $this->findItem($parent);
        }

        if (is_string($child)) {
            $child = $this->findItem($child);
        }

        echo "    > adding $child->name as child to $parent->name ...";
        $time = microtime(true);
        $this->authManager->addChild($parent, $child);
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
    }
764418
function contains(parent, child) {
		if (!parent || !child) { return false; }
		if (parent === child) { return true; }
		var compare = parent.compareDocumentPosition(child);  // useful to break out for debugging
		return Boolean(compare & 16);
	}
1116705
public static <T> boolean isDescendantOf(TreeDef.Parented<T> treeDef, T child, T parent) {
		T candidateParent = treeDef.parentOf(child);
		while (candidateParent != null) {
			if (candidateParent.equals(parent)) {
				return true;
			} else {
				candidateParent = treeDef.parentOf(candidateParent);
			}
		}
		return false;
	}
640188
public static function isBeneathResolve(
        string $child,
        string $parent
    ) {
        $args = [
            'child' => $child,
            'parent' => $parent,
        ];

        array_walk($args, function (&$dir) {
            $dir = Filesystem::resolve($dir);
        });

        return Directories::isBeneath($args['child'], $args['parent']);
    }
82458
protected function _constructStringParentStringChild($parent, $child = null)
    {
        // obtain ref to the filesystem layer
        $fs = FileSystem::getFileSystem();

        if ($child === null) {
            throw new NullPointerException("Argument to function must not be null");
        }
        if ($parent !== null) {
            if ($parent === "") {
                $this->path = $fs->resolve($fs->getDefaultParent(), $fs->normalize($child));
            } else {
                $this->path = $fs->resolve($fs->normalize($parent), $fs->normalize($child));
            }
        } else {
            $this->path = (string) $fs->normalize($child);
        }
        $this->prefixLength = (int) $fs->prefixLength($this->path);
    }
956982
protected final function appendXMLTo(
       SimpleXMLElement $parent,
       string $child): SimpleXMLElement
   {
       return $this->appendTo(
           $parent,
           simplexml_load_string(str_replace("\n", "\n\t", $child)));
   }
672096
def parent_child_paths(path, some_path):
        
        return PathFilterUtil.is_child(path, some_path) or PathFilterUtil.is_child(some_path, path)
808843
public static function containsPath(/*string*/ $top, /*string*/ $sub) {
    $top = self::realPath($top);
    $sub = self::realPath($sub);
    return self::isDir($top) && self::isDir($sub) &&
      0 === strpos($sub, $top . '/');
  }
828007
public function canAddChild($parent, $child)
	{
		return \App::$domain->rbac->item->canAddChild($parent, $child);
	}
344191
private static function fullyQualify(string $subdomain, string $parent): string
    {
        if ('@' === $subdomain) {
            return $parent;
        }

        if ('.' !== substr($subdomain, -1, 1)) {
            return $subdomain.'.'.$parent;
        }

        return $subdomain;
    }
559788
function containsDeep(parent, child) {
        var node = child;
        while (node) {
            if (node == parent) return true;

            node = getParentNode(node);
        }
        return false;
    }
412744
public function detectParent()
    {
        // Look for a string, then a number (the parent id), followed by a non-action
        // string, then possiby a number and/or an action string and then the end
        $pattern = '#([a-z-]+)/(\d+)/(?!'.implode('|', $this->actions).')[a-z-]+(?:/\d+)?(/('.implode('|', $this->actions).'))?$#i';
        if (preg_match($pattern, $this->path, $matches)) {
            return [$matches[1], $matches[2]];
        }

        return false;
    }
851878
protected function _pushParent(&$parent)
    {
        $children    = &$this->_getElementChildren($parent);
        $pathSegment = $this->_getElementPathSegment(null, $parent);

        $this->_pushPathSegment($pathSegment);

        reset($children);
        array_unshift($this->parents, $children);
    }