minor #33509 Remove legacy code from STDIN commands (yceruto)

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 https://github.com/symfony/symfony/pull/33496

Commits
-------

1994ffe61a remove legacy code from STDIN commands
This commit is contained in:
Fabien Potencier 2019-09-09 07:31:06 +02:00
commit afe5188ff5
7 changed files with 17 additions and 32 deletions

View File

@ -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
-----

View File

@ -77,17 +77,12 @@ EOF
{
$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 = [];

View File

@ -66,9 +66,6 @@ class LintCommandTest extends TestCase
$this->assertRegExp('/ERROR in \S+ \(line /', trim($tester->getDisplay()));
}
/**
* @group tty
*/
public function testLintDefaultPaths()
{
$tester = $this->createCommandTester();

View File

@ -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
-----

View File

@ -83,20 +83,15 @@ EOF
$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)) {

View File

@ -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
-----

View File

@ -86,20 +86,15 @@ EOF
$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)) {