private function removeDirectory(string $path): bool
    {
        $iterator = new DirectoryIterator($path);
        foreach ($iterator as $fileInfo) {
            if ($fileInfo->isDot() || !$fileInfo->isDir()) {
                continue;
            }
            $dirName = $fileInfo->getPathname();
            $this->removeDirectory($dirName);
        }

        $files = new FilesystemIterator($path);

        /** @var SplFileInfo $file */
        foreach ($files as $file) {
            $fileName = $file->getPathname();
            unlink($fileName);
        }

        return rmdir($path);
    }
private function removeDirectory(string $path): bool
    {
        $iterator = new DirectoryIterator($path);
        foreach ($iterator as $fileInfo) {
            if ($fileInfo->isDot() || !$fileInfo->isDir()) {
                continue;
            }
            $dirName = $fileInfo->getPathname();
            $this->removeDirectory($dirName);
        }

        $files = new FilesystemIterator($path);

        /** @var SplFileInfo $file */
        foreach ($files as $file) {
            $fileName = $file->getPathname();
            unlink($fileName);
        }

        return rmdir($path);
    }
private function removeDirectory ( string $ path ) : bool { $ iterator = new DirectoryIterator ( $ path ) ; foreach ( $ iterator as $ fileInfo ) { if ( $ fileInfo -> isDot ( ) || ! $ fileInfo -> isDir ( ) ) { continue ; } $ dirName = $ fileInfo -> getPathname ( ) ; $ this -> removeDirectory ( $ dirName ) ; } $ files = new FilesystemIterator ( $ path ) ; /** @var SplFileInfo $file */ foreach ( $ files as $ file ) { $ fileName = $ file -> getPathname ( ) ; unlink ( $ fileName ) ; } return rmdir ( $ path ) ; }
Remove directory recursively.
This function is compatible with vfsStream.

@param string $path Path

@return bool true on success or false on failure
Remove directory recursively . This function is compatible with vfsStream .