@param string $dir

@return SplFileInfo[]|\Iterator
9347
public function getFilesOfDir($dir)
    {
        $iterator = new DirectoryIterator($dir);

        $iterator = new CallbackFilterIterator(
            $iterator,
            function (SplFileInfo $current, $key, DirectoryIterator $iterator) {
                return !$iterator->isDot();
            }
        );

        return $iterator;
    }
311597
public function chdir($dir) {
		$this->connectIfNeeded();
		$this->handle->chdir($dir);
		$this->onFolderChanged(new Event(['sender' => $this, 'data' => $dir]));
		try {
			$cwd = $this->pwd();
		} catch (FtpException $ex) {
			$cwd = $dir;	
		}
		return $cwd;
	}
654019
private function getSuluVersion($dir)
    {
        $version = '_._._';

        /** @var SplFileInfo $composerFile */
        $composerFile = new SplFileInfo($dir . '/composer.lock', '', '');
        if (!$composerFile->isFile()) {
            return $version;
        }

        $composer = json_decode($composerFile->getContents(), true);
        foreach ($composer['packages'] as $package) {
            if ('sulu/sulu' === $package['name']) {
                return $package['version'];
            }
        }

        return $version;
    }
435221
public function files($dir)
    {
        $dir = $this->alias->resolve($dir);

        $files = [];
        foreach ($this->glob($dir . (strpos($dir, '*') === false ? '/*' : ''), SCANDIR_SORT_ASCENDING) as $item) {
            if (is_file($item)) {
                $files[] = $item;
            }
        }

        return $files;
    }
1227595
protected function scanDir($dir)
    {
        $fileinfos = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir));
        $files     = [];
        foreach ($fileinfos as $pathname => $fileinfo) {
            if (!$fileinfo->isFile()) {
                continue;
            }

            $files[] = $pathname;
        }

        return $this->scanArray($files);
    }
293335
private static function get_file_list($directory) {
        global $CFG;
        $directoryroot = $CFG->dirroot;
        $finaleventfiles = array();
        if (is_dir($directory)) {
            if ($handle = opendir($directory)) {
                $eventfiles = scandir($directory);
                foreach ($eventfiles as $file) {
                    if ($file != '.' && $file != '..') {
                        // Ignore the file if it is external to the system.
                        if (strrpos($directory, $directoryroot) !== false) {
                            $location = substr($directory, strlen($directoryroot));
                            $eventname = substr($file, 0, -4);
                            $finaleventfiles[$eventname] = $location  . '/' . $file;
                        }
                    }
                }
            }
        }
        return $finaleventfiles;
    }
393401
public static function emptyContents($dir) {
        $iterator = new \FilesystemIterator($dir, \FilesystemIterator::SKIP_DOTS);
        if (!$iterator->valid()) {
            return;
        }
        foreach($iterator as $fileinfo) {
            if ($fileinfo->isDir()) {
                self::deleteFolder($fileinfo->getPathname());
            }
            else {
                unlink($fileinfo->getPathname());
            }
        }
    }
1101805
protected function doChangeDir($dir)
    {
        $connection = $this->connection;

        return $this->retry(function () use ($connection, $dir) {
            $res = @ftp_chdir($connection, $dir);

            if (false === $res) {
                throw new \RuntimeException("Changing directory failed: ".$dir);
            }
        });
    }
571588
public function getHTMLFiles($directory)
    {
        try {
            $dir = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS | RecursiveDirectoryIterator::NEW_CURRENT_AND_KEY);
            $files = new \RecursiveIteratorIterator($dir);

            $allowedExtensions = ['htm', 'html'];

            $list = [];
            foreach ($files as $file) {
                if (in_array($file->getExtension(), $allowedExtensions)) {
                    // HTML File found
                    $relativePath = str_replace($directory, '', $file->getPathname());
                    $list[] = ltrim($relativePath, '\\/');
                }
            }

            return $list;
        } catch (\Exception $e) {
            return [];
        }
    }
