Find Phakefile parts

Find all Phakefiles in a given folder

@param  string $folder Folder path
@return array List of found files
508105
public static function findPhakefileParts($folder)
    {
        $result = array();

        $dir = new DirectoryIterator($folder);
        $regex = new RegexIterator($dir, '/\.php$/');
        foreach ($regex as $item) {
            $result[] = $item->getRealpath();
        }

        return $result;
    }
751744
public function find_all_files($dir) 
	{
		$root = scandir($dir);
		if(count($root) == 0) return;

		foreach($root as $value)
		{
			if($value === '.' || $value === '..')
			{
				continue;
			}
			if(is_file("$dir/$value"))
			{
				$result[] = "$dir/$value";
				$this->pages[] = $this->read( "$dir/$value", $value );
				continue;
			}
			foreach($this->find_all_files("$dir/$value") as $value)
			{
				$result[] = $value;
			}
		}
		return $result; 
	}
1029039
protected function getFolderIterator($component_folder) {
    $iterator = new \RecursiveDirectoryIterator($component_folder);
    $filter = new ComponentFolderRecursiveFilterIterator($iterator);
    $all_files  = new \RecursiveIteratorIterator($filter, \RecursiveIteratorIterator::SELF_FIRST);

    return $all_files;
  }
1291667
protected function findFiles()
    {
        // Add php files.
        $finder = new Finder();
        $finder
            ->files()
            // Ignore version control system folder.
            ->ignoreVCS(true)
            // Do not add tests folders.
            ->exclude('Tests')
            ->exclude('tests')
            // Do not add composer backup folder.
            ->exclude('composer.bak');

        if (!empty($this->excludeFiles)) {
            foreach ($this->excludeFiles as $file) {
                $finder->notPath($file);
            }
        }

        return $finder;
    }
43570
protected function search_folders( $path ) {
		$return       = array();
		$base_folders = array_filter( glob( $this->trailingslashit( $path ) . '*' ), 'is_dir' );

		if ( is_array( $base_folders ) && ! empty( $base_folders ) ) {
			foreach ( $base_folders as $folder ) {
				$_sub = $this->search_folders( $this->untrailingslashit( $folder ) );

				if ( is_array( $_sub ) && ! empty( $_sub ) ) {
					$return = array_merge( $return, $_sub );
				} elseif ( is_string( $_sub ) ) {
					$return = array_merge( $return, array( $_sub ) );
					$return = array_merge( $return, array( $this->untrailingslashit( $path ) ) );
				}
			}
		} else {
			$return = array( $this->trailingslashit( $path ) );
		}

		return $return;
	}
512580
private function findStatusByFolder(ExtendedFolderInterface $folder)
    {
        $qb = $this->folderUsageRepository->createQueryBuilder('u');
        $qb
            ->select('u.status')
            ->join('u.folder', 'f')
            ->where($qb->expr()->eq('f.id', $qb->expr()->literal($folder->getId())));

        return array_column($qb->getQuery()->getScalarResult(), 'status');
    }
886298
public function analyze_folder(string $folder = '.', bool $deep = false): array
  {
    $res = [];
		if (  \is_dir($folder) ){

      $files = $deep ? bbn\file\dir::scan($folder, 'file') : bbn\file\dir::get_files($folder);
		  foreach ( $files as $f ){

        $words = $this->analyze_file($f);
        foreach ( $words as $word ){
          if ( !isset($res[$word]) ){
            $res[$word] = [];
          }
          if ( !in_array($f, $res[$word]) ){
            $res[$word][] = $f;
          }
        }
      }
    }
    return $res;
  }
924794
protected function breadcrumbs($folder)
    {
        $folder = trim($folder, '/');
        $folders = collect(explode('/', $folder));
        $path = '';

        return $folders->reduce(function ($crumbs, $folder) use (&$path) {
            $path .= '/'.$folder;
            $crumbs[$path] = $folder;

            return $crumbs;
        }, collect())->prepend($this->breadcrumbRootLabel, '/');
    }
25407
public function folder_data($folder)
    {
        if (!strlen($folder)) {
            $folder = $this->folder !== null ? $this->folder : 'INBOX';
        }

        if ($this->conn->selected != $folder) {
            if (!$this->check_connection()) {
                return array();
            }

            if ($this->conn->select($folder)) {
                $this->folder = $folder;
            }
            else {
                return null;
            }
        }

        $data = $this->conn->data;

        // add (E)SEARCH result for ALL UNDELETED query
        if (!empty($this->icache['undeleted_idx'])
            && $this->icache['undeleted_idx']->get_parameters('MAILBOX') == $folder
        ) {
            $data['UNDELETED'] = $this->icache['undeleted_idx'];
        }

        return $data;
    }
