From 8e4dffc0555e839fb33bfcdf8868ab473fe0cd27 Mon Sep 17 00:00:00 2001 From: Ralf Lang Date: Thu, 13 Oct 2022 14:10:27 +0200 Subject: [PATCH] Allow other CLIs (like satis in standalone mode) to re-brand composer. (#11118) This affects the banner at the head of the help screen and the version info. Symfony's base object offers the same signature but composer does not allow to override it in constructor. Yet there are public setter methods to change both after initializing the object. This is the workaround satis cli currently uses. --- src/Composer/Console/Application.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 2a080067e..663e5287e 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -84,10 +84,12 @@ class Application extends BaseApplication /** @var SignalHandler */ private $signalHandler; - public function __construct() + public function __construct(string $name = 'Composer', string $version = '') { static $shutdownRegistered = false; - + if ($version === '') { + $version = Composer::getVersion(); + } if (function_exists('ini_set') && extension_loaded('xdebug')) { ini_set('xdebug.show_exception_trace', '0'); ini_set('xdebug.scream', '0'); @@ -121,7 +123,7 @@ class Application extends BaseApplication $this->initialWorkingDirectory = getcwd(); - parent::__construct('Composer', Composer::getVersion()); + parent::__construct($name, $version); } public function __destruct()