absoluteRelativePath(''), '/')); $rootDocPath = rtrim(str_replace($environment->getDirName(), '', $currentFilePath), '/'); if ($globPattern[0] === '/') { $globPatternPath = $rootDocPath . $globPattern; } else { $globPatternPath = $currentFilePath . '/' . $globPattern; } $pos = strrpos($globPatternPath, '/'); $globPatternFile = $pos === false ? $globPatternPath : substr($globPatternPath, $pos + 1); $globPatternPath = $pos === false ? '' : substr($globPatternPath, 0, $pos); $allFiles = []; $finder = new Finder(); $finder->in($globPatternPath) ->name($globPatternFile . '.rst') ->files(); foreach ($finder as $file) { if ($file->isDir()) { // remove the root directory so it is a relative path from the root $relativePath = str_replace($rootDocPath, '', (string) $file->getRealPath()); // recursively search in this directory $dirFiles = $this->globSearch($environment, $relativePath . '/*'); $allFiles = array_merge($allFiles, $dirFiles); } else { // Trim the root path and the .rst extension. This is what the // RST parser requires to add a dependency. $file = str_replace([$rootDocPath, '.rst'], '', (string) $file->getRealPath()); $allFiles[] = $file; } } return $allFiles; } }