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/Input/ArgvInput.php b/Input/ArgvInput.php index a33ca3519..4568e45fe 100644 --- a/Input/ArgvInput.php +++ b/Input/ArgvInput.php @@ -134,7 +134,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/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/Output/TrimmedBufferOutput.php b/Output/TrimmedBufferOutput.php index 5455c5b47..3f4d375f4 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)); } 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` 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",