From c36a64ad8b1f71dff8bc74132bf7e0ee1b07c51e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 2 Sep 2020 18:06:40 +0200 Subject: [PATCH 1/7] Enable "native_constant_invocation" CS rule --- Application.php | 16 ++++++------- Command/Command.php | 2 +- Descriptor/JsonDescriptor.php | 4 ++-- Descriptor/TextDescriptor.php | 4 ++-- Event/ConsoleExceptionEvent.php | 2 +- Formatter/OutputFormatter.php | 6 ++--- Helper/ProgressBar.php | 4 ++-- Helper/QuestionHelper.php | 6 ++--- Helper/SymfonyQuestionHelper.php | 2 +- Helper/TableStyle.php | 4 ++-- Input/InputDefinition.php | 2 +- Output/BufferedOutput.php | 2 +- Output/ConsoleOutput.php | 2 +- Output/StreamOutput.php | 2 +- Style/OutputStyle.php | 2 +- Style/SymfonyStyle.php | 4 ++-- Tester/ApplicationTester.php | 4 ++-- Tester/CommandTester.php | 4 ++-- Tests/ApplicationTest.php | 14 +++++------ Tests/Command/CommandTest.php | 16 ++++++------- Tests/Descriptor/AbstractDescriptorTest.php | 2 +- Tests/Descriptor/JsonDescriptorTest.php | 2 +- Tests/Descriptor/ObjectsProvider.php | 4 ++-- Tests/Helper/ProcessHelperTest.php | 6 ++--- Tests/Helper/ProgressBarTest.php | 26 ++++++++++----------- Tests/Helper/ProgressIndicatorTest.php | 10 ++++---- Tests/Helper/SymfonyQuestionHelperTest.php | 2 +- Tests/Helper/TableTest.php | 8 +++---- Tests/Logger/ConsoleLoggerTest.php | 2 +- Tests/Output/StreamOutputTest.php | 2 +- Tests/Tester/ApplicationTesterTest.php | 4 ++-- Tests/Tester/CommandTesterTest.php | 4 ++-- 32 files changed, 87 insertions(+), 87 deletions(-) diff --git a/Application.php b/Application.php index 320d53919..e9e3defa1 100644 --- a/Application.php +++ b/Application.php @@ -121,7 +121,7 @@ public function run(InputInterface $input = null, OutputInterface $output = null $renderException = function ($e) use ($output) { if (!$e instanceof \Exception) { - $e = class_exists(FatalThrowableError::class) ? new FatalThrowableError($e) : new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); + $e = class_exists(FatalThrowableError::class) ? new FatalThrowableError($e) : new \ErrorException($e->getMessage(), $e->getCode(), \E_ERROR, $e->getFile(), $e->getLine()); } if ($output instanceof ConsoleOutputInterface) { $this->renderException($e, $output->getErrorOutput()); @@ -139,7 +139,7 @@ public function run(InputInterface $input = null, OutputInterface $output = null } if (null !== $this->dispatcher && $this->dispatcher->hasListeners(ConsoleEvents::EXCEPTION)) { - @trigger_error(sprintf('The "ConsoleEvents::EXCEPTION" event is deprecated since Symfony 3.3 and will be removed in 4.0. Listen to the "ConsoleEvents::ERROR" event instead.'), E_USER_DEPRECATED); + @trigger_error(sprintf('The "ConsoleEvents::EXCEPTION" event is deprecated since Symfony 3.3 and will be removed in 4.0. Listen to the "ConsoleEvents::ERROR" event instead.'), \E_USER_DEPRECATED); } $this->configureIO($input, $output); @@ -784,7 +784,7 @@ protected function doRenderException(\Exception $e, OutputInterface $output) $len = 0; } - $width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : PHP_INT_MAX; + $width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : \PHP_INT_MAX; // HHVM only accepts 32 bits integer in str_split, even when PHP_INT_MAX is a 64 bit integer: https://github.com/facebook/hhvm/issues/1327 if (\defined('HHVM_VERSION') && $width > 1 << 31) { $width = 1 << 31; @@ -853,7 +853,7 @@ protected function doRenderException(\Exception $e, OutputInterface $output) */ protected function getTerminalWidth() { - @trigger_error(sprintf('The "%s()" method is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead.', __METHOD__), \E_USER_DEPRECATED); return $this->terminal->getWidth(); } @@ -867,7 +867,7 @@ protected function getTerminalWidth() */ protected function getTerminalHeight() { - @trigger_error(sprintf('The "%s()" method is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead.', __METHOD__), \E_USER_DEPRECATED); return $this->terminal->getHeight(); } @@ -881,7 +881,7 @@ protected function getTerminalHeight() */ public function getTerminalDimensions() { - @trigger_error(sprintf('The "%s()" method is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead.', __METHOD__), \E_USER_DEPRECATED); return [$this->terminal->getWidth(), $this->terminal->getHeight()]; } @@ -900,7 +900,7 @@ public function getTerminalDimensions() */ public function setTerminalDimensions($width, $height) { - @trigger_error(sprintf('The "%s()" method is deprecated as of 3.2 and will be removed in 4.0. Set the COLUMNS and LINES env vars instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated as of 3.2 and will be removed in 4.0. Set the COLUMNS and LINES env vars instead.', __METHOD__), \E_USER_DEPRECATED); putenv('COLUMNS='.$width); putenv('LINES='.$height); @@ -1173,7 +1173,7 @@ private function findAlternatives($name, $collection) } $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; }); - ksort($alternatives, SORT_NATURAL | SORT_FLAG_CASE); + ksort($alternatives, \SORT_NATURAL | \SORT_FLAG_CASE); return array_keys($alternatives); } diff --git a/Command/Command.php b/Command/Command.php index e39cc3ba4..d896f67fd 100644 --- a/Command/Command.php +++ b/Command/Command.php @@ -223,7 +223,7 @@ public function run(InputInterface $input, OutputInterface $output) if (null !== $this->processTitle) { if (\function_exists('cli_set_process_title')) { if (!@cli_set_process_title($this->processTitle)) { - if ('Darwin' === PHP_OS) { + if ('Darwin' === \PHP_OS) { $output->writeln('Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.', OutputInterface::VERBOSITY_VERY_VERBOSE); } else { cli_set_process_title($this->processTitle); diff --git a/Descriptor/JsonDescriptor.php b/Descriptor/JsonDescriptor.php index d1af3bab2..e51c31db5 100644 --- a/Descriptor/JsonDescriptor.php +++ b/Descriptor/JsonDescriptor.php @@ -110,7 +110,7 @@ private function getInputArgumentData(InputArgument $argument) 'is_required' => $argument->isRequired(), 'is_array' => $argument->isArray(), 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()), - 'default' => INF === $argument->getDefault() ? 'INF' : $argument->getDefault(), + 'default' => \INF === $argument->getDefault() ? 'INF' : $argument->getDefault(), ]; } @@ -126,7 +126,7 @@ private function getInputOptionData(InputOption $option) 'is_value_required' => $option->isValueRequired(), 'is_multiple' => $option->isArray(), 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()), - 'default' => INF === $option->getDefault() ? 'INF' : $option->getDefault(), + 'default' => \INF === $option->getDefault() ? 'INF' : $option->getDefault(), ]; } diff --git a/Descriptor/TextDescriptor.php b/Descriptor/TextDescriptor.php index 960055907..9ca56ce9d 100644 --- a/Descriptor/TextDescriptor.php +++ b/Descriptor/TextDescriptor.php @@ -276,7 +276,7 @@ private function getCommandAliasesText(Command $command) */ private function formatDefaultValue($default) { - if (INF === $default) { + if (\INF === $default) { return 'INF'; } @@ -290,7 +290,7 @@ private function formatDefaultValue($default) } } - return str_replace('\\\\', '\\', json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); + return str_replace('\\\\', '\\', json_encode($default, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE)); } /** diff --git a/Event/ConsoleExceptionEvent.php b/Event/ConsoleExceptionEvent.php index 0adfaf9ac..845119ee2 100644 --- a/Event/ConsoleExceptionEvent.php +++ b/Event/ConsoleExceptionEvent.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Console\Event; -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 3.3 and will be removed in 4.0. Use the ConsoleErrorEvent instead.', ConsoleExceptionEvent::class), E_USER_DEPRECATED); +@trigger_error(sprintf('The "%s" class is deprecated since Symfony 3.3 and will be removed in 4.0. Use the ConsoleErrorEvent instead.', ConsoleExceptionEvent::class), \E_USER_DEPRECATED); use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; diff --git a/Formatter/OutputFormatter.php b/Formatter/OutputFormatter.php index 3202fc176..abc85398e 100644 --- a/Formatter/OutputFormatter.php +++ b/Formatter/OutputFormatter.php @@ -134,7 +134,7 @@ public function format($message) $offset = 0; $output = ''; $tagRegex = '[a-z][a-z0-9,_=;-]*+'; - preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, PREG_OFFSET_CAPTURE); + preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, \PREG_OFFSET_CAPTURE); foreach ($matches[0] as $i => $match) { $pos = $match[1]; $text = $match[0]; @@ -196,7 +196,7 @@ private function createStyleFromString($string) return $this->styles[$string]; } - if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, PREG_SET_ORDER)) { + if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, \PREG_SET_ORDER)) { return false; } @@ -216,7 +216,7 @@ private function createStyleFromString($string) try { $style->setOption($option); } catch (\InvalidArgumentException $e) { - @trigger_error(sprintf('Unknown style options are deprecated since Symfony 3.2 and will be removed in 4.0. Exception "%s".', $e->getMessage()), E_USER_DEPRECATED); + @trigger_error(sprintf('Unknown style options are deprecated since Symfony 3.2 and will be removed in 4.0. Exception "%s".', $e->getMessage()), \E_USER_DEPRECATED); return false; } diff --git a/Helper/ProgressBar.php b/Helper/ProgressBar.php index 172565514..4ee4912f6 100644 --- a/Helper/ProgressBar.php +++ b/Helper/ProgressBar.php @@ -475,7 +475,7 @@ private function overwrite($message) $message = "\x0D\x1B[2K$message"; } } elseif ($this->step > 0) { - $message = PHP_EOL.$message; + $message = \PHP_EOL.$message; } $this->firstRun = false; @@ -544,7 +544,7 @@ private static function initPlaceholderFormatters() return Helper::formatMemory(memory_get_usage(true)); }, 'current' => function (self $bar) { - return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', STR_PAD_LEFT); + return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', \STR_PAD_LEFT); }, 'max' => function (self $bar) { return $bar->getMaxSteps(); diff --git a/Helper/QuestionHelper.php b/Helper/QuestionHelper.php index ee6d4b664..15d4549da 100644 --- a/Helper/QuestionHelper.php +++ b/Helper/QuestionHelper.php @@ -102,7 +102,7 @@ public function ask(InputInterface $input, OutputInterface $output, Question $qu */ public function setInputStream($stream) { - @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.2 and will be removed in 4.0. Use %s::setStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED); + @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.2 and will be removed in 4.0. Use %s::setStream() instead.', __METHOD__, StreamableInputInterface::class), \E_USER_DEPRECATED); if (!\is_resource($stream)) { throw new InvalidArgumentException('Input stream must be a valid resource.'); @@ -122,7 +122,7 @@ public function setInputStream($stream) public function getInputStream() { if (0 === \func_num_args() || func_get_arg(0)) { - @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.2 and will be removed in 4.0. Use %s::getStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED); + @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.2 and will be removed in 4.0. Use %s::getStream() instead.', __METHOD__, StreamableInputInterface::class), \E_USER_DEPRECATED); } return $this->inputStream; @@ -155,7 +155,7 @@ private function doAsk(OutputInterface $output, Question $question) { $this->writePrompt($output, $question); - $inputStream = $this->inputStream ?: STDIN; + $inputStream = $this->inputStream ?: \STDIN; $autocomplete = $question->getAutocompleterValues(); if (\function_exists('sapi_windows_cp_set')) { diff --git a/Helper/SymfonyQuestionHelper.php b/Helper/SymfonyQuestionHelper.php index 7cd050fee..86bebd9d7 100644 --- a/Helper/SymfonyQuestionHelper.php +++ b/Helper/SymfonyQuestionHelper.php @@ -41,7 +41,7 @@ public function ask(InputInterface $input, OutputInterface $output, Question $qu } else { // make required if (!\is_array($value) && !\is_bool($value) && 0 === \strlen($value)) { - @trigger_error('The default question validator is deprecated since Symfony 3.3 and will not be used anymore in version 4.0. Set a custom question validator if needed.', E_USER_DEPRECATED); + @trigger_error('The default question validator is deprecated since Symfony 3.3 and will not be used anymore in version 4.0. Set a custom question validator if needed.', \E_USER_DEPRECATED); throw new LogicException('A value is required.'); } diff --git a/Helper/TableStyle.php b/Helper/TableStyle.php index 4213297f5..98d8847f4 100644 --- a/Helper/TableStyle.php +++ b/Helper/TableStyle.php @@ -30,7 +30,7 @@ class TableStyle private $cellRowFormat = '%s'; private $cellRowContentFormat = ' %s '; private $borderFormat = '%s'; - private $padType = STR_PAD_RIGHT; + private $padType = \STR_PAD_RIGHT; /** * Sets padding character, used for cell padding. @@ -237,7 +237,7 @@ public function getBorderFormat() */ public function setPadType($padType) { - if (!\in_array($padType, [STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH], true)) { + if (!\in_array($padType, [\STR_PAD_LEFT, \STR_PAD_RIGHT, \STR_PAD_BOTH], true)) { throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).'); } diff --git a/Input/InputDefinition.php b/Input/InputDefinition.php index 53f41d73f..d953f9bba 100644 --- a/Input/InputDefinition.php +++ b/Input/InputDefinition.php @@ -171,7 +171,7 @@ public function getArguments() */ public function getArgumentCount() { - return $this->hasAnArrayArgument ? PHP_INT_MAX : \count($this->arguments); + return $this->hasAnArrayArgument ? \PHP_INT_MAX : \count($this->arguments); } /** diff --git a/Output/BufferedOutput.php b/Output/BufferedOutput.php index 8afc8931e..fefaac271 100644 --- a/Output/BufferedOutput.php +++ b/Output/BufferedOutput.php @@ -39,7 +39,7 @@ protected function doWrite($message, $newline) $this->buffer .= $message; if ($newline) { - $this->buffer .= PHP_EOL; + $this->buffer .= \PHP_EOL; } } } diff --git a/Output/ConsoleOutput.php b/Output/ConsoleOutput.php index 61dc7cbdc..21a108fca 100644 --- a/Output/ConsoleOutput.php +++ b/Output/ConsoleOutput.php @@ -124,7 +124,7 @@ private function isRunningOS400() $checks = [ \function_exists('php_uname') ? php_uname('s') : '', getenv('OSTYPE'), - PHP_OS, + \PHP_OS, ]; return false !== stripos(implode(';', $checks), 'OS400'); diff --git a/Output/StreamOutput.php b/Output/StreamOutput.php index 74b9b54e8..451051df8 100644 --- a/Output/StreamOutput.php +++ b/Output/StreamOutput.php @@ -70,7 +70,7 @@ public function getStream() protected function doWrite($message, $newline) { if ($newline) { - $message .= PHP_EOL; + $message .= \PHP_EOL; } @fwrite($this->stream, $message); diff --git a/Style/OutputStyle.php b/Style/OutputStyle.php index b1262b55d..14d2d60b2 100644 --- a/Style/OutputStyle.php +++ b/Style/OutputStyle.php @@ -35,7 +35,7 @@ public function __construct(OutputInterface $output) */ public function newLine($count = 1) { - $this->output->write(str_repeat(PHP_EOL, $count)); + $this->output->write(str_repeat(\PHP_EOL, $count)); } /** diff --git a/Style/SymfonyStyle.php b/Style/SymfonyStyle.php index 02e9b471b..4d83779c5 100644 --- a/Style/SymfonyStyle.php +++ b/Style/SymfonyStyle.php @@ -352,7 +352,7 @@ private function getProgressBar() private function autoPrependBlock() { - $chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2); + $chars = substr(str_replace(\PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2); if (!isset($chars[0])) { $this->newLine(); //empty history, so we should start with a new line. @@ -399,7 +399,7 @@ private function createBlock($messages, $type = null, $style = null, $prefix = ' $message = OutputFormatter::escape($message); } - $lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, PHP_EOL, true))); + $lines = array_merge($lines, explode(\PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, \PHP_EOL, true))); if (\count($messages) > 1 && $key < \count($messages) - 1) { $lines[] = ''; diff --git a/Tester/ApplicationTester.php b/Tester/ApplicationTester.php index dc970182e..355b07b16 100644 --- a/Tester/ApplicationTester.php +++ b/Tester/ApplicationTester.php @@ -114,7 +114,7 @@ public function getDisplay($normalize = false) $display = stream_get_contents($this->output->getStream()); if ($normalize) { - $display = str_replace(PHP_EOL, "\n", $display); + $display = str_replace(\PHP_EOL, "\n", $display); } return $display; @@ -138,7 +138,7 @@ public function getErrorOutput($normalize = false) $display = stream_get_contents($this->output->getErrorOutput()->getStream()); if ($normalize) { - $display = str_replace(PHP_EOL, "\n", $display); + $display = str_replace(\PHP_EOL, "\n", $display); } return $display; diff --git a/Tester/CommandTester.php b/Tester/CommandTester.php index a1d8ad70a..122989488 100644 --- a/Tester/CommandTester.php +++ b/Tester/CommandTester.php @@ -96,7 +96,7 @@ public function getDisplay($normalize = false) $display = stream_get_contents($this->output->getStream()); if ($normalize) { - $display = str_replace(PHP_EOL, "\n", $display); + $display = str_replace(\PHP_EOL, "\n", $display); } return $display; @@ -152,7 +152,7 @@ private static function createStream(array $inputs) $stream = fopen('php://memory', 'r+', false); foreach ($inputs as $input) { - fwrite($stream, $input.PHP_EOL); + fwrite($stream, $input.\PHP_EOL); } rewind($stream); diff --git a/Tests/ApplicationTest.php b/Tests/ApplicationTest.php index 212379a7c..16d856c46 100644 --- a/Tests/ApplicationTest.php +++ b/Tests/ApplicationTest.php @@ -79,7 +79,7 @@ public static function setUpBeforeClass() protected function normalizeLineBreaks($text) { - return str_replace(PHP_EOL, "\n", $text); + return str_replace(\PHP_EOL, "\n", $text); } /** @@ -902,10 +902,10 @@ public function testRun() $tester = new ApplicationTester($application); $tester->run(['command' => 'foo:bar', '--no-interaction' => true], ['decorated' => false]); - $this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if --no-interaction is passed'); + $this->assertSame('called'.\PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if --no-interaction is passed'); $tester->run(['command' => 'foo:bar', '-n' => true], ['decorated' => false]); - $this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed'); + $this->assertSame('called'.\PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed'); } public function testRunWithGlobalOptionAndNoCommand() @@ -1202,7 +1202,7 @@ public function testRunWithDispatcher() $tester = new ApplicationTester($application); $tester->run(['command' => 'foo']); - $this->assertEquals('before.foo.after.'.PHP_EOL, $tester->getDisplay()); + $this->assertEquals('before.foo.after.'.\PHP_EOL, $tester->getDisplay()); } public function testRunWithExceptionAndDispatcher() @@ -1546,7 +1546,7 @@ public function testSetRunCustomDefaultCommand() $tester = new ApplicationTester($application); $tester->run([], ['interactive' => false]); - $this->assertEquals('called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); + $this->assertEquals('called'.\PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); $application = new CustomDefaultCommandApplication(); $application->setAutoExit(false); @@ -1554,7 +1554,7 @@ public function testSetRunCustomDefaultCommand() $tester = new ApplicationTester($application); $tester->run([], ['interactive' => false]); - $this->assertEquals('called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); + $this->assertEquals('called'.\PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); } public function testSetRunCustomDefaultCommandWithOption() @@ -1569,7 +1569,7 @@ public function testSetRunCustomDefaultCommandWithOption() $tester = new ApplicationTester($application); $tester->run(['--fooopt' => 'opt'], ['interactive' => false]); - $this->assertEquals('called'.PHP_EOL.'opt'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); + $this->assertEquals('called'.\PHP_EOL.'opt'.\PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); } public function testSetRunCustomSingleCommand() diff --git a/Tests/Command/CommandTest.php b/Tests/Command/CommandTest.php index 207302fdf..7421c09db 100644 --- a/Tests/Command/CommandTest.php +++ b/Tests/Command/CommandTest.php @@ -271,7 +271,7 @@ public function testRunInteractive() $tester->execute([], ['interactive' => true]); - $this->assertEquals('interact called'.PHP_EOL.'execute called'.PHP_EOL, $tester->getDisplay(), '->run() calls the interact() method if the input is interactive'); + $this->assertEquals('interact called'.\PHP_EOL.'execute called'.\PHP_EOL, $tester->getDisplay(), '->run() calls the interact() method if the input is interactive'); } public function testRunNonInteractive() @@ -280,7 +280,7 @@ public function testRunNonInteractive() $tester->execute([], ['interactive' => false]); - $this->assertEquals('execute called'.PHP_EOL, $tester->getDisplay(), '->run() does not call the interact() method if the input is not interactive'); + $this->assertEquals('execute called'.\PHP_EOL, $tester->getDisplay(), '->run() does not call the interact() method if the input is not interactive'); } public function testExecuteMethodNeedsToBeOverridden() @@ -337,7 +337,7 @@ public function testRunWithProcessTitle() $command->setProcessTitle('foo'); $this->assertSame(0, $command->run(new StringInput(''), new NullOutput())); if (\function_exists('cli_set_process_title')) { - if (null === @cli_get_process_title() && 'Darwin' === PHP_OS) { + if (null === @cli_get_process_title() && 'Darwin' === \PHP_OS) { $this->markTestSkipped('Running "cli_get_process_title" as an unprivileged user is not supported on MacOS.'); } $this->assertEquals('foo', cli_get_process_title()); @@ -353,7 +353,7 @@ public function testSetCode() $this->assertEquals($command, $ret, '->setCode() implements a fluent interface'); $tester = new CommandTester($command); $tester->execute([]); - $this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay()); + $this->assertEquals('interact called'.\PHP_EOL.'from the code...'.\PHP_EOL, $tester->getDisplay()); } public function getSetCodeBindToClosureTests() @@ -378,7 +378,7 @@ public function testSetCodeBindToClosure($previouslyBound, $expected) $command->setCode($code); $tester = new CommandTester($command); $tester->execute([]); - $this->assertEquals('interact called'.PHP_EOL.$expected.PHP_EOL, $tester->getDisplay()); + $this->assertEquals('interact called'.\PHP_EOL.$expected.\PHP_EOL, $tester->getDisplay()); } public function testSetCodeWithStaticClosure() @@ -390,10 +390,10 @@ public function testSetCodeWithStaticClosure() if (\PHP_VERSION_ID < 70000) { // Cannot bind static closures in PHP 5 - $this->assertEquals('interact called'.PHP_EOL.'not bound'.PHP_EOL, $tester->getDisplay()); + $this->assertEquals('interact called'.\PHP_EOL.'not bound'.\PHP_EOL, $tester->getDisplay()); } else { // Can bind static closures in PHP 7 - $this->assertEquals('interact called'.PHP_EOL.'bound'.PHP_EOL, $tester->getDisplay()); + $this->assertEquals('interact called'.\PHP_EOL.'bound'.\PHP_EOL, $tester->getDisplay()); } } @@ -411,7 +411,7 @@ public function testSetCodeWithNonClosureCallable() $this->assertEquals($command, $ret, '->setCode() implements a fluent interface'); $tester = new CommandTester($command); $tester->execute([]); - $this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay()); + $this->assertEquals('interact called'.\PHP_EOL.'from the code...'.\PHP_EOL, $tester->getDisplay()); } public function callableMethodCommand(InputInterface $input, OutputInterface $output) diff --git a/Tests/Descriptor/AbstractDescriptorTest.php b/Tests/Descriptor/AbstractDescriptorTest.php index 320a4fb9f..5d9257fbe 100644 --- a/Tests/Descriptor/AbstractDescriptorTest.php +++ b/Tests/Descriptor/AbstractDescriptorTest.php @@ -102,6 +102,6 @@ protected function assertDescription($expectedDescription, $describedObject, arr { $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true); $this->getDescriptor()->describe($output, $describedObject, $options + ['raw_output' => true]); - $this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $output->fetch()))); + $this->assertEquals(trim($expectedDescription), trim(str_replace(\PHP_EOL, "\n", $output->fetch()))); } } diff --git a/Tests/Descriptor/JsonDescriptorTest.php b/Tests/Descriptor/JsonDescriptorTest.php index fb596b8d7..d3f962fea 100644 --- a/Tests/Descriptor/JsonDescriptorTest.php +++ b/Tests/Descriptor/JsonDescriptorTest.php @@ -30,6 +30,6 @@ protected function assertDescription($expectedDescription, $describedObject, arr { $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true); $this->getDescriptor()->describe($output, $describedObject, $options + ['raw_output' => true]); - $this->assertEquals(json_decode(trim($expectedDescription), true), json_decode(trim(str_replace(PHP_EOL, "\n", $output->fetch())), true)); + $this->assertEquals(json_decode(trim($expectedDescription), true), json_decode(trim(str_replace(\PHP_EOL, "\n", $output->fetch())), true)); } } diff --git a/Tests/Descriptor/ObjectsProvider.php b/Tests/Descriptor/ObjectsProvider.php index d46d6f18b..ccd4c3b07 100644 --- a/Tests/Descriptor/ObjectsProvider.php +++ b/Tests/Descriptor/ObjectsProvider.php @@ -32,7 +32,7 @@ public static function getInputArguments() 'input_argument_3' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', 'default_value'), 'input_argument_4' => new InputArgument('argument_name', InputArgument::REQUIRED, "multiline\nargument description"), 'input_argument_with_style' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', 'style'), - 'input_argument_with_default_inf_value' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', INF), + 'input_argument_with_default_inf_value' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', \INF), ]; } @@ -47,7 +47,7 @@ public static function getInputOptions() 'input_option_6' => new InputOption('option_name', ['o', 'O'], InputOption::VALUE_REQUIRED, 'option with multiple shortcuts'), 'input_option_with_style' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, 'option description', 'style'), 'input_option_with_style_array' => new InputOption('option_name', 'o', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'option description', ['Hello', 'world']), - 'input_option_with_default_inf_value' => new InputOption('option_name', 'o', InputOption::VALUE_OPTIONAL, 'option description', INF), + 'input_option_with_default_inf_value' => new InputOption('option_name', 'o', InputOption::VALUE_OPTIONAL, 'option description', \INF), ]; } diff --git a/Tests/Helper/ProcessHelperTest.php b/Tests/Helper/ProcessHelperTest.php index 044c690d6..a765947f8 100644 --- a/Tests/Helper/ProcessHelperTest.php +++ b/Tests/Helper/ProcessHelperTest.php @@ -96,9 +96,9 @@ public function provideCommandsAndOutput() ['', 'php -r "syntax error"', StreamOutput::VERBOSITY_VERBOSE, null], [$syntaxErrorOutputVerbose, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERY_VERBOSE, null], [$syntaxErrorOutputDebug, 'php -r "fwrite(STDERR, \'error message\');usleep(500000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, null], - [$errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERBOSE, $errorMessage], - [$syntaxErrorOutputVerbose.$errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERY_VERBOSE, $errorMessage], - [$syntaxErrorOutputDebug.$errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(500000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, $errorMessage], + [$errorMessage.\PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERBOSE, $errorMessage], + [$syntaxErrorOutputVerbose.$errorMessage.\PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERY_VERBOSE, $errorMessage], + [$syntaxErrorOutputDebug.$errorMessage.\PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(500000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, $errorMessage], [$successOutputProcessDebug, ['php', '-r', 'echo 42;'], StreamOutput::VERBOSITY_DEBUG, null], [$successOutputDebug, new Process('php -r "echo 42;"'), StreamOutput::VERBOSITY_DEBUG, null], ]; diff --git a/Tests/Helper/ProgressBarTest.php b/Tests/Helper/ProgressBarTest.php index a0be9b8a6..e35cd9023 100644 --- a/Tests/Helper/ProgressBarTest.php +++ b/Tests/Helper/ProgressBarTest.php @@ -477,16 +477,16 @@ public function testNonDecoratedOutput() rewind($output->getStream()); $this->assertEquals( - ' 0/200 [>---------------------------] 0%'.PHP_EOL. - ' 20/200 [==>-------------------------] 10%'.PHP_EOL. - ' 40/200 [=====>----------------------] 20%'.PHP_EOL. - ' 60/200 [========>-------------------] 30%'.PHP_EOL. - ' 80/200 [===========>----------------] 40%'.PHP_EOL. - ' 100/200 [==============>-------------] 50%'.PHP_EOL. - ' 120/200 [================>-----------] 60%'.PHP_EOL. - ' 140/200 [===================>--------] 70%'.PHP_EOL. - ' 160/200 [======================>-----] 80%'.PHP_EOL. - ' 180/200 [=========================>--] 90%'.PHP_EOL. + ' 0/200 [>---------------------------] 0%'.\PHP_EOL. + ' 20/200 [==>-------------------------] 10%'.\PHP_EOL. + ' 40/200 [=====>----------------------] 20%'.\PHP_EOL. + ' 60/200 [========>-------------------] 30%'.\PHP_EOL. + ' 80/200 [===========>----------------] 40%'.\PHP_EOL. + ' 100/200 [==============>-------------] 50%'.\PHP_EOL. + ' 120/200 [================>-----------] 60%'.\PHP_EOL. + ' 140/200 [===================>--------] 70%'.\PHP_EOL. + ' 160/200 [======================>-----] 80%'.\PHP_EOL. + ' 180/200 [=========================>--] 90%'.\PHP_EOL. ' 200/200 [============================] 100%', stream_get_contents($output->getStream()) ); @@ -503,8 +503,8 @@ public function testNonDecoratedOutputWithClear() rewind($output->getStream()); $this->assertEquals( - ' 0/50 [>---------------------------] 0%'.PHP_EOL. - ' 25/50 [==============>-------------] 50%'.PHP_EOL. + ' 0/50 [>---------------------------] 0%'.\PHP_EOL. + ' 25/50 [==============>-------------] 50%'.\PHP_EOL. ' 50/50 [============================] 100%', stream_get_contents($output->getStream()) ); @@ -518,7 +518,7 @@ public function testNonDecoratedOutputWithoutMax() rewind($output->getStream()); $this->assertEquals( - ' 0 [>---------------------------]'.PHP_EOL. + ' 0 [>---------------------------]'.\PHP_EOL. ' 1 [->--------------------------]', stream_get_contents($output->getStream()) ); diff --git a/Tests/Helper/ProgressIndicatorTest.php b/Tests/Helper/ProgressIndicatorTest.php index 1428cf5e9..5ae2bc6b0 100644 --- a/Tests/Helper/ProgressIndicatorTest.php +++ b/Tests/Helper/ProgressIndicatorTest.php @@ -46,11 +46,11 @@ public function testDefaultIndicator() $this->generateOutput(' \\ Advancing...'). $this->generateOutput(' | Advancing...'). $this->generateOutput(' | Done...'). - PHP_EOL. + \PHP_EOL. $this->generateOutput(' - Starting Again...'). $this->generateOutput(' \\ Starting Again...'). $this->generateOutput(' \\ Done Again...'). - PHP_EOL, + \PHP_EOL, stream_get_contents($output->getStream()) ); } @@ -70,9 +70,9 @@ public function testNonDecoratedOutput() rewind($output->getStream()); $this->assertEquals( - ' Starting...'.PHP_EOL. - ' Midway...'.PHP_EOL. - ' Done...'.PHP_EOL.PHP_EOL, + ' Starting...'.\PHP_EOL. + ' Midway...'.\PHP_EOL. + ' Done...'.\PHP_EOL.\PHP_EOL, stream_get_contents($output->getStream()) ); } diff --git a/Tests/Helper/SymfonyQuestionHelperTest.php b/Tests/Helper/SymfonyQuestionHelperTest.php index 467f38b6d..06f20e2b1 100644 --- a/Tests/Helper/SymfonyQuestionHelperTest.php +++ b/Tests/Helper/SymfonyQuestionHelperTest.php @@ -206,7 +206,7 @@ private function assertOutputContains($expected, StreamOutput $output, $normaliz $stream = stream_get_contents($output->getStream()); if ($normalize) { - $stream = str_replace(PHP_EOL, "\n", $stream); + $stream = str_replace(\PHP_EOL, "\n", $stream); } $this->assertStringContainsString($expected, $stream); diff --git a/Tests/Helper/TableTest.php b/Tests/Helper/TableTest.php index 7e2bd8101..54bb4378c 100644 --- a/Tests/Helper/TableTest.php +++ b/Tests/Helper/TableTest.php @@ -707,7 +707,7 @@ public function testColumnStyle() ]); $style = new TableStyle(); - $style->setPadType(STR_PAD_LEFT); + $style->setPadType(\STR_PAD_LEFT); $table->setColumnStyle(3, $style); $table->render(); @@ -753,7 +753,7 @@ public function testColumnWidth() ->setColumnWidth(3, 10); $style = new TableStyle(); - $style->setPadType(STR_PAD_LEFT); + $style->setPadType(\STR_PAD_LEFT); $table->setColumnStyle(3, $style); $table->render(); @@ -784,7 +784,7 @@ public function testColumnWidths() ->setColumnWidths([15, 0, -1, 10]); $style = new TableStyle(); - $style->setPadType(STR_PAD_LEFT); + $style->setPadType(\STR_PAD_LEFT); $table->setColumnStyle(3, $style); $table->render(); @@ -863,6 +863,6 @@ protected function getOutputContent(StreamOutput $output) { rewind($output->getStream()); - return str_replace(PHP_EOL, "\n", stream_get_contents($output->getStream())); + return str_replace(\PHP_EOL, "\n", stream_get_contents($output->getStream())); } } diff --git a/Tests/Logger/ConsoleLoggerTest.php b/Tests/Logger/ConsoleLoggerTest.php index f1bbb61c5..54546e4f5 100644 --- a/Tests/Logger/ConsoleLoggerTest.php +++ b/Tests/Logger/ConsoleLoggerTest.php @@ -70,7 +70,7 @@ public function testOutputMapping($logLevel, $outputVerbosity, $isOutput, $addVe $logger = new ConsoleLogger($out, $addVerbosityLevelMap); $logger->log($logLevel, 'foo bar'); $logs = $out->fetch(); - $this->assertEquals($isOutput ? "[$logLevel] foo bar".PHP_EOL : '', $logs); + $this->assertEquals($isOutput ? "[$logLevel] foo bar".\PHP_EOL : '', $logs); } public function provideOutputMappingParams() diff --git a/Tests/Output/StreamOutputTest.php b/Tests/Output/StreamOutputTest.php index 86d503806..ad9eef1ae 100644 --- a/Tests/Output/StreamOutputTest.php +++ b/Tests/Output/StreamOutputTest.php @@ -54,7 +54,7 @@ public function testDoWrite() $output = new StreamOutput($this->stream); $output->writeln('foo'); rewind($output->getStream()); - $this->assertEquals('foo'.PHP_EOL, stream_get_contents($output->getStream()), '->doWrite() writes to the stream'); + $this->assertEquals('foo'.\PHP_EOL, stream_get_contents($output->getStream()), '->doWrite() writes to the stream'); } public function testDoWriteOnFailure() diff --git a/Tests/Tester/ApplicationTesterTest.php b/Tests/Tester/ApplicationTesterTest.php index 74c356200..9011706cd 100644 --- a/Tests/Tester/ApplicationTesterTest.php +++ b/Tests/Tester/ApplicationTesterTest.php @@ -55,12 +55,12 @@ public function testGetInput() public function testGetOutput() { rewind($this->tester->getOutput()->getStream()); - $this->assertEquals('foo'.PHP_EOL, stream_get_contents($this->tester->getOutput()->getStream()), '->getOutput() returns the current output instance'); + $this->assertEquals('foo'.\PHP_EOL, stream_get_contents($this->tester->getOutput()->getStream()), '->getOutput() returns the current output instance'); } public function testGetDisplay() { - $this->assertEquals('foo'.PHP_EOL, $this->tester->getDisplay(), '->getDisplay() returns the display of the last execution'); + $this->assertEquals('foo'.\PHP_EOL, $this->tester->getDisplay(), '->getDisplay() returns the display of the last execution'); } public function testGetStatusCode() diff --git a/Tests/Tester/CommandTesterTest.php b/Tests/Tester/CommandTesterTest.php index 1fa829236..1a9226e18 100644 --- a/Tests/Tester/CommandTesterTest.php +++ b/Tests/Tester/CommandTesterTest.php @@ -59,12 +59,12 @@ public function testGetInput() public function testGetOutput() { rewind($this->tester->getOutput()->getStream()); - $this->assertEquals('foo'.PHP_EOL, stream_get_contents($this->tester->getOutput()->getStream()), '->getOutput() returns the current output instance'); + $this->assertEquals('foo'.\PHP_EOL, stream_get_contents($this->tester->getOutput()->getStream()), '->getOutput() returns the current output instance'); } public function testGetDisplay() { - $this->assertEquals('foo'.PHP_EOL, $this->tester->getDisplay(), '->getDisplay() returns the display of the last execution'); + $this->assertEquals('foo'.\PHP_EOL, $this->tester->getDisplay(), '->getDisplay() returns the display of the last execution'); } public function testGetStatusCode() From 5e2200bcd5a7b758799fe58ae330f198a47c7c9b Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 6 Sep 2020 21:31:28 +0200 Subject: [PATCH 2/7] [Console] Make sure $maxAttempts is an int or null. --- Question/Question.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Question/Question.php b/Question/Question.php index 06464e135..7d016ecea 100644 --- a/Question/Question.php +++ b/Question/Question.php @@ -188,8 +188,11 @@ public function getValidator() */ public function setMaxAttempts($attempts) { - if (null !== $attempts && $attempts < 1) { - throw new InvalidArgumentException('Maximum number of attempts must be a positive value.'); + if (null !== $attempts) { + $attempts = (int) $attempts; + if ($attempts < 1) { + throw new InvalidArgumentException('Maximum number of attempts must be a positive value.'); + } } $this->attempts = $attempts; From c2a6c76511df3c2d5f334a90fe4d4dda91272ab8 Mon Sep 17 00:00:00 2001 From: bilogic Date: Wed, 9 Sep 2020 00:09:14 +0800 Subject: [PATCH 3/7] guard $argv + $token against null, preventing unnecessary exceptions --- Input/ArgvInput.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Input/ArgvInput.php b/Input/ArgvInput.php index b0c167d69..7f5432387 100644 --- a/Input/ArgvInput.php +++ b/Input/ArgvInput.php @@ -49,9 +49,7 @@ class ArgvInput extends Input */ public function __construct(array $argv = null, InputDefinition $definition = null) { - if (null === $argv) { - $argv = $_SERVER['argv']; - } + $argv = $argv ?? $_SERVER['argv'] ?? []; // strip the application name array_shift($argv); From 714a4a3b8486930c8f011c1b774059ca4b392727 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Tue, 8 Sep 2020 23:46:32 +0200 Subject: [PATCH 4/7] [Console] Silence warnings on sapi_windows_cp_set() call --- Helper/QuestionHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Helper/QuestionHelper.php b/Helper/QuestionHelper.php index 15d4549da..ac6f2be49 100644 --- a/Helper/QuestionHelper.php +++ b/Helper/QuestionHelper.php @@ -160,7 +160,7 @@ private function doAsk(OutputInterface $output, Question $question) if (\function_exists('sapi_windows_cp_set')) { // Codepage used by cmd.exe on Windows to allow special characters (éàüñ). - sapi_windows_cp_set(1252); + @sapi_windows_cp_set(1252); } if (null === $autocomplete || !self::$stty || !Terminal::hasSttyAvailable()) { From b28996bc0a3b08914b2a8609163ec35b36b30685 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 9 Sep 2020 07:09:37 +0200 Subject: [PATCH 5/7] Fix tests on 5.6 --- Input/ArgvInput.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Input/ArgvInput.php b/Input/ArgvInput.php index 7f5432387..fb2b3584f 100644 --- a/Input/ArgvInput.php +++ b/Input/ArgvInput.php @@ -49,7 +49,7 @@ class ArgvInput extends Input */ public function __construct(array $argv = null, InputDefinition $definition = null) { - $argv = $argv ?? $_SERVER['argv'] ?? []; + $argv = null !== $argv ? $argv : (isset($_SERVER['argv']) ? $_SERVER['argv'] : []); // strip the application name array_shift($argv); From 37746b24cd2979a43dfbabddef19eada2f40c59a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 9 Sep 2020 07:14:52 +0200 Subject: [PATCH 6/7] Simplify code --- Input/ArgvInput.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Input/ArgvInput.php b/Input/ArgvInput.php index 4dbb0468c..6d2946926 100644 --- a/Input/ArgvInput.php +++ b/Input/ArgvInput.php @@ -48,7 +48,7 @@ class ArgvInput extends Input */ public function __construct(array $argv = null, InputDefinition $definition = null) { - $argv = null !== $argv ? $argv : (isset($_SERVER['argv']) ? $_SERVER['argv'] : []); + $argv = $argv ?? $_SERVER['argv'] ?? []; // strip the application name array_shift($argv); From 90933b39c7b312fc3ceaa1ddeac7eb48cb953124 Mon Sep 17 00:00:00 2001 From: SenTisso <38100632+SenTisso@users.noreply.github.com> Date: Sat, 12 Sep 2020 17:15:36 +0200 Subject: [PATCH 7/7] [Console] work around disabled putenv() --- Application.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Application.php b/Application.php index da5c98756..bc3f23b5e 100644 --- a/Application.php +++ b/Application.php @@ -114,8 +114,10 @@ public function setCommandLoader(CommandLoaderInterface $commandLoader) */ public function run(InputInterface $input = null, OutputInterface $output = null) { - putenv('LINES='.$this->terminal->getHeight()); - putenv('COLUMNS='.$this->terminal->getWidth()); + if (\function_exists('putenv')) { + @putenv('LINES='.$this->terminal->getHeight()); + @putenv('COLUMNS='.$this->terminal->getWidth()); + } if (null === $input) { $input = new ArgvInput(); @@ -980,7 +982,9 @@ protected function configureIO(InputInterface $input, OutputInterface $output) $input->setInteractive(false); } - putenv('SHELL_VERBOSITY='.$shellVerbosity); + if (\function_exists('putenv')) { + @putenv('SHELL_VERBOSITY='.$shellVerbosity); + } $_ENV['SHELL_VERBOSITY'] = $shellVerbosity; $_SERVER['SHELL_VERBOSITY'] = $shellVerbosity; }