diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php index be49df5fdf..20db8c5de1 100644 --- a/src/Symfony/Bridge/Twig/Command/LintCommand.php +++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php @@ -81,7 +81,7 @@ EOF $showDeprecations = $input->getOption('show-deprecations'); if (['-'] === $filenames) { - return $this->display($input, $output, $io, [$this->validate($this->getStdin(), uniqid('sf_', true))]); + return $this->display($input, $output, $io, [$this->validate(file_get_contents('php://stdin'), uniqid('sf_', true))]); } if (!$filenames) { @@ -89,7 +89,7 @@ EOF if (0 === ftell(STDIN)) { @trigger_error('Piping content from STDIN to the "lint:twig" command without passing the dash symbol "-" as argument is deprecated since Symfony 4.4.', E_USER_DEPRECATED); - return $this->display($input, $output, $io, [$this->validate($this->getStdin(), uniqid('sf_', true))]); + return $this->display($input, $output, $io, [$this->validate(file_get_contents('php://stdin'), uniqid('sf_', true))]); } $loader = $this->twig->getLoader(); @@ -132,16 +132,6 @@ EOF return $this->display($input, $output, $io, $filesInfo); } - private function getStdin(): string - { - $template = ''; - while (!feof(STDIN)) { - $template .= fread(STDIN, 1024); - } - - return $template; - } - private function getFilesInfo(array $filenames): array { $filesInfo = []; diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index 80906db4ed..bba719b534 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -115,7 +115,7 @@ class QuestionHelper extends Helper { $this->writePrompt($output, $question); - $inputStream = $this->inputStream ?: STDIN; + $inputStream = $this->inputStream ?: fopen('php://stdin', 'r'); $autocomplete = $question->getAutocompleterCallback(); if (null === $autocomplete || !Terminal::hasSttyAvailable()) { diff --git a/src/Symfony/Component/Translation/Command/XliffLintCommand.php b/src/Symfony/Component/Translation/Command/XliffLintCommand.php index f078b55bbf..770a15e209 100644 --- a/src/Symfony/Component/Translation/Command/XliffLintCommand.php +++ b/src/Symfony/Component/Translation/Command/XliffLintCommand.php @@ -85,7 +85,7 @@ EOF $this->displayCorrectFiles = $output->isVerbose(); if (['-'] === $filenames) { - return $this->display($io, [$this->validate($this->getStdin())]); + return $this->display($io, [$this->validate(file_get_contents('php://stdin'))]); } // @deprecated to be removed in 5.0 @@ -96,7 +96,7 @@ EOF @trigger_error('Piping content from STDIN to the "lint:xliff" command without passing the dash symbol "-" as argument is deprecated since Symfony 4.4.', E_USER_DEPRECATED); - return $this->display($io, [$this->validate($this->getStdin())]); + return $this->display($io, [$this->validate(file_get_contents('php://stdin'))]); } $filesInfo = []; @@ -230,16 +230,6 @@ EOF } } - private function getStdin(): string - { - $xliff = ''; - while (!feof(STDIN)) { - $xliff .= fread(STDIN, 1024); - } - - return $xliff; - } - private function getDirectoryIterator(string $directory) { $default = function ($directory) { diff --git a/src/Symfony/Component/Yaml/Command/LintCommand.php b/src/Symfony/Component/Yaml/Command/LintCommand.php index d15ffb38c8..65ef531ffe 100644 --- a/src/Symfony/Component/Yaml/Command/LintCommand.php +++ b/src/Symfony/Component/Yaml/Command/LintCommand.php @@ -88,7 +88,7 @@ EOF $flags = $input->getOption('parse-tags') ? Yaml::PARSE_CUSTOM_TAGS : 0; if (['-'] === $filenames) { - return $this->display($io, [$this->validate($this->getStdin(), $flags)]); + return $this->display($io, [$this->validate(file_get_contents('php://stdin'), $flags)]); } // @deprecated to be removed in 5.0 @@ -96,7 +96,7 @@ EOF if (0 === ftell(STDIN)) { @trigger_error('Piping content from STDIN to the "lint:yaml" command without passing the dash symbol "-" as argument is deprecated since Symfony 4.4.', E_USER_DEPRECATED); - return $this->display($io, [$this->validate($this->getStdin(), $flags)]); + return $this->display($io, [$this->validate(file_get_contents('php://stdin'), $flags)]); } throw new RuntimeException('Please provide a filename or pipe file content to STDIN.'); @@ -215,16 +215,6 @@ EOF } } - private function getStdin(): string - { - $yaml = ''; - while (!feof(STDIN)) { - $yaml .= fread(STDIN, 1024); - } - - return $yaml; - } - private function getParser(): Parser { if (!$this->parser) {