diff --git a/Application.php b/Application.php index 81e8f9656..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(); @@ -719,7 +721,7 @@ public function find($name) $command = $this->get(reset($commands)); if ($command->isHidden()) { - @trigger_error(sprintf('Command "%s" is hidden, finding it using an abbreviation is deprecated since Symfony 4.4, use its full name instead.', $command->getName()), E_USER_DEPRECATED); + @trigger_error(sprintf('Command "%s" is hidden, finding it using an abbreviation is deprecated since Symfony 4.4, use its full name instead.', $command->getName()), \E_USER_DEPRECATED); } return $command; @@ -798,7 +800,7 @@ public static function getAbbreviations($names) */ public function renderException(\Exception $e, OutputInterface $output) { - @trigger_error(sprintf('The "%s::renderException()" method is deprecated since Symfony 4.4, use "renderThrowable()" instead.', __CLASS__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s::renderException()" method is deprecated since Symfony 4.4, use "renderThrowable()" instead.', __CLASS__), \E_USER_DEPRECATED); $output->writeln('', OutputInterface::VERBOSITY_QUIET); @@ -810,10 +812,10 @@ public function renderException(\Exception $e, OutputInterface $output) public function renderThrowable(\Throwable $e, OutputInterface $output): void { if (__CLASS__ !== static::class && __CLASS__ === (new \ReflectionMethod($this, 'renderThrowable'))->getDeclaringClass()->getName() && __CLASS__ !== (new \ReflectionMethod($this, 'renderException'))->getDeclaringClass()->getName()) { - @trigger_error(sprintf('The "%s::renderException()" method is deprecated since Symfony 4.4, use "renderThrowable()" instead.', __CLASS__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s::renderException()" method is deprecated since Symfony 4.4, use "renderThrowable()" instead.', __CLASS__), \E_USER_DEPRECATED); 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()); } $this->renderException($e, $output); @@ -841,7 +843,7 @@ private function finishRenderThrowableOrException(OutputInterface $output): void */ protected function doRenderException(\Exception $e, OutputInterface $output) { - @trigger_error(sprintf('The "%s::doRenderException()" method is deprecated since Symfony 4.4, use "doRenderThrowable()" instead.', __CLASS__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s::doRenderException()" method is deprecated since Symfony 4.4, use "doRenderThrowable()" instead.', __CLASS__), \E_USER_DEPRECATED); $this->doActuallyRenderThrowable($e, $output); } @@ -849,10 +851,10 @@ protected function doRenderException(\Exception $e, OutputInterface $output) protected function doRenderThrowable(\Throwable $e, OutputInterface $output): void { if (__CLASS__ !== static::class && __CLASS__ === (new \ReflectionMethod($this, 'doRenderThrowable'))->getDeclaringClass()->getName() && __CLASS__ !== (new \ReflectionMethod($this, 'doRenderException'))->getDeclaringClass()->getName()) { - @trigger_error(sprintf('The "%s::doRenderException()" method is deprecated since Symfony 4.4, use "doRenderThrowable()" instead.', __CLASS__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s::doRenderException()" method is deprecated since Symfony 4.4, use "doRenderThrowable()" instead.', __CLASS__), \E_USER_DEPRECATED); 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()); } $this->doRenderException($e, $output); @@ -881,7 +883,7 @@ private function doActuallyRenderThrowable(\Throwable $e, OutputInterface $outpu }, $message); } - $width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : PHP_INT_MAX; + $width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : \PHP_INT_MAX; $lines = []; foreach ('' !== $message ? preg_split('/\r?\n/', $message) : [] as $line) { foreach ($this->splitStringByWidth($line, $width - 4) as $line) { @@ -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; } @@ -1167,7 +1171,7 @@ private function findAlternatives(string $name, iterable $collection): array } $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 26a09fb8f..c2b1f4c7e 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); @@ -255,7 +255,7 @@ public function run(InputInterface $input, OutputInterface $output) $statusCode = $this->execute($input, $output); if (!\is_int($statusCode)) { - @trigger_error(sprintf('Return value of "%s::execute()" should always be of the type int since Symfony 4.4, %s returned.', static::class, \gettype($statusCode)), E_USER_DEPRECATED); + @trigger_error(sprintf('Return value of "%s::execute()" should always be of the type int since Symfony 4.4, %s returned.', static::class, \gettype($statusCode)), \E_USER_DEPRECATED); } } diff --git a/Descriptor/JsonDescriptor.php b/Descriptor/JsonDescriptor.php index 131fef1f1..5ba588ee9 100644 --- a/Descriptor/JsonDescriptor.php +++ b/Descriptor/JsonDescriptor.php @@ -107,7 +107,7 @@ private function getInputArgumentData(InputArgument $argument): array '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(), ]; } @@ -120,7 +120,7 @@ private function getInputOptionData(InputOption $option): array '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 bde620bfa..05a32443d 100644 --- a/Descriptor/TextDescriptor.php +++ b/Descriptor/TextDescriptor.php @@ -280,7 +280,7 @@ private function getCommandAliasesText(Command $command): string */ private function formatDefaultValue($default): string { - if (INF === $default) { + if (\INF === $default) { return 'INF'; } @@ -294,7 +294,7 @@ private function formatDefaultValue($default): string } } - 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/Formatter/OutputFormatter.php b/Formatter/OutputFormatter.php index 27b608585..5d52896ac 100644 --- a/Formatter/OutputFormatter.php +++ b/Formatter/OutputFormatter.php @@ -138,7 +138,7 @@ public function formatAndWrap(string $message, int $width) $output = ''; $tagRegex = '[a-z][^<>]*+'; $currentLineLength = 0; - 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 $string): ?OutputFormatterStyleInt return $this->styles[$string]; } - if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, PREG_SET_ORDER)) { + if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, \PREG_SET_ORDER)) { return null; } diff --git a/Helper/ProcessHelper.php b/Helper/ProcessHelper.php index f519919a7..d580357b9 100644 --- a/Helper/ProcessHelper.php +++ b/Helper/ProcessHelper.php @@ -53,7 +53,7 @@ public function run(OutputInterface $output, $cmd, $error = null, callable $call } if (!\is_array($cmd)) { - @trigger_error(sprintf('Passing a command as a string to "%s()" is deprecated since Symfony 4.2, pass it the command as an array of arguments instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('Passing a command as a string to "%s()" is deprecated since Symfony 4.2, pass it the command as an array of arguments instead.', __METHOD__), \E_USER_DEPRECATED); $cmd = [method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($cmd) : new Process($cmd)]; } diff --git a/Helper/ProgressBar.php b/Helper/ProgressBar.php index e4f0a9936..afabf7c52 100644 --- a/Helper/ProgressBar.php +++ b/Helper/ProgressBar.php @@ -454,7 +454,7 @@ private function overwrite(string $message): void } } } elseif ($this->step > 0) { - $message = PHP_EOL.$message; + $message = \PHP_EOL.$message; } $this->previousMessage = $originalMessage; @@ -525,7 +525,7 @@ private static function initPlaceholderFormatters(): array 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 eb4f21125..18a222db3 100644 --- a/Helper/QuestionHelper.php +++ b/Helper/QuestionHelper.php @@ -105,12 +105,12 @@ private function doAsk(OutputInterface $output, Question $question) { $this->writePrompt($output, $question); - $inputStream = $this->inputStream ?: STDIN; + $inputStream = $this->inputStream ?: \STDIN; $autocomplete = $question->getAutocompleterCallback(); 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()) { diff --git a/Helper/TableStyle.php b/Helper/TableStyle.php index 6166f11dc..a8df59b3a 100644 --- a/Helper/TableStyle.php +++ b/Helper/TableStyle.php @@ -46,7 +46,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. @@ -112,7 +112,7 @@ public function setHorizontalBorderChars(string $outside, string $inside = null) */ public function setHorizontalBorderChar($horizontalBorderChar) { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use setHorizontalBorderChars() instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use setHorizontalBorderChars() instead.', __METHOD__), \E_USER_DEPRECATED); return $this->setHorizontalBorderChars($horizontalBorderChar, $horizontalBorderChar); } @@ -126,7 +126,7 @@ public function setHorizontalBorderChar($horizontalBorderChar) */ public function getHorizontalBorderChar() { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use getBorderChars() instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use getBorderChars() instead.', __METHOD__), \E_USER_DEPRECATED); return $this->horizontalOutsideBorderChar; } @@ -168,7 +168,7 @@ public function setVerticalBorderChars(string $outside, string $inside = null): */ public function setVerticalBorderChar($verticalBorderChar) { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use setVerticalBorderChars() instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use setVerticalBorderChars() instead.', __METHOD__), \E_USER_DEPRECATED); return $this->setVerticalBorderChars($verticalBorderChar, $verticalBorderChar); } @@ -182,7 +182,7 @@ public function setVerticalBorderChar($verticalBorderChar) */ public function getVerticalBorderChar() { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use getBorderChars() instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use getBorderChars() instead.', __METHOD__), \E_USER_DEPRECATED); return $this->verticalOutsideBorderChar; } @@ -270,7 +270,7 @@ public function setDefaultCrossingChar(string $char): self */ public function setCrossingChar($crossingChar) { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1. Use setDefaultCrossingChar() instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1. Use setDefaultCrossingChar() instead.', __METHOD__), \E_USER_DEPRECATED); return $this->setDefaultCrossingChar($crossingChar); } @@ -413,7 +413,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/ArgvInput.php b/Input/ArgvInput.php index 3bc205553..6d2946926 100644 --- a/Input/ArgvInput.php +++ b/Input/ArgvInput.php @@ -48,9 +48,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); diff --git a/Input/InputDefinition.php b/Input/InputDefinition.php index 75a975213..db55315a8 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 9684ad67b..ff02f8694 100644 --- a/Output/ConsoleOutput.php +++ b/Output/ConsoleOutput.php @@ -131,7 +131,7 @@ private function isRunningOS400(): bool $checks = [ \function_exists('php_uname') ? php_uname('s') : '', getenv('OSTYPE'), - PHP_OS, + \PHP_OS, ]; return false !== stripos(implode(';', $checks), 'OS400'); diff --git a/Output/ConsoleSectionOutput.php b/Output/ConsoleSectionOutput.php index 024d99d96..c19edbf95 100644 --- a/Output/ConsoleSectionOutput.php +++ b/Output/ConsoleSectionOutput.php @@ -82,10 +82,10 @@ public function getContent(): string */ public function addContent(string $input) { - foreach (explode(PHP_EOL, $input) as $lineContent) { + foreach (explode(\PHP_EOL, $input) as $lineContent) { $this->lines += ceil($this->getDisplayLength($lineContent) / $this->terminal->getWidth()) ?: 1; $this->content[] = $lineContent; - $this->content[] = PHP_EOL; + $this->content[] = \PHP_EOL; } } diff --git a/Output/StreamOutput.php b/Output/StreamOutput.php index f39422a57..9c2243644 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/Question/Question.php b/Question/Question.php index c28e0bf55..2d46d1a98 100644 --- a/Question/Question.php +++ b/Question/Question.php @@ -220,8 +220,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; 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 5efe2d4b1..b40c16e99 100644 --- a/Style/SymfonyStyle.php +++ b/Style/SymfonyStyle.php @@ -427,7 +427,7 @@ private function getProgressBar(): ProgressBar private function autoPrependBlock(): void { - $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. @@ -472,7 +472,7 @@ private function createBlock(iterable $messages, string $type = null, string $st $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/TesterTrait.php b/Tester/TesterTrait.php index a5c2088ae..14b65ec00 100644 --- a/Tester/TesterTrait.php +++ b/Tester/TesterTrait.php @@ -44,7 +44,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; @@ -68,7 +68,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; @@ -170,7 +170,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 b3d33629d..c62ac5b3e 100644 --- a/Tests/ApplicationTest.php +++ b/Tests/ApplicationTest.php @@ -81,7 +81,7 @@ public static function setUpBeforeClass(): void protected function normalizeLineBreaks($text) { - return str_replace(PHP_EOL, "\n", $text); + return str_replace(\PHP_EOL, "\n", $text); } /** @@ -1026,10 +1026,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() @@ -1326,7 +1326,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() @@ -1610,7 +1610,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); @@ -1618,7 +1618,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() @@ -1633,7 +1633,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 c51a47c68..d82b0d03a 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() @@ -323,7 +323,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()); @@ -339,7 +339,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() @@ -364,7 +364,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() @@ -374,7 +374,7 @@ public function testSetCodeWithStaticClosure() $tester = new CommandTester($command); $tester->execute([]); - $this->assertEquals('interact called'.PHP_EOL.'bound'.PHP_EOL, $tester->getDisplay()); + $this->assertEquals('interact called'.\PHP_EOL.'bound'.\PHP_EOL, $tester->getDisplay()); } private static function createClosure() @@ -391,7 +391,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 82c6b4451..e2880f22f 100644 --- a/Tests/Helper/ProcessHelperTest.php +++ b/Tests/Helper/ProcessHelperTest.php @@ -109,9 +109,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, $fromShellCommandline('php -r "echo 42;"'), StreamOutput::VERBOSITY_DEBUG, null], [$successOutputProcessDebug, [new Process(['php', '-r', 'echo 42;'])], StreamOutput::VERBOSITY_DEBUG, null], diff --git a/Tests/Helper/ProgressBarTest.php b/Tests/Helper/ProgressBarTest.php index b9b63c7df..5804f9cd5 100644 --- a/Tests/Helper/ProgressBarTest.php +++ b/Tests/Helper/ProgressBarTest.php @@ -336,9 +336,9 @@ public function testOverwriteWithSectionOutput() rewind($output->getStream()); $this->assertEquals( - ' 0/50 [>---------------------------] 0%'.PHP_EOL. - "\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL. - "\x1b[1A\x1b[0J".' 2/50 [=>--------------------------] 4%'.PHP_EOL, + ' 0/50 [>---------------------------] 0%'.\PHP_EOL. + "\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.\PHP_EOL. + "\x1b[1A\x1b[0J".' 2/50 [=>--------------------------] 4%'.\PHP_EOL, stream_get_contents($output->getStream()) ); } @@ -362,12 +362,12 @@ public function testOverwriteMultipleProgressBarsWithSectionOutputs() rewind($stream->getStream()); $this->assertEquals( - ' 0/50 [>---------------------------] 0%'.PHP_EOL. - ' 0/50 [>---------------------------] 0%'.PHP_EOL. - "\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL. - "\x1b[2A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL. - "\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL. - ' 1/50 [>---------------------------] 2%'.PHP_EOL, + ' 0/50 [>---------------------------] 0%'.\PHP_EOL. + ' 0/50 [>---------------------------] 0%'.\PHP_EOL. + "\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.\PHP_EOL. + "\x1b[2A\x1b[0J".' 1/50 [>---------------------------] 2%'.\PHP_EOL. + "\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.\PHP_EOL. + ' 1/50 [>---------------------------] 2%'.\PHP_EOL, stream_get_contents($stream->getStream()) ); } @@ -393,12 +393,12 @@ public function testMultipleSectionsWithCustomFormat() rewind($stream->getStream()); - $this->assertEquals(' 0/50 [>---------------------------] 0%'.PHP_EOL. - ' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.PHP_EOL. - "\x1b[4A\x1b[0J".' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.PHP_EOL. - "\x1b[3A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL. - ' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.PHP_EOL. - "\x1b[3A\x1b[0J".' 1/50 [>] 2% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.PHP_EOL, + $this->assertEquals(' 0/50 [>---------------------------] 0%'.\PHP_EOL. + ' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.\PHP_EOL. + "\x1b[4A\x1b[0J".' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.\PHP_EOL. + "\x1b[3A\x1b[0J".' 1/50 [>---------------------------] 2%'.\PHP_EOL. + ' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.\PHP_EOL. + "\x1b[3A\x1b[0J".' 1/50 [>] 2% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.\PHP_EOL, stream_get_contents($stream->getStream()) ); } @@ -555,16 +555,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()) ); @@ -581,8 +581,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()) ); @@ -596,7 +596,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 4abb9706a..986646794 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 070b87b03..3616333ec 100644 --- a/Tests/Helper/TableTest.php +++ b/Tests/Helper/TableTest.php @@ -787,7 +787,7 @@ public function testColumnStyle() ]); $style = new TableStyle(); - $style->setPadType(STR_PAD_LEFT); + $style->setPadType(\STR_PAD_LEFT); $table->setColumnStyle(3, $style); $table->render(); @@ -833,7 +833,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(); @@ -864,7 +864,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(); @@ -1260,7 +1260,7 @@ 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())); } public function testWithColspanAndMaxWith(): void diff --git a/Tests/Logger/ConsoleLoggerTest.php b/Tests/Logger/ConsoleLoggerTest.php index 0f5884136..283eccaf2 100644 --- a/Tests/Logger/ConsoleLoggerTest.php +++ b/Tests/Logger/ConsoleLoggerTest.php @@ -67,7 +67,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/ConsoleSectionOutputTest.php b/Tests/Output/ConsoleSectionOutputTest.php index e8c65f9b2..6abe040b4 100644 --- a/Tests/Output/ConsoleSectionOutputTest.php +++ b/Tests/Output/ConsoleSectionOutputTest.php @@ -39,11 +39,11 @@ public function testClearAll() $sections = []; $output = new ConsoleSectionOutput($this->stream, $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter()); - $output->writeln('Foo'.PHP_EOL.'Bar'); + $output->writeln('Foo'.\PHP_EOL.'Bar'); $output->clear(); rewind($output->getStream()); - $this->assertEquals('Foo'.PHP_EOL.'Bar'.PHP_EOL.sprintf("\x1b[%dA", 2)."\x1b[0J", stream_get_contents($output->getStream())); + $this->assertEquals('Foo'.\PHP_EOL.'Bar'.\PHP_EOL.sprintf("\x1b[%dA", 2)."\x1b[0J", stream_get_contents($output->getStream())); } public function testClearNumberOfLines() @@ -55,7 +55,7 @@ public function testClearNumberOfLines() $output->clear(2); rewind($output->getStream()); - $this->assertEquals("Foo\nBar\nBaz\nFooBar".PHP_EOL.sprintf("\x1b[%dA", 2)."\x1b[0J", stream_get_contents($output->getStream())); + $this->assertEquals("Foo\nBar\nBaz\nFooBar".\PHP_EOL.sprintf("\x1b[%dA", 2)."\x1b[0J", stream_get_contents($output->getStream())); } public function testClearNumberOfLinesWithMultipleSections() @@ -72,7 +72,7 @@ public function testClearNumberOfLinesWithMultipleSections() rewind($output->getStream()); - $this->assertEquals('Foo'.PHP_EOL.'Bar'.PHP_EOL."\x1b[1A\x1b[0J\e[1A\e[0J".'Baz'.PHP_EOL.'Foo'.PHP_EOL, stream_get_contents($output->getStream())); + $this->assertEquals('Foo'.\PHP_EOL.'Bar'.\PHP_EOL."\x1b[1A\x1b[0J\e[1A\e[0J".'Baz'.\PHP_EOL.'Foo'.\PHP_EOL, stream_get_contents($output->getStream())); } public function testClearPreservingEmptyLines() @@ -82,13 +82,13 @@ public function testClearPreservingEmptyLines() $output1 = new ConsoleSectionOutput($output->getStream(), $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter()); $output2 = new ConsoleSectionOutput($output->getStream(), $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter()); - $output2->writeln(PHP_EOL.'foo'); + $output2->writeln(\PHP_EOL.'foo'); $output2->clear(1); $output1->writeln('bar'); rewind($output->getStream()); - $this->assertEquals(PHP_EOL.'foo'.PHP_EOL."\x1b[1A\x1b[0J\x1b[1A\x1b[0J".'bar'.PHP_EOL.PHP_EOL, stream_get_contents($output->getStream())); + $this->assertEquals(\PHP_EOL.'foo'.\PHP_EOL."\x1b[1A\x1b[0J\x1b[1A\x1b[0J".'bar'.\PHP_EOL.\PHP_EOL, stream_get_contents($output->getStream())); } public function testOverwrite() @@ -100,7 +100,7 @@ public function testOverwrite() $output->overwrite('Bar'); rewind($output->getStream()); - $this->assertEquals('Foo'.PHP_EOL."\x1b[1A\x1b[0JBar".PHP_EOL, stream_get_contents($output->getStream())); + $this->assertEquals('Foo'.\PHP_EOL."\x1b[1A\x1b[0JBar".\PHP_EOL, stream_get_contents($output->getStream())); } public function testOverwriteMultipleLines() @@ -108,11 +108,11 @@ public function testOverwriteMultipleLines() $sections = []; $output = new ConsoleSectionOutput($this->stream, $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter()); - $output->writeln('Foo'.PHP_EOL.'Bar'.PHP_EOL.'Baz'); + $output->writeln('Foo'.\PHP_EOL.'Bar'.\PHP_EOL.'Baz'); $output->overwrite('Bar'); rewind($output->getStream()); - $this->assertEquals('Foo'.PHP_EOL.'Bar'.PHP_EOL.'Baz'.PHP_EOL.sprintf("\x1b[%dA", 3)."\x1b[0J".'Bar'.PHP_EOL, stream_get_contents($output->getStream())); + $this->assertEquals('Foo'.\PHP_EOL.'Bar'.\PHP_EOL.'Baz'.\PHP_EOL.sprintf("\x1b[%dA", 3)."\x1b[0J".'Bar'.\PHP_EOL, stream_get_contents($output->getStream())); } public function testAddingMultipleSections() @@ -138,7 +138,7 @@ public function testMultipleSectionsOutput() $output2->overwrite('Foobar'); rewind($output->getStream()); - $this->assertEquals('Foo'.PHP_EOL.'Bar'.PHP_EOL."\x1b[2A\x1b[0JBar".PHP_EOL."\x1b[1A\x1b[0JBaz".PHP_EOL.'Bar'.PHP_EOL."\x1b[1A\x1b[0JFoobar".PHP_EOL, stream_get_contents($output->getStream())); + $this->assertEquals('Foo'.\PHP_EOL.'Bar'.\PHP_EOL."\x1b[2A\x1b[0JBar".\PHP_EOL."\x1b[1A\x1b[0JBaz".\PHP_EOL.'Bar'.\PHP_EOL."\x1b[1A\x1b[0JFoobar".\PHP_EOL, stream_get_contents($output->getStream())); } public function testClearSectionContainingQuestion() @@ -158,6 +158,6 @@ public function testClearSectionContainingQuestion() $output->clear(); rewind($output->getStream()); - $this->assertSame('What\'s your favorite super hero?'.PHP_EOL."\x1b[2A\x1b[0J", stream_get_contents($output->getStream())); + $this->assertSame('What\'s your favorite super hero?'.\PHP_EOL."\x1b[2A\x1b[0J", stream_get_contents($output->getStream())); } } diff --git a/Tests/Output/StreamOutputTest.php b/Tests/Output/StreamOutputTest.php index 8fa9dfd10..a434fead4 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 8361602dd..dabf00988 100644 --- a/Tests/Tester/ApplicationTesterTest.php +++ b/Tests/Tester/ApplicationTesterTest.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 testSetInputs() diff --git a/Tests/Tester/CommandTesterTest.php b/Tests/Tester/CommandTesterTest.php index d48126cbe..11a4bfaf4 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()