public static function walkDir(string $path, callable $callback): void
    {
        $realPath = realpath($path);
        if (!is_string($realPath) || !is_dir($realPath)) {
            throw new InvalidArgumentException(sprintf(
                "Passed path \"%s\" (%s) isn't a directory",
                $path,
                var_export($realPath, true)
            ));
        }
        $dir = new RecursiveDirectoryIterator(
            $realPath,
            RecursiveDirectoryIterator::SKIP_DOTS
        );
        $files = iterator_to_array(new RecursiveIteratorIterator(
            $dir,
            RecursiveIteratorIterator::CHILD_FIRST
        ));
        array_walk($files, $callback, ["path" => $path]);
    }
public static function walkDir(string $path, callable $callback): void
    {
        $realPath = realpath($path);
        if (!is_string($realPath) || !is_dir($realPath)) {
            throw new InvalidArgumentException(sprintf(
                "Passed path \"%s\" (%s) isn't a directory",
                $path,
                var_export($realPath, true)
            ));
        }
        $dir = new RecursiveDirectoryIterator(
            $realPath,
            RecursiveDirectoryIterator::SKIP_DOTS
        );
        $files = iterator_to_array(new RecursiveIteratorIterator(
            $dir,
            RecursiveIteratorIterator::CHILD_FIRST
        ));
        array_walk($files, $callback, ["path" => $path]);
    }
public static function walkDir ( string $ path , callable $ callback ) : void { $ realPath = realpath ( $ path ) ; if ( ! is_string ( $ realPath ) || ! is_dir ( $ realPath ) ) { throw new InvalidArgumentException ( sprintf ( "Passed path \"%s\" (%s) isn't a directory" , $ path , var_export ( $ realPath , true ) ) ) ; } $ dir = new RecursiveDirectoryIterator ( $ realPath , RecursiveDirectoryIterator :: SKIP_DOTS ) ; $ files = iterator_to_array ( new RecursiveIteratorIterator ( $ dir , RecursiveIteratorIterator :: CHILD_FIRST ) ) ; array_walk ( $ files , $ callback , [ "path" => $ path ] ) ; }
Walks directory recursively.

```php
\donbidon\Lib\FileSystem\Tools::walkDir(
"/path/to/dir",
function (\SplFileInfo $file, $key, array $args): void
{
// $args["path"] contains passed "/path/to/dir" ($path)
echo sprintf(
"[%s] %s%s", $file->isDir() ? "DIR " : "file",
$file->getRealPath(),
PHP_EOL
);
}
);
```

@param string   $path
@param callback $callback

@return void

@throws InvalidArgumentException  If passed path isn't a directory.
Walks directory recursively .