private function packFile(\Phar $phar, \SplFileInfo $file): void
    {
        // skip error
        if (!\file_exists($file)) {
            $this->reportError("File $file is not exists!");
            return;
        }

        $this->counter++;
        $path = $this->getRelativeFilePath($file);
        $strip = $this->stripComments;
        $content = \file_get_contents($file);

        // clear php file comments
        if ($strip && \strpos($path, '.php')) {
            $filter = $this->stripFilter;

            if (!$filter || ($filter && $filter($file))) {
                $content = $this->stripWhitespace($content);
            }
        }

        // have versionFile
        if ($path === $this->versionFile) {
            $content = \str_replace([
                '{@package_version}',
                '{@package_branch_alias_version}',
                '{@release_date}',
            ], [
                $this->version,
                $this->branchAliasVersion,
                $this->versionDate->format('Y-m-d H:i:s')
            ], $content);
        }

        if ($cb = $this->events['add']) {
            $cb($path, $this->counter);
        }

        $phar->addFromString($path, $content);
    }
private function packFile(\Phar $phar, \SplFileInfo $file): void
    {
        // skip error
        if (!\file_exists($file)) {
            $this->reportError("File $file is not exists!");
            return;
        }

        $this->counter++;
        $path = $this->getRelativeFilePath($file);
        $strip = $this->stripComments;
        $content = \file_get_contents($file);

        // clear php file comments
        if ($strip && \strpos($path, '.php')) {
            $filter = $this->stripFilter;

            if (!$filter || ($filter && $filter($file))) {
                $content = $this->stripWhitespace($content);
            }
        }

        // have versionFile
        if ($path === $this->versionFile) {
            $content = \str_replace([
                '{@package_version}',
                '{@package_branch_alias_version}',
                '{@release_date}',
            ], [
                $this->version,
                $this->branchAliasVersion,
                $this->versionDate->format('Y-m-d H:i:s')
            ], $content);
        }

        if ($cb = $this->events['add']) {
            $cb($path, $this->counter);
        }

        $phar->addFromString($path, $content);
    }
private function packFile ( \ Phar $ phar , \ SplFileInfo $ file ) : void { // skip error if ( ! \ file_exists ( $ file ) ) { $ this -> reportError ( "File $file is not exists!" ) ; return ; } $ this -> counter ++ ; $ path = $ this -> getRelativeFilePath ( $ file ) ; $ strip = $ this -> stripComments ; $ content = \ file_get_contents ( $ file ) ; // clear php file comments if ( $ strip && \ strpos ( $ path , '.php' ) ) { $ filter = $ this -> stripFilter ; if ( ! $ filter || ( $ filter && $ filter ( $ file ) ) ) { $ content = $ this -> stripWhitespace ( $ content ) ; } } // have versionFile if ( $ path === $ this -> versionFile ) { $ content = \ str_replace ( [ '{@package_version}' , '{@package_branch_alias_version}' , '{@release_date}' , ] , [ $ this -> version , $ this -> branchAliasVersion , $ this -> versionDate -> format ( 'Y-m-d H:i:s' ) ] , $ content ) ; } if ( $ cb = $ this -> events [ 'add' ] ) { $ cb ( $ path , $ this -> counter ) ; } $ phar -> addFromString ( $ path , $ content ) ; }
Add a file to the Phar.
@param \Phar        $phar
@param \SplFileInfo $file
Add a file to the Phar .