Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require exact match when reading from stdin with a dash #33511

Merged
merged 1 commit into from Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Twig/Command/LintCommand.php
Expand Up @@ -77,9 +77,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we trigger a deprecation warning here, or display a warning on STDERR ? I don't think CLI deprecations are visible to users properly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered the same in the original PR and deprecations are now displayed when using -vv. We used to call $io->caution() explicitly in 2.8, but I didn't find any usage in 3.4 anymore. Thus the current state.

Expand Down
Expand Up @@ -83,9 +83,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
$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.');
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Yaml/Command/LintCommand.php
Expand Up @@ -86,9 +86,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
$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.');
}
Expand Down