original_string: public static function unlinkRecursive($dir, $deleteRootToo, \Closure $beforeUnlink = null)
      {
          if (!$dh = @opendir($dir)) {
              return;
          }
          while (false !== ($obj = readdir($dh))) {
              if ($obj == '.' || $obj == '..') {
                  continue;
              }
  
              $path = $dir . '/' . $obj;
              if ($beforeUnlink) {
                  $beforeUnlink($path);
              }
  
              if (!@unlink($path)) {
                  self::unlinkRecursive($path, true);
              }
          }
          closedir($dh);
          if ($deleteRootToo) {
              @rmdir($dir);
          }
          return;
      }
code: public static function unlinkRecursive($dir, $deleteRootToo, \Closure $beforeUnlink = null)
      {
          if (!$dh = @opendir($dir)) {
              return;
          }
          while (false !== ($obj = readdir($dh))) {
              if ($obj == '.' || $obj == '..') {
                  continue;
              }
  
              $path = $dir . '/' . $obj;
              if ($beforeUnlink) {
                  $beforeUnlink($path);
              }
  
              if (!@unlink($path)) {
                  self::unlinkRecursive($path, true);
              }
          }
          closedir($dh);
          if ($deleteRootToo) {
              @rmdir($dir);
          }
          return;
      }
code_tokens: public static function unlinkRecursive ( $ dir , $ deleteRootToo , \ Closure $ beforeUnlink = null ) { if ( ! $ dh = @ opendir ( $ dir ) ) { return ; } while ( false !== ( $ obj = readdir ( $ dh ) ) ) { if ( $ obj == '.' || $ obj == '..' ) { continue ; } $ path = $ dir . '/' . $ obj ; if ( $ beforeUnlink ) { $ beforeUnlink ( $ path ) ; } if ( ! @ unlink ( $ path ) ) { self :: unlinkRecursive ( $ path , true ) ; } } closedir ( $ dh ) ; if ( $ deleteRootToo ) { @ rmdir ( $ dir ) ; } return ; }
docstring: Recursively deletes a directory.
  
  @param string $dir Path of the directory to delete.
  @param boolean $deleteRootToo If true, `$dir` is deleted, otherwise just its contents.
  @param \Closure|false $beforeUnlink An optional closure to execute on a file path before unlinking.
  @api
docstring_tokens: Recursively deletes a directory .