Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Compiler.php

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

Composer

Code

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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal