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

Breadcrumb

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

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\Command

Code

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

API Navigation

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