224102
protected static function readdir($dir)
    {
        $entries = array();
        foreach (scandir($dir) as $entry) {
            if(($entry != '.') && ($entry != '..')){
                $current = "$dir/$entry";
                if($current != $dir){
                    if(is_dir($current)){
                        $aux = self::readdir($current);
                        $entries = array_merge($entries, $aux);
                    }else{
                        if(preg_match("/\w*?Controller.php/", $entry)){
                            $entries[] = $current;
                        }
                    }
                }
            }
        }

        return $entries;
    }
664508
public static function register_js_var_files( $dir ) {
		if ( ! is_dir( $dir ) ) {
			return [];
		}
		$finder = new Finder();
		$registered = [];
		foreach ( $finder->in( $dir )->name( '*.php' )->files() as $file ) {
			$path = $file->getPathname();
			$file_name = basename( $path );
			if ( preg_match( '#^[_.]#u', $file_name ) ) {
				continue;
			}
			$handle   = str_replace( '.php', '', $file_name );
			$var_name = self::camelize( $handle );
			$vars     = include $path;
			if ( ! is_array( $vars ) ) {
				continue;
			}
			$vars = apply_filters( 'wp_enqueue_manager_vars', $vars, $handle );
			wp_localize_script( $handle, $var_name, $vars );
			$registered[ $handle ] = [
				'name' => $var_name,
				'vars' => $vars,
			];
		}
		return $registered;
	}
823473
public function findAll($directory): array
    {
        $cache = $this->cacheService->systemSimple();
        $key = \str_replace(['::', '\\'], '_', __METHOD__) . '_' . \crc32($directory);
        $result = $cache->get($key);
        if (!$result) {
            $result = $this->classHelper->getClassMap($directory, self::FILENAME);
            $cache->set($key, $result);
        }
        return $result;
    }
409955
public function clearDirectory($dir)
    {
        if (empty($dir) || !@is_dir($dir)) {
            return false;
        }

        $iterator = new \RecursiveDirectoryIterator($dir);
        $filter = new \RecursiveCallbackFilterIterator($iterator, function ($current) {
            /** @var \SplFileInfo $current */
            $filename = $current->getBasename();
            // Check for files and dirs starting with "dot" (.gitignore, etc)
            return !($filename && $filename[0] === '.');
        });

        /** @var \SplFileInfo[] $listing */
        $listing = new \RecursiveIteratorIterator($filter, \RecursiveIteratorIterator::CHILD_FIRST);
        foreach ($listing as $item) {
            $path = $item->getPathname();
            $item->isDir() ? rmdir($path) : unlink($path);
        }
        return true;
    }
523005
protected function getMessages($dir)
    {
        $file = sprintf("%smessages/%s.php", $dir, $this->lang);
        if (file_exists($file)) {
            return include $file;
        }

        return [];
    }
1016180
protected function scanDir(string $dir): ScanResult
    {
        $fileInfo = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir));
        $files = [];
        foreach ($fileInfo as $pathname => $item) {
            if (!$item->isFile()) {
                continue;
            }

            $files[] = $pathname;
        }

        return $this->scanArray($files);
    }
147424
protected function getRecursiveDirectoryIterator($dir)
    {
        return new \RecursiveIteratorIterator(
                new \RecursiveDirectoryIterator($dir, \FilesystemIterator::CURRENT_AS_FILEINFO),
                \RecursiveIteratorIterator::SELF_FIRST,
                \RecursiveIteratorIterator::CATCH_GET_CHILD
                );
    }
306183
public static function getFilesRecursivelyWithSpecifiedExtension($dir, $extension)
    {
        $directory = new RecursiveDirectoryIterator($dir);
        $iterator = new RecursiveIteratorIterator($directory);
        $filter = new RegexIterator($iterator, "/\.$extension$/i", RecursiveRegexIterator::GET_MATCH);
        return array_keys(iterator_to_array($filter));
    }