Dump mapping to file

@param array  $map
@param string $fileName
12228
protected function write($map, $fileName)
    {
        $content = json_encode($map, JSON_PRETTY_PRINT);

        if (!file_exists($fileName)) {
            file_put_contents($fileName, $content);
            return;
        }

        $oldContent = file_get_contents($fileName);
        // prevent file lastModified time change
        if ($content !== $oldContent) {
            file_put_contents($fileName, $content);
        }
    }
659928
public static void saveMapping(final Writer out,
                                   final DSLMapping mapping) throws IOException {
        for (DSLMappingEntry dslMappingEntry : mapping.getEntries()) {
            out.write(dslMappingEntry.toString());
            out.write("\n");
        }
    }
977413
public static function map( $source, $destination, iterable $map ) {

    // sanity check
    if( !static::is( $source, false, true ) ) throw new \TypeError( 'The $source must be arraylike' );
    else if( !static::is( $destination, false, true ) ) throw new \TypeError( 'The $destination must be arraylike' );
    else {

      // iterate $map and fill the destination based on it
      foreach( $map as $key => $key_list ) {

        $value    = $source[ Number::is( $key ) ? $key_list : $key ] ?? null;
        $key_list = static::cast( $key_list, [ $key_list ] );
        foreach( $key_list as $_key ) {
          $destination[ $_key ] = $value;
        }
      }

      return $destination;
    }
  }
270248
public static void storeCache(Map<String, String> map, File file) {
        BufferedWriter bw = null;
        try {
            // Ensure that we the directory exists (maybe this should be done at
            // another place).
            file.getParentFile().mkdirs();
            bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));
            for (Entry<String, String> en : map.entrySet()) {
                bw.write(en.getValue());
                bw.write(' ');
                bw.write(en.getKey());
                bw.write('\n');
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            FileUtil.closeAndIgnoreExceptions(bw);
        }
    }
1071573
private function copyData(string $source, string $to, array $mapping)
    {
        $sourceColumns = array_keys($mapping);
        $targetColumns = array_values($mapping);

        //Preparing mapping
        $sourceColumns = array_map([$this, 'identify'], $sourceColumns);
        $targetColumns = array_map([$this, 'identify'], $targetColumns);

        $query = sprintf(
            'INSERT INTO %s (%s) SELECT %s FROM %s',
            $this->identify($to),
            implode(', ', $targetColumns),
            implode(', ', $sourceColumns),
            $this->identify($source)
        );

        $this->run($query);
    }
493184
private function copyMap($package_map, &$result = NULL)
	{
		$result   = (array) $result;
		$manager  = $this->composer->getRepositoryManager();
		$packages = $manager->getLocalRepository()->getPackages();

		foreach ($packages as $package) {
			$package_name = $package->getName();
			$package_root = rtrim($this->getInstallPath($package), '/\\' . DIRECTORY_SEPARATOR);

			if (!isset($package_map[$package_name])) {
				continue;
			}

			$this->io->write(sprintf(
				self::TAB . 'Copying files from %s',
				substr($package_root, strlen(getcwd()))
			));

			foreach ($package_map[$package_name] as $a => $b) {
				$a =  trim($a, '/\\' . DIRECTORY_SEPARATOR);
				$b = ltrim($b, '/\\' . DIRECTORY_SEPARATOR);
				$result = array_replace_recursive(
					$this->copy(
						$package_root . DIRECTORY_SEPARATOR . $a,
						getcwd() . DIRECTORY_SEPARATOR . $b,
						$package_name
					),
					$result
				);
			}
		}
	}
1003543
public function setDiscriminatorMap(array $map) : void
    {
        if ($this->isFile) {
            throw MappingException::discriminatorNotAllowedForGridFS($this->name);
        }

        $this->subClasses         = [];
        $this->discriminatorMap   = [];
        $this->discriminatorValue = null;

        foreach ($map as $value => $className) {
            $this->discriminatorMap[$value] = $className;
            if ($this->name === $className) {
                $this->discriminatorValue = $value;
            } else {
                if (! class_exists($className)) {
                    throw MappingException::invalidClassInDiscriminatorMap($className, $this->name);
                }
                if (is_subclass_of($className, $this->name)) {
                    $this->subClasses[] = $className;
                }
            }
        }
    }
