protected function removeRecursiveDirectory(string $dirPath): bool
    {
        $itemList = array_diff(scandir($dirPath), ['.', '..']);
        
        foreach ($itemList as $itemName) {
            $itemPath = $dirPath.'/'.$itemName;
            
            if (is_dir($itemPath)) {
                $this->removeRecursiveDirectory($itemPath);
            } else {
                unlink($itemPath);
            }
        }
        
        return rmdir($dirPath);
    }
protected function removeRecursiveDirectory(string $dirPath): bool
    {
        $itemList = array_diff(scandir($dirPath), ['.', '..']);
        
        foreach ($itemList as $itemName) {
            $itemPath = $dirPath.'/'.$itemName;
            
            if (is_dir($itemPath)) {
                $this->removeRecursiveDirectory($itemPath);
            } else {
                unlink($itemPath);
            }
        }
        
        return rmdir($dirPath);
    }
protected function removeRecursiveDirectory ( string $ dirPath ) : bool { $ itemList = array_diff ( scandir ( $ dirPath ) , [ '.' , '..' ] ) ; foreach ( $ itemList as $ itemName ) { $ itemPath = $ dirPath . '/' . $ itemName ; if ( is_dir ( $ itemPath ) ) { $ this -> removeRecursiveDirectory ( $ itemPath ) ; } else { unlink ( $ itemPath ) ; } } return rmdir ( $ dirPath ) ; }
Remove folders recursively

@see http://php.net/manual/fr/function.rmdir.php#110489

@param string $dirPath Path to directory to remove

@return boolean
Remove folders recursively