public static function scan(string $dir, string $type = null, bool $hidden = false): array
   {
	   $all = [];
	   $dir = self::clean($dir);
	   $dirs = self::get_dirs($dir);
	   if ( \is_array($dirs) ){
	     if ( $type && (strpos($type, 'file') === 0) ){
	       $all = self::get_files($dir, false, $hidden);
	     }
	     else if ( $type && ((strpos($type, 'dir') === 0) || (strpos($type, 'fold') === 0)) ){
	       $all = $dirs;
	     }
	     else if ( $type ){
	       $all = array_filter(self::get_files($dir, false, $hidden), function($a)use($type){
	         $ext = bbn\str::file_ext($a);
	         return strtolower($ext) === strtolower($type);
	       });
	     }
	     else{
	       $files = self::get_files($dir, false, $hidden);
	       if ( \is_array($files) ){
	         $all = array_merge($dirs, $files);
	       }
	     }
	     foreach ( $dirs as $d ){
	       $all = array_merge(\is_array($all) ? $all : [], self::scan($d, $type, $hidden));
	     }
	   }
	   return $all;
	 }