966899
public static function getFiles($folder, $excludeFolders = self::INCLUDE_FOLDERS)
    {
        $files = [];

        if (false === is_dir($folder)) {
            return [];
        }

        $handle = opendir($folder);
        while (false !== ($entry = readdir($handle))) {
            if (true === in_array($entry, self::getDirSymbols())) {
                continue;
            }

            if (self::EXCLUDE_FOLDERS === $excludeFolders && true === is_dir(sprintf('%s/%s', $folder, $entry))) {
                continue;
            }

            $files[] = $entry;
        }

        closedir($handle);

        return $files;
    }
489231
public function folder(Folder $folder = null)
    {
        if (is_null($folder)) {
            return $this->folder;
        }

        $this->folder = $folder;

        return $this;
    }
352620
private function findFeatureFiles($path)
    {
        $absolutePath = $this->findAbsolutePath($path);

        if (!$absolutePath) {
            return array($path);
        }

        if (is_file($absolutePath)) {
            return array($absolutePath);
        }

        $iterator = new RegexIterator(
            new RecursiveIteratorIterator(
                new RecursiveDirectoryIterator(
                    $absolutePath,
                    RecursiveDirectoryIterator::FOLLOW_SYMLINKS | RecursiveDirectoryIterator::SKIP_DOTS
                )
            ),
            '/^.+\.feature$/i',
            RegexIterator::MATCH
        );

        $paths = array_map('strval', iterator_to_array($iterator));
        uasort($paths, 'strnatcasecmp');

        return $paths;
    }
156500
public function locateFileInFolder($filename, array $folders)
    {
        $list = [];
        foreach ($folders as $folder) {
            $list += $this->detectInFolder($folder, $filename);
        }
        return $list;
    }
549866
private function getFolderContent($dir)
    {
        $finder = Finder::create()
            ->ignoreVCS(false)
            ->ignoreDotFiles(false)
            ->depth(0)
            ->in($dir);

        return iterator_to_array($finder);
    }
1112414
private function filterOutFolderMask(string $folder): string
    {
        $mask = '**';

        $folder = str_replace($mask . DIRECTORY_SEPARATOR, '', $folder);
        $folder = str_replace($mask, '', $folder);

        return $folder;
    }
145732
public function getFileList()
    {
        $allfiles = [];

        foreach ($this->filesets as $fs) {
            $ds = $fs->getDirectoryScanner($this->project);

            $files = $ds->getIncludedFiles();

            // We need to store these files keyed by the basedir from DirectoryScanner
            // so that we can resolve the fullpath of the file later.
            if (isset($allfiles[$ds->getBasedir()])) {
                $allfiles[$ds->getBasedir()] = array_merge($allfiles[$ds->getBasedir()], $files);
            } else {
                $allfiles[$ds->getBasedir()] = $files;
            }
        }

        $struc = [];

        foreach ($allfiles as $basedir => $files) {
            foreach ($files as $file) {
                // paths are relative to $basedir above
                $path = strtr(dirname($file), DIRECTORY_SEPARATOR, '/');

                if (!$path || $path == '.') {
                    $path = '/'; // for array index
                }

                $parts = explode('.', basename($file));
                $ext = array_pop($parts);
                if (strlen($ext) == strlen($file)) {
                    $ext = '';
                }

                $f = new PhingFile($basedir, $file);

                $struc[$path][] = [
                    'file' => basename($file),
                    'ext' => $ext,
                    'path' => (($path == '/') ? basename($file) : $path . '/' . basename($file)),
                    'fullpath' => $f->getAbsolutePath()
                ];
            }
        }

        uksort($struc, 'strnatcasecmp');
        foreach ($struc as $key => $ind) {
            usort($ind, [$this, 'sortfiles']);
            $struc[$key] = $ind;
        }

        $tempstruc = $struc;
        $struc = ['/' => $tempstruc['/']];
        $bv = 0;
        foreach ($tempstruc as $key => $ind) {
            $save = $key;
            if ($key != '/') {
                $struc['/'] = $this->setupDirs($struc['/'], explode('/', $key), $tempstruc[$key]);
            }
        }
        uksort($struc['/'], [$this, 'mystrucsort']);

        return $struc;
    }
481208
private function getPhpFilesFromPath(string $path)
    {
        $directoryIterator = new RecursiveDirectoryIterator($path);
        foreach (new RecursiveIteratorIterator($directoryIterator) as $file) {
            if (! in_array($file->getExtension(), $this->fileExtensions)) {
                continue;
            }

            if ($this->fileShouldBeIgnored($file)) {
                continue;
            }

            $this->files->push(new File(['displayPath' => $file->getPathName(), 'fullPath' => $file->getRealPath()]));
        }
    }