Return list of all files in directory for php 7.2.0 and higher.

@param  string $path
@return \SebastianFeldmann\Ftp\File[]
@throws \Exception
349834
private function ls72(string $path) : array
    {
        $list = [];
        foreach ($this->mlsd($path) as $fileInfo) {
            $list[] = new File($fileInfo);
        }
        return $list;
    }
91131
public static function findDirs(string $path): array
    {
        $result = [];

        try {
            static::validatePath($path);
            $path = new DirectoryIterator($path);
        } catch (InvalidArgumentException $e) {
            return $result;
        } catch (UnexpectedValueException $e) {
            return $result;
        }

        foreach ($path as $dir) {
            if ($dir->isDot()) {
                continue;
            }
            if (!$dir->isDir()) {
                continue;
            }
            $result[] = $dir->getFilename();
        }
        asort($result);

        return $result;
    }
98105
public function findPhp($path)
    {
        $allFiles = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
        $phpFiles = new RegexIterator($allFiles, '/\.php$/');
        $files = array();
        foreach ($phpFiles as $phpFile) {
            $filename = $phpFile->getRealpath();
            $content = file_get_contents($filename);
            $files[] = new File($filename, $content);
        }

        return $files;
    }
478872
public function parsePhpFiles($path)
    {
        $files = $this->finderFactory->createFinder()->in($path);
        $parsedFiles = array();
        $parserErrors = array();

        $this->progressOutput->start($fileCount = $files->count());

        $i = 0;
        foreach ($files->getIterator() as $file) {
            $file = PhpFileInfo::create($file);

            try {
                $this->progressOutput->advance(++$i, $file);
                $this->parser->parseFile($file);
            } catch (Error $ex) {
                $raw = $ex->getRawMessage().' in file '.$file;
                $ex->setRawMessage($raw);
                $parserErrors[] = $ex;
            }

            $parsedFiles[] = $file;
        }

        $this->progressOutput->end();

        return new Result($parsedFiles, $parserErrors, $fileCount);
    }
992839
protected function getImageFiles($path)
    {
        $finder = Finder::create()->in($path)->sortByType()->depth(0);
        foreach (config('media.images_ext') as $file) {
            $finder->name('*' . $file);
        }

        return $finder;
    }
622218
private function lsLegacy(string $path) : array
    {
        $list = [];
        foreach ($this->nlist($path) as $name) {
            $type   = $this->isDir($name) ? 'dir' : 'file';
            $size   = $this->size($name);
            $mtime  = $this->mdtm($name);

            if ($mtime == -1) {
                throw new RuntimeException('FTP server doesnt support \'ftp_mdtm\'');
            }

            $list[] = new File(['name' => $name, 'modify' => $mtime, 'type' => $type, 'size' => $size]);
        }
        return $list;
    }
556796
public function get($path)
    {
        $data = explode(':', $path, 2);
        $file = $this->filePath($data[0]);

        if (!$file)
        {
            throw new Exceptions\PermissionDenied($data[0]);
        }

        $slice = $this->slice($file);

        if (!empty($data[1]))
        {
            return $slice->getData($data[1]);
        }

        return $slice;
    }
378908
protected static function getFilesFromPath($path)
    {
        $files = [];
        $path = rtrim($path, '/') . DIRECTORY_SEPARATOR;

        if (false !== $items = scandir($path)) {
            foreach ($items as $item) {
                $file = $path . $item;
                if (is_file($file)) {
                    $extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
                    if (in_array($extension, [Packager::FILE_EXTENSION, Package::FILE_EXTENSION])) {
                        $files[] = $file;
                    }
                }
            }
        }

        return $files;
    }
647592
public static function GetDirContent($path)
    {
        $files = array();
        $directory = opendir($path);

        while(($file = readdir($directory)) !== false)
        {
            $full_path = $path . "/" . $file;

            if(is_file($full_path))
            {
                $files[] = $full_path;
            }
            elseif($file != "." && $file != ".." && is_dir($full_path))
            {
                $files[] = $full_path;
                $files = array_merge($files, self::GetDirContent($full_path));
            }
        }

        closedir($directory);

        return $files;
    }
937109
public function getClassesByPath($path)
    {
        $allClasses = [];
        foreach ($this->findAllClasses([$this->rootPath."/$path"], 'php') as $class){
            $allClasses[] = trim($class,"0\\");
        }

        return $allClasses;
    }
1187341
protected function _scandir($path) {
		$files = array();

 		foreach (ftp_rawlist($this->connect, $path) as $str) {
 			if (($stat = $this->parseRaw($str))) {
 				$files[] = $path.DIRECTORY_SEPARATOR.$stat['name'];
 			}
 		}

 		return $files;
	}
140774
private function get_plugin_files( $path ) {
		$folder = dirname( $this->get_absolute_path( $path ) );

		// Return single file plugins immediately, to avoid iterating over the
		// entire plugins folder.
		if ( WP_PLUGIN_DIR === $folder ) {
			return (array) $path;
		}

		return $this->get_files( trailingslashit( $folder ) );
	}
242707
public function ls(string $path): array
    {
        $files = [];
        $d = dir($path);
        while (false !== ($entry = $d->read())) {
            if (in_array($entry, ['.', '..'], true)) {
                continue;
            }
            $entryPath = $path . $entry;
            if (is_dir($entryPath)) {
                foreach ($this->ls($entryPath . DIRECTORY_SEPARATOR) as $entryPath) {
                    $files[] = $entryPath;
                }
                continue;
            }
            if (!is_file($entryPath)) {
                continue;
            }
            $files[] = $entryPath;
        }
        $d->close();

        return $files;
    }
740244
private function getFiles($path)
    {
        if (is_file($path)) {
            return [new SplFileInfo($path, '', '')];
        }

        return $this->finder->name('*.php')->in(realpath($path));
    }
470826
public function ls(string $path = '') : array
    {
        return version_compare(PHP_VERSION, '7.2.0', '>=')
            ? $this->ls72($path)
            : $this->lsLegacy($path);

    }
1278746
public function getMappingFiles($path)
    {
        $files = $this->files->glob($path.'/*_*.php');

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

        $files = array_map(function ($file) {
            return str_replace('.php', '', basename($file));
        }, $files);

        return $files;
    }
648395
protected function getConfigurationFiles($path)
    {
        $files = [];

        foreach (Finder::create()->files()->name('*.php')->in($path) as $file) {
            $directory = $this->getNestedDirectory($file, $path);
            $files[$directory.basename($file->getRealPath(), '.php')] = $file->getRealPath();
        }

        ksort($files, SORT_NATURAL);

        return $files;
    }