Require exact match when reading from stdin with a dash

This commit is contained in:
Nicolas Grekas 2019-09-09 08:40:31 +02:00
parent 81ac674b61
commit 3d14b79dad
3 changed files with 6 additions and 6 deletions

View File

@ -77,9 +77,9 @@ EOF
{
$io = new SymfonyStyle($input, $output);
$filenames = $input->getArgument('filename');
$hasStdin = '-' === ($filenames[0] ?? '');
$hasStdin = ['-'] === $filenames;
if ($hasStdin || 0 === \count($filenames)) {
if ($hasStdin || !$filenames) {
if ($hasStdin || 0 === ftell(STDIN)) { // remove 0 === ftell(STDIN) check in 5.0
if (!$hasStdin) {
@trigger_error('Calling to the "lint:twig" command providing pipe file content to STDIN without passing the dash symbol "-" explicitly is deprecated since Symfony 4.4.', E_USER_DEPRECATED);

View File

@ -83,9 +83,9 @@ EOF
$filenames = (array) $input->getArgument('filename');
$this->format = $input->getOption('format');
$this->displayCorrectFiles = $output->isVerbose();
$hasStdin = '-' === ($filenames[0] ?? '');
$hasStdin = ['-'] === $filenames;
if ($hasStdin || 0 === \count($filenames)) {
if ($hasStdin || !$filenames) {
if (!$hasStdin && 0 !== ftell(STDIN)) { // remove 0 !== ftell(STDIN) check in 5.0
throw new RuntimeException('Please provide a filename or pipe file content to STDIN.');
}

View File

@ -86,9 +86,9 @@ EOF
$this->format = $input->getOption('format');
$this->displayCorrectFiles = $output->isVerbose();
$flags = $input->getOption('parse-tags') ? Yaml::PARSE_CUSTOM_TAGS : 0;
$hasStdin = '-' === ($filenames[0] ?? '');
$hasStdin = ['-'] === $filenames;
if ($hasStdin || 0 === \count($filenames)) {
if ($hasStdin || !$filenames) {
if (!$hasStdin && 0 !== ftell(STDIN)) { // remove 0 !== ftell(STDIN) check in 5.0
throw new RuntimeException('Please provide a filename or pipe file content to STDIN.');
}