Skip to content

Commit dd586a4

Browse files
Replace STDIN by php://stdin
1 parent 55724bf commit dd586a4

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

Command/LintCommand.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
8181
$showDeprecations = $input->getOption('show-deprecations');
8282

8383
if (['-'] === $filenames) {
84-
return $this->display($input, $output, $io, [$this->validate($this->getStdin(), uniqid('sf_', true))]);
84+
return $this->display($input, $output, $io, [$this->validate(file_get_contents('php://stdin'), uniqid('sf_', true))]);
8585
}
8686

8787
if (!$filenames) {
8888
// @deprecated to be removed in 5.0
8989
if (0 === ftell(STDIN)) {
9090
@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);
9191

92-
return $this->display($input, $output, $io, [$this->validate($this->getStdin(), uniqid('sf_', true))]);
92+
return $this->display($input, $output, $io, [$this->validate(file_get_contents('php://stdin'), uniqid('sf_', true))]);
9393
}
9494

9595
$loader = $this->twig->getLoader();
@@ -132,16 +132,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
132132
return $this->display($input, $output, $io, $filesInfo);
133133
}
134134

135-
private function getStdin(): string
136-
{
137-
$template = '';
138-
while (!feof(STDIN)) {
139-
$template .= fread(STDIN, 1024);
140-
}
141-
142-
return $template;
143-
}
144-
145135
private function getFilesInfo(array $filenames): array
146136
{
147137
$filesInfo = [];

0 commit comments

Comments
 (0)