function Compiler::addFile
1 call to Compiler::addFile()
- Compiler::compile in vendor/
composer/ composer/ src/ Composer/ Compiler.php - Compiles composer into a single phar file
File
-
vendor/
composer/ composer/ src/ Composer/ Compiler.php, line 214
Class
- Compiler
- The Compiler class compiles composer into a phar
Namespace
ComposerCode
private function addFile(\Phar $phar, \SplFileInfo $file, bool $strip = true) : void {
$path = $this->getRelativeFilePath($file);
$content = file_get_contents((string) $file);
if ($strip) {
$content = $this->stripWhitespace($content);
}
elseif ('LICENSE' === $file->getFilename()) {
$content = "\n" . $content . "\n";
}
if ($path === 'src/Composer/Composer.php') {
$content = strtr($content, [
'@package_version@' => $this->version,
'@package_branch_alias_version@' => $this->branchAliasVersion,
'@release_date@' => $this->versionDate
->format('Y-m-d H:i:s'),
]);
$content = Preg::replace('{SOURCE_VERSION = \'[^\']+\';}', 'SOURCE_VERSION = \'\';', $content);
}
$phar->addFromString($path, $content);
}