Skip to content

Commit 0940ee9

Browse files
committed
Fix lint commands frozen on empty stdin
1 parent 40ff940 commit 0940ee9

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

Command/LintCommand.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected function configure()
6363
6464
You can validates YAML contents passed from STDIN:
6565
66-
<info>cat filename | php %command.full_name%</info>
66+
<info>cat filename | php %command.full_name% -</info>
6767
6868
You can also validate the syntax of a file:
6969
@@ -86,18 +86,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
8686
$this->format = $input->getOption('format');
8787
$this->displayCorrectFiles = $output->isVerbose();
8888
$flags = $input->getOption('parse-tags') ? Yaml::PARSE_CUSTOM_TAGS : 0;
89-
$hasStdin = ['-'] === $filenames;
9089

91-
if ($hasStdin || !$filenames) {
92-
if (!$hasStdin && 0 !== ftell(STDIN)) { // remove 0 !== ftell(STDIN) check in 5.0
93-
throw new RuntimeException('Please provide a filename or pipe file content to STDIN.');
94-
}
90+
if (['-'] === $filenames) {
91+
return $this->display($io, [$this->validate($this->getStdin(), $flags)]);
92+
}
9593

96-
if (!$hasStdin) {
97-
@trigger_error('Calling to the "lint:yaml" command providing pipe file content to STDIN without passing the dash symbol "-" explicitly is deprecated since Symfony 4.4.', E_USER_DEPRECATED);
94+
// @deprecated to be removed in 5.0
95+
if (!$filenames) {
96+
if (0 === ftell(STDIN)) {
97+
@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);
98+
99+
return $this->display($io, [$this->validate($this->getStdin(), $flags)]);
98100
}
99101

100-
return $this->display($io, [$this->validate($this->getStdin(), $flags)]);
102+
throw new RuntimeException('Please provide a filename or pipe file content to STDIN.');
101103
}
102104

103105
$filesInfo = [];

0 commit comments

Comments
 (0)