220655
private static void putMapEntry( final Map<String, String[]> map, final String name, final String value )
    {
        String[] newValues = null;
        final String[] oldValues = map.get( name );
        if ( oldValues == null )
        {
            newValues = new String[1];
            newValues[0] = value;
        }
        else
        {
            newValues = new String[oldValues.length + 1];
            System.arraycopy( oldValues, 0, newValues, 0, oldValues.length );
            newValues[oldValues.length] = value;
        }
        map.put( name, newValues );
    }
1282958
public static void saveContentMap(Map<String, String> map, File file) throws IOException {

    FileWriter out = new FileWriter(file);
    for (String key : map.keySet()) {
      if (map.get(key) != null) {
        out.write(key.replace(":", "#escapedtwodots#") + ":"
            + map.get(key).replace(":", "#escapedtwodots#") + "\r\n");
      }
    }
    out.close();
  }
793192
protected function writeSource($filename, array $source)
    {
        $source = str_replace(['  ', "\n"], ["\t", "\n\t"], var_export($source, true));
        $source = <<<FILE
<?php
	return $source;
FILE;

        return @file_put_contents($filename, $source) != 0;
    }
975514
def dump(filename)
      File.open(filename,'w') do |f|
        YAML.dump(self.to_hash,f)
      end
    end
1336003
private function buildMap(&$fromDir, &$toDir, &$names, &$mapper, &$map)
    {
        $toCopy = null;
        if ($this->overwrite) {
            $v = [];
            foreach ($names as $name) {
                $result = $mapper->main($name);
                if ($result !== null) {
                    $v[] = $name;
                }
            }
            $toCopy = $v;
        } else {
            $ds = new SourceFileScanner($this);
            $toCopy = $ds->restrict($names, $fromDir, $toDir, $mapper);
        }

        for ($i = 0, $_i = count($toCopy); $i < $_i; $i++) {
            $src = new PhingFile($fromDir, $toCopy[$i]);
            $mapped = $mapper->main($toCopy[$i]);
            if (!$this->enableMultipleMappings) {
                $dest = new PhingFile($toDir, $mapped[0]);
                $map[$src->getAbsolutePath()] = $dest->getAbsolutePath();
            } else {
                $mappedFiles = [];

                foreach ($mapped as $mappedFile) {
                    if ($mappedFile === null) {
                        continue;
                    }
                    $dest = new PhingFile($toDir, $mappedFile);
                    $mappedFiles[] = $dest->getAbsolutePath();
                }
                $map[$src->getAbsolutePath()] = $mappedFiles;
            }
        }
    }
1076905
public static function writeSitemap( $links, $fileName = "sitemap.xml", $baseUrl = "" )
	{
		$xml	= XML_DOM_GoogleSitemapBuilder::buildSitemap( $links, $baseUrl );
		$file	= new FS_File_Writer( $fileName );
		return $file->writeString( $xml );
	}
301779
public function save($filename)
    {
        $this->setFilename($filename);

        call_user_func_array($this->getFunctionName(), [$this->getImage(), $filename]);

        return $filename;
    }
613524
function save(string $filename=null): bool
  {
    if (!empty($filename)) $this->filename = $filename;

    return ( file_put_contents($this->filename, json_encode($this->confValues,JSON_PRETTY_PRINT))!==false );
  }
90003
public static void writeStringMap(DataOutputStream os, Map<String,String> map) throws IOException {
		if(map==null) {
			os.writeInt(-1);
		} else {
			Set<Entry<String, String>> es = map.entrySet();
			os.writeInt(es.size());
			for(Entry<String,String> e : es) {
				writeString(os, e.getKey());
				writeString(os, e.getValue());
			}
		}

	}
172075
public static function map($array, $mapping) {
        $result = array();
        foreach($mapping as $src=>$dest) {
            if(array_key_exists($src, $array)) {
                $result[$dest] = $array[$src];
            }
        }
        return $result;
    }