function SelfUpdateCommand::validatePhar
Validates the downloaded/backup phar file
Parameters
string $pharFile The downloaded or backup phar:
null|string $error Set by method on failure:
Code taken from getcomposer.org/installer. Any changes should be made there and replicated here
Return value
bool If the operation succeeded
Throws
\Exception
1 call to SelfUpdateCommand::validatePhar()
- SelfUpdateCommand::setLocalPhar in vendor/
composer/ composer/ src/ Composer/ Command/ SelfUpdateCommand.php - Checks if the downloaded/rollback phar is valid then moves it
File
-
vendor/
composer/ composer/ src/ Composer/ Command/ SelfUpdateCommand.php, line 549
Class
- SelfUpdateCommand
- @author Igor Wiedler <igor@wiedler.ch> @author Kevin Ran <kran@adobe.com> @author Jordi Boggiano <j.boggiano@seld.be>
Namespace
Composer\CommandCode
protected function validatePhar(string $pharFile, ?string &$error) : bool {
if ((bool) ini_get('phar.readonly')) {
return true;
}
try {
// Test the phar validity
$phar = new \Phar($pharFile);
// Free the variable to unlock the file
unset($phar);
$result = true;
} catch (\Exception $e) {
if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
throw $e;
}
$error = $e->getMessage();
$result = false;
}
return $result;
}