From 36fbe5713cf8112b57433d6696ad31223ce1e173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draic=20Brady?= Date: Sat, 6 May 2017 14:08:05 +0100 Subject: [PATCH 01/13] Initial commit Add comments to explain consts Exclude codesniffer from PHARs Stash --- bin/phpmnd | 3 + box.json.dist | 3 +- composer.json | 3 +- src/Console/Command/SelfUpdate.php | 227 +++++++++++++++++++++++++++++ 4 files changed, 234 insertions(+), 2 deletions(-) create mode 100644 src/Console/Command/SelfUpdate.php diff --git a/bin/phpmnd b/bin/phpmnd index 81a2c8c..8b1456d 100755 --- a/bin/phpmnd +++ b/bin/phpmnd @@ -36,4 +36,7 @@ if (false === $loaded) { ini_set('xdebug.max_nesting_level', 10000); $application = new Povils\PHPMND\Console\Application; +if ('phar:' === substr(__FILE__, 0, 5)) { + $application->add(new Povils\PHPMND\Console\Command\SelfUpdate; +} $application->run(); diff --git a/box.json.dist b/box.json.dist index 173eeb9..85be828 100644 --- a/box.json.dist +++ b/box.json.dist @@ -40,7 +40,8 @@ "phar-io/manifest", "phar-io/version", "theseer/tokenizer", - "sebastian/object-reflector" + "sebastian/object-reflector", + "squizlabs/php_codesniffer" ], "in": [ "vendor" diff --git a/composer.json b/composer.json index 2176c3c..56bb433 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,8 @@ }, "require-dev": { "phpunit/phpunit": "^5.7 || ^6.0", - "squizlabs/php_codesniffer": "^2.8.1" + "squizlabs/php_codesniffer": "^2.8.1", + "padraic/phar-updater": "^1.0.3" }, "autoload": { "psr-4": { diff --git a/src/Console/Command/SelfUpdate.php b/src/Console/Command/SelfUpdate.php new file mode 100644 index 0000000..e27c455 --- /dev/null +++ b/src/Console/Command/SelfUpdate.php @@ -0,0 +1,227 @@ +setName('self-update') + ->setDescription('Update phpmnd.phar to most recent stable build.') + ->addOption( + 'stable', + 's', + InputOption::VALUE_NONE, + 'Update to most recent stable version of PHPMND tagged on Github.' + ) + ->addOption( + 'rollback', + 'r', + InputOption::VALUE_NONE, + 'Rollback to previous version of PHPMND if available on filesystem.' + ) + ->addOption( + 'check', + 'c', + InputOption::VALUE_NONE, + 'Checks what updates are available.' + ) + ; + } + + /** + * Execute the command. + * + * @param InputInterface $input + * @param OutputInterface $output + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->output = $output; + $this->version = $this->getApplication()->getVersion(); + $parser = new VersionParser; + + /** + * Check for ancilliary options + */ + if ($input->getOption('rollback')) { + $this->rollback(); + return; + } + + if ($input->getOption('check')) { + $this->printAvailableUpdates(); + return; + } + + $this->updateToStableBuild(); + } + + /** + * Perform update using phar-updater configured for stable versions. + */ + protected function updateToStableBuild() + { + $this->update($this->getStableUpdater()); + } + + /** + * Get phar-updater instance. + */ + protected function getStableUpdater() + { + $updater = new Updater; + $updater->setStrategy(Updater::STRATEGY_GITHUB); + return $this->getGithubReleasesUpdater($updater); + } + + /** + * Perform in-place update of phar. + */ + protected function update(Updater $updater) + { + $this->output->writeln('Updating...'.PHP_EOL); + try { + $result = $updater->update(); + + $newVersion = $updater->getNewVersion(); + $oldVersion = $updater->getOldVersion(); + + if ($result) { + $this->output->writeln('PHPMND has been updated.'); + $this->output->writeln(sprintf( + 'Current version is: %s.', + $newVersion + )); + $this->output->writeln(sprintf( + 'Previous version was: %s.', + $oldVersion + )); + } else { + $this->output->writeln('PHPMND is currently up to date.'); + $this->output->writeln(sprintf( + 'Current version is: %s.', + $oldVersion + )); + } + } catch (\Exception $e) { + $this->output->writeln(sprintf('Error: %s', $e->getMessage())); + } + $this->output->write(PHP_EOL); + } + + /** + * Attempt to rollback to the previous phar version. + */ + protected function rollback() + { + $updater = new Updater; + try { + $result = $updater->rollback(); + if ($result) { + $this->output->writeln('PHPMND has been rolled back to prior version.'); + } else { + $this->output->writeln('Rollback failed for reasons unknown.'); + } + } catch (\Exception $e) { + $this->output->writeln(sprintf('Error: %s', $e->getMessage())); + } + } + + protected function printAvailableUpdates() + { + $this->printCurrentLocalVersion(); + $this->printCurrentStableVersion(); + } + + /** + * Print the current version of the phar in use. + */ + protected function printCurrentLocalVersion() + { + $this->output->writeln(sprintf( + 'Your current local build version is: %s', + $this->version + )); + } + + /** + * Send updater to version printer. + */ + protected function printCurrentStableVersion() + { + $this->printVersion($this->getStableUpdater()); + } + + /** + * Print a remotely available version. + * @param Updater $updater + */ + protected function printVersion(Updater $updater) + { + $stability = 'stable'; + try { + if ($updater->hasUpdate()) { + $this->output->writeln(sprintf( + 'The current %s build available remotely is: %s', + $stability, + $updater->getNewVersion() + )); + } elseif (false == $updater->getNewVersion()) { + $this->output->writeln(sprintf('There are no new %s builds available.', $stability)); + } else { + $this->output->writeln(sprintf('You have the current %s build installed.', $stability)); + } + } catch (\Exception $e) { + $this->output->writeln(sprintf('Error: %s', $e->getMessage())); + } + } + + /** + * Configure phar-updater with local phar details. + * @param Updater $updater + * @return Updater + */ + protected function getGithubReleasesUpdater(Updater $updater) + { + $updater->getStrategy()->setPackageName(self::PACKAGE_NAME); + $updater->getStrategy()->setPharName(self::FILE_NAME); + $updater->getStrategy()->setCurrentLocalVersion($this->version); + return $updater; + } + +} From 5eaced4adbd99fef2691b61caf88093ea1e33542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draic=20Brady?= Date: Sat, 6 May 2017 18:37:17 +0100 Subject: [PATCH 02/13] Remap commands to allow second --- bin/phpmnd | 28 ++++++++++++++++++++++++++-- src/Console/Application.php | 12 ++++++------ src/Console/Command.php | 2 +- src/Console/Command/SelfUpdate.php | 6 +++--- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/bin/phpmnd b/bin/phpmnd index 8b1456d..dd16a92 100755 --- a/bin/phpmnd +++ b/bin/phpmnd @@ -36,7 +36,31 @@ if (false === $loaded) { ini_set('xdebug.max_nesting_level', 10000); $application = new Povils\PHPMND\Console\Application; +$application->add(new Povils\PHPMND\Console\Command); if ('phar:' === substr(__FILE__, 0, 5)) { - $application->add(new Povils\PHPMND\Console\Command\SelfUpdate; + $application->add(new Povils\PHPMND\Console\Command\SelfUpdate); +} + +$output = new Symfony\Component\Console\Output\ConsoleOutput(); +$input = new \Symfony\Component\Console\Input\ArgvInput(prepareArgv()); +$application->run($input, $output); + +function prepareArgv() +{ + $argv = $_SERVER['argv']; + + $found = false; + + while (next($argv)) { + $value = current($argv); + if (!$value || '-' !== $value[0]) { + $found = true; + } + } + + if (!$found) { + $argv[] = 'run'; + } + + return $argv; } -$application->run(); diff --git a/src/Console/Application.php b/src/Console/Application.php index b86efaf..6d1fe2c 100644 --- a/src/Console/Application.php +++ b/src/Console/Application.php @@ -19,12 +19,12 @@ class Application extends BaseApplication public function __construct() { - parent::__construct('phpmnd', self::VERSION); + parent::__construct(self::COMMAND_NAME, self::VERSION); } /** * @inheritdoc - */ + * protected function getCommandName(InputInterface $input) { return self::COMMAND_NAME; @@ -32,7 +32,7 @@ protected function getCommandName(InputInterface $input) /** * @inheritdoc - */ + * protected function getDefaultCommands() { $defaultCommands = parent::getDefaultCommands(); @@ -43,7 +43,7 @@ protected function getDefaultCommands() /** * @inheritdoc - */ + * public function getDefinition() { $inputDefinition = parent::getDefinition(); @@ -70,8 +70,8 @@ public function doRun(InputInterface $input, OutputInterface $output) exit; } - if (null === $input->getFirstArgument()) { - $input = new ArrayInput(['--help']); + if ('run' === $input->getFirstArgument()) { + $input = new ArrayInput(['run','--help']); } parent::doRun($input, $output); diff --git a/src/Console/Command.php b/src/Console/Command.php index 4cc17fa..a49c9e3 100644 --- a/src/Console/Command.php +++ b/src/Console/Command.php @@ -26,7 +26,7 @@ class Command extends BaseCommand protected function configure() { $this - ->setName('phpmnd') + ->setName('run') ->setDefinition( [ new InputArgument( diff --git a/src/Console/Command/SelfUpdate.php b/src/Console/Command/SelfUpdate.php index e27c455..9672a47 100644 --- a/src/Console/Command/SelfUpdate.php +++ b/src/Console/Command/SelfUpdate.php @@ -3,7 +3,7 @@ namespace Povils\PHPMND\Console\Command; use Povils\PHPMND\Console\Application; -use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Command\Command as BaseCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -11,7 +11,7 @@ use Humbug\SelfUpdate\VersionParser; use Humbug\SelfUpdate\Strategy\GithubStrategy; -class SelfUpdate extends Command +class SelfUpdate extends BaseCommand { /** @@ -104,7 +104,7 @@ protected function updateToStableBuild() */ protected function getStableUpdater() { - $updater = new Updater; + $updater = new Updater(null, false); $updater->setStrategy(Updater::STRATEGY_GITHUB); return $this->getGithubReleasesUpdater($updater); } From c9f9bf45cea6f77b8d151c6166215c8b791d1b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draic=20Brady?= Date: Sat, 6 May 2017 18:41:34 +0100 Subject: [PATCH 03/13] CS fixes --- src/Console/Command/SelfUpdate.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/Console/Command/SelfUpdate.php b/src/Console/Command/SelfUpdate.php index 9672a47..32660a4 100644 --- a/src/Console/Command/SelfUpdate.php +++ b/src/Console/Command/SelfUpdate.php @@ -43,22 +43,22 @@ protected function configure() ->setName('self-update') ->setDescription('Update phpmnd.phar to most recent stable build.') ->addOption( - 'stable', - 's', - InputOption::VALUE_NONE, - 'Update to most recent stable version of PHPMND tagged on Github.' + 'stable', + 's', + InputOption::VALUE_NONE, + 'Update to most recent stable version of PHPMND tagged on Github.' ) ->addOption( - 'rollback', - 'r', - InputOption::VALUE_NONE, - 'Rollback to previous version of PHPMND if available on filesystem.' + 'rollback', + 'r', + InputOption::VALUE_NONE, + 'Rollback to previous version of PHPMND if available on filesystem.' ) ->addOption( - 'check', - 'c', - InputOption::VALUE_NONE, - 'Checks what updates are available.' + 'check', + 'c', + InputOption::VALUE_NONE, + 'Checks what updates are available.' ) ; } @@ -223,5 +223,4 @@ protected function getGithubReleasesUpdater(Updater $updater) $updater->getStrategy()->setCurrentLocalVersion($this->version); return $updater; } - } From 28640d4ce6198eaa888439e63a429eed0bedce2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draic=20Brady?= Date: Sat, 6 May 2017 18:52:51 +0100 Subject: [PATCH 04/13] Remove dead code --- src/Console/Application.php | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/src/Console/Application.php b/src/Console/Application.php index 6d1fe2c..cb76e3f 100644 --- a/src/Console/Application.php +++ b/src/Console/Application.php @@ -22,36 +22,6 @@ public function __construct() parent::__construct(self::COMMAND_NAME, self::VERSION); } - /** - * @inheritdoc - * - protected function getCommandName(InputInterface $input) - { - return self::COMMAND_NAME; - } - - /** - * @inheritdoc - * - protected function getDefaultCommands() - { - $defaultCommands = parent::getDefaultCommands(); - $defaultCommands[] = new Command; - - return $defaultCommands; - } - - /** - * @inheritdoc - * - public function getDefinition() - { - $inputDefinition = parent::getDefinition(); - $inputDefinition->setArguments(); - - return $inputDefinition; - } - /** * @inheritdoc */ From cdf04ed0c61379f2c799caae9607241dcdb99862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draic=20Brady?= Date: Sat, 6 May 2017 19:12:27 +0100 Subject: [PATCH 05/13] Small fix - Updater should be configured for unsigned phars --- src/Console/Command/SelfUpdate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Console/Command/SelfUpdate.php b/src/Console/Command/SelfUpdate.php index 32660a4..347f74d 100644 --- a/src/Console/Command/SelfUpdate.php +++ b/src/Console/Command/SelfUpdate.php @@ -149,7 +149,7 @@ protected function update(Updater $updater) */ protected function rollback() { - $updater = new Updater; + $updater = new Updater(null, false); try { $result = $updater->rollback(); if ($result) { From ab1ec6105c8d65938ea793260c487b7f67fba69f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draic=20Brady?= Date: Sat, 6 May 2017 19:32:12 +0100 Subject: [PATCH 06/13] Remove ref to VersionParser (not used unless updating to non-stable versions) --- src/Console/Command/SelfUpdate.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Console/Command/SelfUpdate.php b/src/Console/Command/SelfUpdate.php index 347f74d..915a8af 100644 --- a/src/Console/Command/SelfUpdate.php +++ b/src/Console/Command/SelfUpdate.php @@ -8,7 +8,6 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Humbug\SelfUpdate\Updater; -use Humbug\SelfUpdate\VersionParser; use Humbug\SelfUpdate\Strategy\GithubStrategy; class SelfUpdate extends BaseCommand @@ -73,7 +72,6 @@ protected function execute(InputInterface $input, OutputInterface $output) { $this->output = $output; $this->version = $this->getApplication()->getVersion(); - $parser = new VersionParser; /** * Check for ancilliary options From 52f0c626a27975c6ed4fedaf053141c0afb2b4ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draic=20Brady?= Date: Sat, 6 May 2017 21:01:25 +0100 Subject: [PATCH 07/13] Include a 'list' description for default command 'run' --- src/Console/Command.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Console/Command.php b/src/Console/Command.php index a49c9e3..fe2b52e 100644 --- a/src/Console/Command.php +++ b/src/Console/Command.php @@ -27,6 +27,7 @@ protected function configure() { $this ->setName('run') + ->setDescription('Runs PHPMND. Executed by default when no other command provided.') ->setDefinition( [ new InputArgument( From 4030f8b7fa73c697a794ddd1bd4cc533bec70df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draic=20Brady?= Date: Sat, 6 May 2017 22:34:34 +0100 Subject: [PATCH 08/13] Normalise command delivered to symfony/console from `phpmnd` to `phpmnd run` --- bin/phpmnd | 9 +++------ src/Console/Application.php | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/bin/phpmnd b/bin/phpmnd index dd16a92..152ef02 100755 --- a/bin/phpmnd +++ b/bin/phpmnd @@ -51,15 +51,12 @@ function prepareArgv() $found = false; - while (next($argv)) { - $value = current($argv); - if (!$value || '-' !== $value[0]) { - $found = true; - } + if (isset($argv[1]) && ('run' === $argv[1] || 'self-update' === $argv[1])) { + $found = true; } if (!$found) { - $argv[] = 'run'; + array_splice($argv, 1, 0, ['run']); } return $argv; diff --git a/src/Console/Application.php b/src/Console/Application.php index cb76e3f..0105e89 100644 --- a/src/Console/Application.php +++ b/src/Console/Application.php @@ -40,7 +40,7 @@ public function doRun(InputInterface $input, OutputInterface $output) exit; } - if ('run' === $input->getFirstArgument()) { + if ('run' === (string) $input) { $input = new ArrayInput(['run','--help']); } From 4c29e14849a95866ff6e85d4d7557b58ea0f9120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draic=20Brady?= Date: Sun, 7 May 2017 23:08:34 +0100 Subject: [PATCH 09/13] Update for review --- src/Console/Application.php | 1 + src/Console/Command/SelfUpdate.php | 37 +++++++++++------------------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/Console/Application.php b/src/Console/Application.php index 0105e89..bc7c6f4 100644 --- a/src/Console/Application.php +++ b/src/Console/Application.php @@ -16,6 +16,7 @@ class Application extends BaseApplication { const VERSION = '1.0.3'; const COMMAND_NAME = 'phpmnd'; + const PACKAGIST_PACKAGE_NAME = 'povils/phpmnd'; public function __construct() { diff --git a/src/Console/Command/SelfUpdate.php b/src/Console/Command/SelfUpdate.php index 915a8af..f1c571d 100644 --- a/src/Console/Command/SelfUpdate.php +++ b/src/Console/Command/SelfUpdate.php @@ -13,15 +13,7 @@ class SelfUpdate extends BaseCommand { - /** - * Packagist package name - */ - const PACKAGE_NAME = 'povils/phpmnd'; - - /** - * This is the remote file name, not local name. - */ - const FILE_NAME = 'phpmnd.phar'; + const REMOTE_FILENAME = 'phpmnd.phar'; /** * @var OutputInterface @@ -36,7 +28,7 @@ class SelfUpdate extends BaseCommand /** * Setup command and arguments. */ - protected function configure() + private function configure() { $this ->setName('self-update') @@ -68,7 +60,7 @@ protected function configure() * @param InputInterface $input * @param OutputInterface $output */ - protected function execute(InputInterface $input, OutputInterface $output) + private function execute(InputInterface $input, OutputInterface $output) { $this->output = $output; $this->version = $this->getApplication()->getVersion(); @@ -92,7 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output) /** * Perform update using phar-updater configured for stable versions. */ - protected function updateToStableBuild() + private function updateToStableBuild() { $this->update($this->getStableUpdater()); } @@ -100,7 +92,7 @@ protected function updateToStableBuild() /** * Get phar-updater instance. */ - protected function getStableUpdater() + private function getStableUpdater() { $updater = new Updater(null, false); $updater->setStrategy(Updater::STRATEGY_GITHUB); @@ -110,7 +102,7 @@ protected function getStableUpdater() /** * Perform in-place update of phar. */ - protected function update(Updater $updater) + private function update(Updater $updater) { $this->output->writeln('Updating...'.PHP_EOL); try { @@ -145,7 +137,7 @@ protected function update(Updater $updater) /** * Attempt to rollback to the previous phar version. */ - protected function rollback() + private function rollback() { $updater = new Updater(null, false); try { @@ -160,7 +152,7 @@ protected function rollback() } } - protected function printAvailableUpdates() + private function printAvailableUpdates() { $this->printCurrentLocalVersion(); $this->printCurrentStableVersion(); @@ -169,7 +161,7 @@ protected function printAvailableUpdates() /** * Print the current version of the phar in use. */ - protected function printCurrentLocalVersion() + private function printCurrentLocalVersion() { $this->output->writeln(sprintf( 'Your current local build version is: %s', @@ -180,7 +172,7 @@ protected function printCurrentLocalVersion() /** * Send updater to version printer. */ - protected function printCurrentStableVersion() + private function printCurrentStableVersion() { $this->printVersion($this->getStableUpdater()); } @@ -189,7 +181,7 @@ protected function printCurrentStableVersion() * Print a remotely available version. * @param Updater $updater */ - protected function printVersion(Updater $updater) + private function printVersion(Updater $updater) { $stability = 'stable'; try { @@ -210,14 +202,13 @@ protected function printVersion(Updater $updater) } /** - * Configure phar-updater with local phar details. * @param Updater $updater * @return Updater */ - protected function getGithubReleasesUpdater(Updater $updater) + private function getGithubReleasesUpdater(Updater $updater) { - $updater->getStrategy()->setPackageName(self::PACKAGE_NAME); - $updater->getStrategy()->setPharName(self::FILE_NAME); + $updater->getStrategy()->setPackageName(Application::PACKAGIST_PACKAGE_NAME); + $updater->getStrategy()->setPharName(self::REMOTE_FILENAME); $updater->getStrategy()->setCurrentLocalVersion($this->version); return $updater; } From b2571b19e41650f6b514c18031cf0a1254b8f5bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draic=20Brady?= Date: Sun, 7 May 2017 23:15:07 +0100 Subject: [PATCH 10/13] Update prop/method visibility to interface --- src/Console/Command/SelfUpdate.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Console/Command/SelfUpdate.php b/src/Console/Command/SelfUpdate.php index f1c571d..02f6102 100644 --- a/src/Console/Command/SelfUpdate.php +++ b/src/Console/Command/SelfUpdate.php @@ -18,17 +18,17 @@ class SelfUpdate extends BaseCommand /** * @var OutputInterface */ - protected $output; + private $output; /** * @var string */ - protected $version; + private $version; /** * Setup command and arguments. */ - private function configure() + protected function configure() { $this ->setName('self-update') @@ -60,7 +60,7 @@ private function configure() * @param InputInterface $input * @param OutputInterface $output */ - private function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output) { $this->output = $output; $this->version = $this->getApplication()->getVersion(); From e22bea4fef21c7922818f88f5c776cb67103511e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draic=20Brady?= Date: Sun, 7 May 2017 23:18:38 +0100 Subject: [PATCH 11/13] Update colour theme --- src/Console/Command/SelfUpdate.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Console/Command/SelfUpdate.php b/src/Console/Command/SelfUpdate.php index 02f6102..19c6a4f 100644 --- a/src/Console/Command/SelfUpdate.php +++ b/src/Console/Command/SelfUpdate.php @@ -112,24 +112,24 @@ private function update(Updater $updater) $oldVersion = $updater->getOldVersion(); if ($result) { - $this->output->writeln('PHPMND has been updated.'); + $this->output->writeln('PHPMND has been updated.'); $this->output->writeln(sprintf( - 'Current version is: %s.', + 'Current version is: %s.', $newVersion )); $this->output->writeln(sprintf( - 'Previous version was: %s.', + 'Previous version was: %s.', $oldVersion )); } else { - $this->output->writeln('PHPMND is currently up to date.'); + $this->output->writeln('PHPMND is currently up to date.'); $this->output->writeln(sprintf( - 'Current version is: %s.', + 'Current version is: %s.', $oldVersion )); } } catch (\Exception $e) { - $this->output->writeln(sprintf('Error: %s', $e->getMessage())); + $this->output->writeln(sprintf('Error: %s', $e->getMessage())); } $this->output->write(PHP_EOL); } @@ -143,12 +143,12 @@ private function rollback() try { $result = $updater->rollback(); if ($result) { - $this->output->writeln('PHPMND has been rolled back to prior version.'); + $this->output->writeln('PHPMND has been rolled back to prior version.'); } else { - $this->output->writeln('Rollback failed for reasons unknown.'); + $this->output->writeln('Rollback failed for reasons unknown.'); } } catch (\Exception $e) { - $this->output->writeln(sprintf('Error: %s', $e->getMessage())); + $this->output->writeln(sprintf('Error: %s', $e->getMessage())); } } @@ -197,7 +197,7 @@ private function printVersion(Updater $updater) $this->output->writeln(sprintf('You have the current %s build installed.', $stability)); } } catch (\Exception $e) { - $this->output->writeln(sprintf('Error: %s', $e->getMessage())); + $this->output->writeln(sprintf('Error: %s', $e->getMessage())); } } From 734ed1b5f6ce46660e55da2ad4d42f27bc0545d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draic=20Brady?= Date: Sun, 7 May 2017 23:21:16 +0100 Subject: [PATCH 12/13] Closing tags, idiot! :D --- src/Console/Command/SelfUpdate.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Console/Command/SelfUpdate.php b/src/Console/Command/SelfUpdate.php index 19c6a4f..d70dd65 100644 --- a/src/Console/Command/SelfUpdate.php +++ b/src/Console/Command/SelfUpdate.php @@ -112,24 +112,24 @@ private function update(Updater $updater) $oldVersion = $updater->getOldVersion(); if ($result) { - $this->output->writeln('PHPMND has been updated.'); + $this->output->writeln('PHPMND has been updated.'); $this->output->writeln(sprintf( - 'Current version is: %s.', + 'Current version is: %s.', $newVersion )); $this->output->writeln(sprintf( - 'Previous version was: %s.', + 'Previous version was: %s.', $oldVersion )); } else { - $this->output->writeln('PHPMND is currently up to date.'); + $this->output->writeln('PHPMND is currently up to date.'); $this->output->writeln(sprintf( - 'Current version is: %s.', + 'Current version is: %s.', $oldVersion )); } } catch (\Exception $e) { - $this->output->writeln(sprintf('Error: %s', $e->getMessage())); + $this->output->writeln(sprintf('Error: %s', $e->getMessage())); } $this->output->write(PHP_EOL); } @@ -143,12 +143,12 @@ private function rollback() try { $result = $updater->rollback(); if ($result) { - $this->output->writeln('PHPMND has been rolled back to prior version.'); + $this->output->writeln('PHPMND has been rolled back to prior version.'); } else { - $this->output->writeln('Rollback failed for reasons unknown.'); + $this->output->writeln('Rollback failed for reasons unknown.'); } } catch (\Exception $e) { - $this->output->writeln(sprintf('Error: %s', $e->getMessage())); + $this->output->writeln(sprintf('Error: %s', $e->getMessage())); } } @@ -197,7 +197,7 @@ private function printVersion(Updater $updater) $this->output->writeln(sprintf('You have the current %s build installed.', $stability)); } } catch (\Exception $e) { - $this->output->writeln(sprintf('Error: %s', $e->getMessage())); + $this->output->writeln(sprintf('Error: %s', $e->getMessage())); } } From 6bc8e1c1a8b408626c42521f1701d5abda5383de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draic=20Brady?= Date: Tue, 16 May 2017 21:05:37 +0100 Subject: [PATCH 13/13] Replace with in output decoration --- src/Console/Command/SelfUpdate.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/Console/Command/SelfUpdate.php b/src/Console/Command/SelfUpdate.php index d70dd65..844d9d0 100644 --- a/src/Console/Command/SelfUpdate.php +++ b/src/Console/Command/SelfUpdate.php @@ -33,12 +33,6 @@ protected function configure() $this ->setName('self-update') ->setDescription('Update phpmnd.phar to most recent stable build.') - ->addOption( - 'stable', - 's', - InputOption::VALUE_NONE, - 'Update to most recent stable version of PHPMND tagged on Github.' - ) ->addOption( 'rollback', 'r', @@ -49,7 +43,7 @@ protected function configure() 'check', 'c', InputOption::VALUE_NONE, - 'Checks what updates are available.' + 'Checks whether an update is available.' ) ; } @@ -129,7 +123,7 @@ private function update(Updater $updater) )); } } catch (\Exception $e) { - $this->output->writeln(sprintf('Error: %s', $e->getMessage())); + $this->output->writeln(sprintf('Error: %s', $e->getMessage())); } $this->output->write(PHP_EOL); } @@ -145,10 +139,10 @@ private function rollback() if ($result) { $this->output->writeln('PHPMND has been rolled back to prior version.'); } else { - $this->output->writeln('Rollback failed for reasons unknown.'); + $this->output->writeln('Rollback failed for reasons unknown.'); } } catch (\Exception $e) { - $this->output->writeln(sprintf('Error: %s', $e->getMessage())); + $this->output->writeln(sprintf('Error: %s', $e->getMessage())); } } @@ -197,7 +191,7 @@ private function printVersion(Updater $updater) $this->output->writeln(sprintf('You have the current %s build installed.', $stability)); } } catch (\Exception $e) { - $this->output->writeln(sprintf('Error: %s', $e->getMessage())); + $this->output->writeln(sprintf('Error: %s', $e->getMessage())); } }