Skip to content

Commit

Permalink
minor #33509 Remove legacy code from STDIN commands (yceruto)
Browse files Browse the repository at this point in the history
This PR was merged into the 5.0-dev branch.

Discussion
----------

Remove legacy code from STDIN commands

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

See #33496

Commits
-------

1994ffe remove legacy code from STDIN commands
  • Loading branch information
fabpot committed Sep 9, 2019
2 parents 6b6562c + 1994ffe commit afe5188
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 32 deletions.
1 change: 1 addition & 0 deletions src/Symfony/Bridge/Twig/CHANGELOG.md
Expand Up @@ -7,6 +7,7 @@ CHANGELOG
* removed `TwigEngine` class, use `\Twig\Environment` instead.
* removed `transChoice` filter and token
* `HttpFoundationExtension` requires a `UrlHelper` on instantiation
* removed support for implicit STDIN usage in the `lint:twig` command, use `lint:twig -` (append a dash) instead to make it explicit.

4.4.0
-----
Expand Down
13 changes: 4 additions & 9 deletions src/Symfony/Bridge/Twig/Command/LintCommand.php
Expand Up @@ -77,17 +77,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$filenames = $input->getArgument('filename');
$hasStdin = '-' === ($filenames[0] ?? '');

if ($hasStdin || 0 === \count($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);
}

return $this->display($input, $output, $io, [$this->validate($this->getStdin(), uniqid('sf_', true))]);
}
if ('-' === ($filenames[0] ?? '')) {
return $this->display($input, $output, $io, [$this->validate($this->getStdin(), uniqid('sf_', true))]);
}

if (0 === \count($filenames)) {
$loader = $this->twig->getLoader();
if ($loader instanceof FilesystemLoader) {
$paths = [];
Expand Down
3 changes: 0 additions & 3 deletions src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php
Expand Up @@ -66,9 +66,6 @@ public function testLintFileCompileTimeException()
$this->assertRegExp('/ERROR in \S+ \(line /', trim($tester->getDisplay()));
}

/**
* @group tty
*/
public function testLintDefaultPaths()
{
$tester = $this->createCommandTester();
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/Translation/CHANGELOG.md
Expand Up @@ -14,6 +14,7 @@ CHANGELOG
* removed `FileDumper::setBackup()` and `TranslationWriter::disableBackup()`
* removed `MessageFormatter::choiceFormat()`
* added argument `$filename` to `PhpExtractor::parseTokens()`
* removed support for implicit STDIN usage in the `lint:xliff` command, use `lint:xliff -` (append a dash) instead to make it explicit.

4.4.0
-----
Expand Down
15 changes: 5 additions & 10 deletions src/Symfony/Component/Translation/Command/XliffLintCommand.php
Expand Up @@ -83,20 +83,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
$filenames = (array) $input->getArgument('filename');
$this->format = $input->getOption('format');
$this->displayCorrectFiles = $output->isVerbose();
$hasStdin = '-' === ($filenames[0] ?? '');

if ($hasStdin || 0 === \count($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.');
}

if (!$hasStdin) {
@trigger_error('Calling to the "lint:xliff" command providing pipe file content to STDIN without passing the dash symbol "-" explicitly is deprecated since Symfony 4.4.', E_USER_DEPRECATED);
}

if ('-' === ($filenames[0] ?? '')) {
return $this->display($io, [$this->validate($this->getStdin())]);
}

if (0 === \count($filenames)) {
throw new RuntimeException('Please provide a filename or pipe file content to STDIN.');
}

$filesInfo = [];
foreach ($filenames as $filename) {
if (!$this->isReadable($filename)) {
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/Yaml/CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@ CHANGELOG
-----

* Removed support for mappings inside multi-line strings.
* removed support for implicit STDIN usage in the `lint:yaml` command, use `lint:yaml -` (append a dash) instead to make it explicit.

4.4.0
-----
Expand Down
15 changes: 5 additions & 10 deletions src/Symfony/Component/Yaml/Command/LintCommand.php
Expand Up @@ -86,20 +86,15 @@ 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] ?? '');

if ($hasStdin || 0 === \count($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.');
}

if (!$hasStdin) {
@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);
}

if ('-' === ($filenames[0] ?? '')) {
return $this->display($io, [$this->validate($this->getStdin(), $flags)]);
}

if (0 === \count($filenames)) {
throw new RuntimeException('Please provide a filename or pipe file content to STDIN.');
}

$filesInfo = [];
foreach ($filenames as $filename) {
if (!$this->isReadable($filename)) {
Expand Down

0 comments on commit afe5188

Please sign in to comment.