From e0034601e81c909196b72c8549b64048ee1a9c8e Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Tue, 2 Nov 2021 12:09:00 +0100 Subject: [PATCH 1/3] [Console] Runtime conflict for psr/log >= 3.0 instead of composer conflict --- Logger/ConsoleLogger.php | 4 ++++ composer.json | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Logger/ConsoleLogger.php b/Logger/ConsoleLogger.php index c9ee03561..9abe713ff 100644 --- a/Logger/ConsoleLogger.php +++ b/Logger/ConsoleLogger.php @@ -17,6 +17,10 @@ use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\OutputInterface; +if ((new \ReflectionMethod(AbstractLogger::class, 'log'))->hasReturnType()) { + throw new \RuntimeException(sprintf('The "%s" logger is not compatible with psr/log >= 3.0. Try running "composer require psr/log:^2.".', ConsoleLogger::class)); +} + /** * PSR-3 compliant console logger. * diff --git a/composer.json b/composer.json index 7598179c3..1984e520d 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,6 @@ "psr/log": "For using the console logger" }, "conflict": { - "psr/log": ">=3", "symfony/dependency-injection": "<4.4", "symfony/dotenv": "<5.1", "symfony/event-dispatcher": "<4.4", From 329b3a75cc6b16d435ba1b1a41df54a53382a3f0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 4 Nov 2021 09:49:31 +0100 Subject: [PATCH 2/3] Fix CS --- Input/ArgvInput.php | 2 +- Output/TrimmedBufferOutput.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Input/ArgvInput.php b/Input/ArgvInput.php index b63529509..63f40f271 100644 --- a/Input/ArgvInput.php +++ b/Input/ArgvInput.php @@ -137,7 +137,7 @@ private function parseLongOption(string $token) $name = substr($token, 2); if (false !== $pos = strpos($name, '=')) { - if (0 === \strlen($value = substr($name, $pos + 1))) { + if ('' === $value = substr($name, $pos + 1)) { array_unshift($this->parsed, $value); } $this->addLongOption(substr($name, 0, $pos), $value); diff --git a/Output/TrimmedBufferOutput.php b/Output/TrimmedBufferOutput.php index 4ca63c49b..87c04a892 100644 --- a/Output/TrimmedBufferOutput.php +++ b/Output/TrimmedBufferOutput.php @@ -24,7 +24,8 @@ class TrimmedBufferOutput extends Output private $maxLength; private $buffer = ''; - public function __construct(int $maxLength, ?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, OutputFormatterInterface $formatter = null) { + public function __construct(int $maxLength, ?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, OutputFormatterInterface $formatter = null) + { if ($maxLength <= 0) { throw new InvalidArgumentException(sprintf('"%s()" expects a strictly positive maxLength. Got %d.', __METHOD__, $maxLength)); } From 3e7ab8f5905058984899b05a4648096f558bfeba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Sun, 21 Nov 2021 01:00:46 +0100 Subject: [PATCH 3/3] Default ansi option to null --- Application.php | 2 +- CHANGELOG.md | 1 + Tests/Fixtures/application_1.md | 4 ++-- Tests/Fixtures/application_2.md | 10 +++++----- Tests/Fixtures/application_mbstring.md | 6 +++--- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Application.php b/Application.php index 769c65d63..9f9f8394e 100644 --- a/Application.php +++ b/Application.php @@ -1040,7 +1040,7 @@ protected function getDefaultInputDefinition() new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'), new InputOption('--verbose', '-v|vv|vvv', InputOption::VALUE_NONE, 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'), new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'), - new InputOption('--ansi', '', InputOption::VALUE_NEGATABLE, 'Force (or disable --no-ansi) ANSI output', false), + new InputOption('--ansi', '', InputOption::VALUE_NEGATABLE, 'Force (or disable --no-ansi) ANSI output', null), new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'), ]); } diff --git a/CHANGELOG.md b/CHANGELOG.md index 880856386..c41b65f14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ CHANGELOG * Add support for bright colors * Add `#[AsCommand]` attribute for declaring commands on PHP 8 * Add `Helper::width()` and `Helper::length()` + * The `--ansi` and `--no-ansi` options now default to `null`. 5.2.0 ----- diff --git a/Tests/Fixtures/application_1.md b/Tests/Fixtures/application_1.md index fb1d089f4..1ecb4e62f 100644 --- a/Tests/Fixtures/application_1.md +++ b/Tests/Fixtures/application_1.md @@ -103,7 +103,7 @@ Force (or disable --no-ansi) ANSI output * Is value required: no * Is multiple: no * Is negatable: yes -* Default: `false` +* Default: `NULL` #### `--no-interaction|-n` @@ -230,7 +230,7 @@ Force (or disable --no-ansi) ANSI output * Is value required: no * Is multiple: no * Is negatable: yes -* Default: `false` +* Default: `NULL` #### `--no-interaction|-n` diff --git a/Tests/Fixtures/application_2.md b/Tests/Fixtures/application_2.md index 75ed6bd5f..96d5431e6 100644 --- a/Tests/Fixtures/application_2.md +++ b/Tests/Fixtures/application_2.md @@ -116,7 +116,7 @@ Force (or disable --no-ansi) ANSI output * Is value required: no * Is multiple: no * Is negatable: yes -* Default: `false` +* Default: `NULL` #### `--no-interaction|-n` @@ -243,7 +243,7 @@ Force (or disable --no-ansi) ANSI output * Is value required: no * Is multiple: no * Is negatable: yes -* Default: `false` +* Default: `NULL` #### `--no-interaction|-n` @@ -318,7 +318,7 @@ Force (or disable --no-ansi) ANSI output * Is value required: no * Is multiple: no * Is negatable: yes -* Default: `false` +* Default: `NULL` #### `--no-interaction|-n` @@ -409,7 +409,7 @@ Force (or disable --no-ansi) ANSI output * Is value required: no * Is multiple: no * Is negatable: yes -* Default: `false` +* Default: `NULL` #### `--no-interaction|-n` @@ -481,7 +481,7 @@ Force (or disable --no-ansi) ANSI output * Is value required: no * Is multiple: no * Is negatable: yes -* Default: `false` +* Default: `NULL` #### `--no-interaction|-n` diff --git a/Tests/Fixtures/application_mbstring.md b/Tests/Fixtures/application_mbstring.md index 148122295..e3838905f 100644 --- a/Tests/Fixtures/application_mbstring.md +++ b/Tests/Fixtures/application_mbstring.md @@ -107,7 +107,7 @@ Force (or disable --no-ansi) ANSI output * Is value required: no * Is multiple: no * Is negatable: yes -* Default: `false` +* Default: `NULL` #### `--no-interaction|-n` @@ -234,7 +234,7 @@ Force (or disable --no-ansi) ANSI output * Is value required: no * Is multiple: no * Is negatable: yes -* Default: `false` +* Default: `NULL` #### `--no-interaction|-n` @@ -325,7 +325,7 @@ Force (or disable --no-ansi) ANSI output * Is value required: no * Is multiple: no * Is negatable: yes -* Default: `false` +* Default: `NULL` #### `--no-interaction|-n`