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

        foreach ($references as $reference) {
            // Filter out null values
            // Links should be followed before calling this method
            if (null === $reference) {
                continue;
            }

            $nestedReference = rtrim($reference, '/').'/'.$nestedPath;

            if (file_exists($nestedReference)) {
                $result[] = $nestedReference;

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

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

        foreach ($references as $reference) {
            // Filter out null values
            // Links should be followed before calling this method
            if (null === $reference) {
                continue;
            }

            $nestedReference = rtrim($reference, '/').'/'.$nestedPath;

            if (file_exists($nestedReference)) {
                $result[] = $nestedReference;

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

        return $result;
    }
private function appendPathAndFilterExisting ( array $ references , $ nestedPath , $ flags = 0 ) { $ result = array ( ) ; foreach ( $ references as $ reference ) { // Filter out null values // Links should be followed before calling this method if ( null === $ reference ) { continue ; } $ nestedReference = rtrim ( $ reference , '/' ) . '/' . $ nestedPath ; if ( file_exists ( $ nestedReference ) ) { $ result [ ] = $ nestedReference ; if ( $ flags & self :: STOP_ON_FIRST ) { return $ result ; } } } return $ result ; }
Appends nested paths to references and filters out the existing ones.

This method takes all the given references, appends the nested path to
each of them and then filters out the results that actually exist on the
filesystem.

Null references are filtered out.

Link references should be followed with {@link followLinks()} before
calling this method.

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

@param string[]|null[] $references The references.
@param string          $nestedPath The nested path to append without
leading slash ("/").
@param int             $flags      A bitwise combination of the flag
constants in this class.

@return string[] The references with the nested path appended. Each
reference is guaranteed to exist on the filesystem.
Appends nested paths to references and filters out the existing ones .