Skip to content

Commit 8caed6e

Browse files
Replace STDIN by php://stdin
1 parent e108a60 commit 8caed6e

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
@@ -88,15 +88,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
8888
$flags = $input->getOption('parse-tags') ? Yaml::PARSE_CUSTOM_TAGS : 0;
8989

9090
if (['-'] === $filenames) {
91-
return $this->display($io, [$this->validate($this->getStdin(), $flags)]);
91+
return $this->display($io, [$this->validate(file_get_contents('php://stdin'), $flags)]);
9292
}
9393

9494
// @deprecated to be removed in 5.0
9595
if (!$filenames) {
9696
if (0 === ftell(STDIN)) {
9797
@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);
9898

99-
return $this->display($io, [$this->validate($this->getStdin(), $flags)]);
99+
return $this->display($io, [$this->validate(file_get_contents('php://stdin'), $flags)]);
100100
}
101101

102102
throw new RuntimeException('Please provide a filename or pipe file content to STDIN.');
@@ -215,16 +215,6 @@ private function getFiles(string $fileOrDirectory): iterable
215215
}
216216
}
217217

218-
private function getStdin(): string
219-
{
220-
$yaml = '';
221-
while (!feof(STDIN)) {
222-
$yaml .= fread(STDIN, 1024);
223-
}
224-
225-
return $yaml;
226-
}
227-
228218
private function getParser(): Parser
229219
{
230220
if (!$this->parser) {

0 commit comments

Comments
 (0)