private function followLinks(array $references, $flags = 0)
    {
        $result = array();

        foreach ($references as $key => $reference) {
            // Not a link
            if (!$this->isLinkReference($reference)) {
                $result[] = $reference;

                if ($flags & self::STOP_ON_FIRST) {
                    return $result;
                }

                continue;
            }

            $referencedPath = substr($reference, 1);

            // Get all the file system paths that this link points to
            // and append them to the result
            foreach ($this->searchReferences($referencedPath, $flags) as $referencedReferences) {
                // Follow links recursively
                $referencedReferences = $this->followLinks($referencedReferences);

                // Append all resulting target paths to the result
                foreach ($referencedReferences as $referencedReference) {
                    $result[] = $referencedReference;

                    if ($flags & self::STOP_ON_FIRST) {
                        return $result;
                    }
                }
            }
        }

        return $result;
    }
private function followLinks(array $references, $flags = 0)
    {
        $result = array();

        foreach ($references as $key => $reference) {
            // Not a link
            if (!$this->isLinkReference($reference)) {
                $result[] = $reference;

                if ($flags & self::STOP_ON_FIRST) {
                    return $result;
                }

                continue;
            }

            $referencedPath = substr($reference, 1);

            // Get all the file system paths that this link points to
            // and append them to the result
            foreach ($this->searchReferences($referencedPath, $flags) as $referencedReferences) {
                // Follow links recursively
                $referencedReferences = $this->followLinks($referencedReferences);

                // Append all resulting target paths to the result
                foreach ($referencedReferences as $referencedReference) {
                    $result[] = $referencedReference;

                    if ($flags & self::STOP_ON_FIRST) {
                        return $result;
                    }
                }
            }
        }

        return $result;
    }
private function followLinks ( array $ references , $ flags = 0 ) { $ result = array ( ) ; foreach ( $ references as $ key => $ reference ) { // Not a link if ( ! $ this -> isLinkReference ( $ reference ) ) { $ result [ ] = $ reference ; if ( $ flags & self :: STOP_ON_FIRST ) { return $ result ; } continue ; } $ referencedPath = substr ( $ reference , 1 ) ; // Get all the file system paths that this link points to // and append them to the result foreach ( $ this -> searchReferences ( $ referencedPath , $ flags ) as $ referencedReferences ) { // Follow links recursively $ referencedReferences = $ this -> followLinks ( $ referencedReferences ) ; // Append all resulting target paths to the result foreach ( $ referencedReferences as $ referencedReference ) { $ result [ ] = $ referencedReference ; if ( $ flags & self :: STOP_ON_FIRST ) { return $ result ; } } } } return $ result ; }
Follows any link in a list of references.

This method takes all the given references, checks for links starting
with "@" and recursively expands those links to their target references.
The target references may be `null` or absolute filesystem paths.

Null values are returned unchanged.

Absolute filesystem paths are returned unchanged.

The flag `STOP_ON_FIRST` may be used to stop the search at the first result.

@param string[]|null[] $references The references.
@param int             $flags      A bitwise combination of the flag
constants in this class.

@return string[]|null[] The references with all links replaced by their
target references. If any link pointed to more
than one target reference, the returned array
is larger than the passed array (unless the
argument `$stopOnFirst` was set to `true`).
Follows any link in a list of references .