pharext\Updater::updatePackage PHP Method

updatePackage() private method

Update an .ext.phar package to the current pharext version
private updatePackage ( SplFileInfo $file, Phar $phar = null ) : boolean
$file SplFileInfo
$phar Phar the parent phar containing $file as dependency
return boolean FALSE if the package is too old (pre-v3) to upgrade
    private function updatePackage(SplFileInfo $file, Phar $phar = null)
    {
        $this->info("Updating pharext core in '%s'...\n", basename($file));
        $temp = new Tempname("update", substr(strstr($file, ".ext.phar"), 4));
        if (!copy($file->getPathname(), $temp)) {
            throw new Exception();
        }
        if (!chmod($temp, $file->getPerms())) {
            throw new Exception();
        }
        if (!$this->replacePharext($temp)) {
            return false;
        }
        if ($phar) {
            $phar->addFile($temp, $file);
        } elseif (!rename($temp, $file->getPathname())) {
            throw new Exception();
        }
        return true;
    }