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;
    }
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;
    }
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 ; }
List all files in a directory and it's subdirectories.

@param  string $path
@return array
List all files in a directory and it s subdirectories .