public function writeAutoload( array $list ) {

    $file = Autoload::FILE;
    if( is_dir( dirname( $file ) ) || mkdir( dirname( $file ), 0777, true ) ) {

      //
      uksort( $list, function ( $a, $b ) {
        return strlen( $b ) - strlen( $a );
      } );

      //
      $content = [];
      foreach( $list as $namespace => $path ) {

        // detect if the path can be relative (then remove the root)
        $is_absolute = substr( $path, 0, strlen( $this->root ) ) != $this->root;
        if( !$is_absolute ) $path = substr( $path, strlen( $this->root ) );

        $count     = substr_count( $namespace, '\\' );
        $namespace = str_replace( [ '\\', "'" ], [ '\\\\', "\\'" ], $namespace );
        $path      = str_replace( [ '\\', "'" ], [ '\\\\', "\\'" ], $path );

        $prefix    = $is_absolute ? "'" : "__DIR__ . '/../";
        $content[] = "  '{$namespace}' => [ {$prefix}{$path}', {$count} ]";
      }

      // 
      file_put_contents( $file, "<?php return [\n" . implode( ",\n", $content ) . "\n];\n" );

      // invalidate opcache
      if( function_exists( 'opcache_invalidate' ) ) {
        opcache_invalidate( $file, true );
      }
    }
  }