deprecated not passing dash symbol (-) to STDIN commands
This commit is contained in:
parent
9d472c715f
commit
586f299ebd
|
@ -207,12 +207,14 @@ Translation
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
* Deprecated support for using `null` as the locale in `Translator`.
|
* Deprecated support for using `null` as the locale in `Translator`.
|
||||||
|
* Deprecated accepting STDIN implicitly when using the `lint:xliff` command, use `lint:xliff -` (append a dash) instead to make it explicit.
|
||||||
|
|
||||||
TwigBridge
|
TwigBridge
|
||||||
----------
|
----------
|
||||||
|
|
||||||
* Deprecated to pass `$rootDir` and `$fileLinkFormatter` as 5th and 6th argument respectively to the
|
* Deprecated to pass `$rootDir` and `$fileLinkFormatter` as 5th and 6th argument respectively to the
|
||||||
`DebugCommand::__construct()` method, swap the variables position.
|
`DebugCommand::__construct()` method, swap the variables position.
|
||||||
|
* Deprecated accepting STDIN implicitly when using the `lint:twig` command, use `lint:twig -` (append a dash) instead to make it explicit.
|
||||||
|
|
||||||
TwigBundle
|
TwigBundle
|
||||||
----------
|
----------
|
||||||
|
@ -326,3 +328,8 @@ WebServerBundle
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
* The bundle is deprecated and will be removed in 5.0.
|
* The bundle is deprecated and will be removed in 5.0.
|
||||||
|
|
||||||
|
Yaml
|
||||||
|
----
|
||||||
|
|
||||||
|
* Deprecated accepting STDIN implicitly when using the `lint:yaml` command, use `lint:yaml -` (append a dash) instead to make it explicit.
|
||||||
|
|
|
@ -531,6 +531,7 @@ Translation
|
||||||
* The `MessageSelector`, `Interval` and `PluralizationRules` classes have been removed, use `IdentityTranslator` instead
|
* The `MessageSelector`, `Interval` and `PluralizationRules` classes have been removed, use `IdentityTranslator` instead
|
||||||
* The `Translator::getFallbackLocales()` and `TranslationDataCollector::getFallbackLocales()` method are now internal
|
* The `Translator::getFallbackLocales()` and `TranslationDataCollector::getFallbackLocales()` method are now internal
|
||||||
* The `Translator::transChoice()` method has been removed in favor of using `Translator::trans()` with "%count%" as the parameter driving plurals
|
* The `Translator::transChoice()` method has been removed in favor of using `Translator::trans()` with "%count%" as the parameter driving plurals
|
||||||
|
* Removed support for implicit STDIN usage in the `lint:xliff` command, use `lint:xliff -` (append a dash) instead to make it explicit.
|
||||||
|
|
||||||
TwigBundle
|
TwigBundle
|
||||||
----------
|
----------
|
||||||
|
@ -548,6 +549,7 @@ TwigBridge
|
||||||
* removed the `$requestStack` and `$requestContext` arguments of the
|
* removed the `$requestStack` and `$requestContext` arguments of the
|
||||||
`HttpFoundationExtension`, pass a `Symfony\Component\HttpFoundation\UrlHelper`
|
`HttpFoundationExtension`, pass a `Symfony\Component\HttpFoundation\UrlHelper`
|
||||||
instance as the only argument instead
|
instance as the only argument instead
|
||||||
|
* Removed support for implicit STDIN usage in the `lint:twig` command, use `lint:twig -` (append a dash) instead to make it explicit.
|
||||||
|
|
||||||
Validator
|
Validator
|
||||||
--------
|
--------
|
||||||
|
@ -653,6 +655,7 @@ Yaml
|
||||||
|
|
||||||
* The parser is now stricter and will throw a `ParseException` when a
|
* The parser is now stricter and will throw a `ParseException` when a
|
||||||
mapping is found inside a multi-line string.
|
mapping is found inside a multi-line string.
|
||||||
|
* Removed support for implicit STDIN usage in the `lint:yaml` command, use `lint:yaml -` (append a dash) instead to make it explicit.
|
||||||
|
|
||||||
WebProfilerBundle
|
WebProfilerBundle
|
||||||
-----------------
|
-----------------
|
||||||
|
|
|
@ -8,6 +8,7 @@ CHANGELOG
|
||||||
* deprecated to pass `$rootDir` and `$fileLinkFormatter` as 5th and 6th argument respectively to the
|
* deprecated to pass `$rootDir` and `$fileLinkFormatter` as 5th and 6th argument respectively to the
|
||||||
`DebugCommand::__construct()` method, swap the variables position.
|
`DebugCommand::__construct()` method, swap the variables position.
|
||||||
* the `LintCommand` lints all the templates stored in all configured Twig paths if none argument is provided
|
* the `LintCommand` lints all the templates stored in all configured Twig paths if none argument is provided
|
||||||
|
* deprecated accepting STDIN implicitly when using the `lint:twig` command, use `lint:twig -` (append a dash) instead to make it explicit.
|
||||||
|
|
||||||
4.3.0
|
4.3.0
|
||||||
-----
|
-----
|
||||||
|
|
|
@ -50,7 +50,7 @@ class LintCommand extends Command
|
||||||
$this
|
$this
|
||||||
->setDescription('Lints a template and outputs encountered errors')
|
->setDescription('Lints a template and outputs encountered errors')
|
||||||
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
|
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
|
||||||
->addArgument('filename', InputArgument::IS_ARRAY)
|
->addArgument('filename', InputArgument::IS_ARRAY, 'A file, a directory or "-" for reading from STDIN')
|
||||||
->setHelp(<<<'EOF'
|
->setHelp(<<<'EOF'
|
||||||
The <info>%command.name%</info> command lints a template and outputs to STDOUT
|
The <info>%command.name%</info> command lints a template and outputs to STDOUT
|
||||||
the first encountered syntax error.
|
the first encountered syntax error.
|
||||||
|
@ -77,15 +77,15 @@ EOF
|
||||||
{
|
{
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
$filenames = $input->getArgument('filename');
|
$filenames = $input->getArgument('filename');
|
||||||
|
$hasStdin = '-' === ($filenames[0] ?? '');
|
||||||
|
|
||||||
if (0 === \count($filenames)) {
|
if ($hasStdin || 0 === \count($filenames)) {
|
||||||
if (0 === ftell(STDIN)) {
|
if ($hasStdin || 0 === ftell(STDIN)) { // remove 0 === ftell(STDIN) check in 5.0
|
||||||
$template = '';
|
if (!$hasStdin) {
|
||||||
while (!feof(STDIN)) {
|
@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);
|
||||||
$template .= fread(STDIN, 1024);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->display($input, $output, $io, [$this->validate($template, uniqid('sf_', true))]);
|
return $this->display($input, $output, $io, [$this->validate($this->getStdin(), uniqid('sf_', true))]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$loader = $this->twig->getLoader();
|
$loader = $this->twig->getLoader();
|
||||||
|
@ -107,6 +107,16 @@ EOF
|
||||||
return $this->display($input, $output, $io, $filesInfo);
|
return $this->display($input, $output, $io, $filesInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getStdin(): string
|
||||||
|
{
|
||||||
|
$template = '';
|
||||||
|
while (!feof(STDIN)) {
|
||||||
|
$template .= fread(STDIN, 1024);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
private function getFilesInfo(array $filenames)
|
private function getFilesInfo(array $filenames)
|
||||||
{
|
{
|
||||||
$filesInfo = [];
|
$filesInfo = [];
|
||||||
|
|
|
@ -5,6 +5,7 @@ CHANGELOG
|
||||||
-----
|
-----
|
||||||
|
|
||||||
* deprecated support for using `null` as the locale in `Translator`
|
* deprecated support for using `null` as the locale in `Translator`
|
||||||
|
* deprecated accepting STDIN implicitly when using the `lint:xliff` command, use `lint:xliff -` (append a dash) instead to make it explicit.
|
||||||
|
|
||||||
4.3.0
|
4.3.0
|
||||||
-----
|
-----
|
||||||
|
|
|
@ -53,7 +53,7 @@ class XliffLintCommand extends Command
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setDescription('Lints a XLIFF file and outputs encountered errors')
|
->setDescription('Lints a XLIFF file and outputs encountered errors')
|
||||||
->addArgument('filename', InputArgument::IS_ARRAY, 'A file or a directory or STDIN')
|
->addArgument('filename', InputArgument::IS_ARRAY, 'A file, a directory or "-" for reading from STDIN')
|
||||||
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
|
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
|
||||||
->setHelp(<<<EOF
|
->setHelp(<<<EOF
|
||||||
The <info>%command.name%</info> command lints a XLIFF file and outputs to STDOUT
|
The <info>%command.name%</info> command lints a XLIFF file and outputs to STDOUT
|
||||||
|
@ -83,13 +83,18 @@ EOF
|
||||||
$filenames = (array) $input->getArgument('filename');
|
$filenames = (array) $input->getArgument('filename');
|
||||||
$this->format = $input->getOption('format');
|
$this->format = $input->getOption('format');
|
||||||
$this->displayCorrectFiles = $output->isVerbose();
|
$this->displayCorrectFiles = $output->isVerbose();
|
||||||
|
$hasStdin = '-' === ($filenames[0] ?? '');
|
||||||
|
|
||||||
if (0 === \count($filenames)) {
|
if ($hasStdin || 0 === \count($filenames)) {
|
||||||
if (!$stdin = $this->getStdin()) {
|
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.');
|
throw new RuntimeException('Please provide a filename or pipe file content to STDIN.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->display($io, [$this->validate($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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->display($io, [$this->validate($this->getStdin())]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$filesInfo = [];
|
$filesInfo = [];
|
||||||
|
@ -223,18 +228,14 @@ EOF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getStdin(): ?string
|
private function getStdin(): string
|
||||||
{
|
{
|
||||||
if (0 !== ftell(STDIN)) {
|
$xliff = '';
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$inputs = '';
|
|
||||||
while (!feof(STDIN)) {
|
while (!feof(STDIN)) {
|
||||||
$inputs .= fread(STDIN, 1024);
|
$xliff .= fread(STDIN, 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $inputs;
|
return $xliff;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDirectoryIterator(string $directory)
|
private function getDirectoryIterator(string $directory)
|
||||||
|
|
|
@ -5,6 +5,7 @@ CHANGELOG
|
||||||
-----
|
-----
|
||||||
|
|
||||||
* Added support to dump `null` as `~` by using the `Yaml::DUMP_NULL_AS_TILDE` flag.
|
* Added support to dump `null` as `~` by using the `Yaml::DUMP_NULL_AS_TILDE` flag.
|
||||||
|
* deprecated accepting STDIN implicitly when using the `lint:yaml` command, use `lint:yaml -` (append a dash) instead to make it explicit.
|
||||||
|
|
||||||
4.3.0
|
4.3.0
|
||||||
-----
|
-----
|
||||||
|
|
|
@ -54,7 +54,7 @@ class LintCommand extends Command
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setDescription('Lints a file and outputs encountered errors')
|
->setDescription('Lints a file and outputs encountered errors')
|
||||||
->addArgument('filename', InputArgument::IS_ARRAY, 'A file or a directory or STDIN')
|
->addArgument('filename', InputArgument::IS_ARRAY, 'A file, a directory or "-" for reading from STDIN')
|
||||||
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
|
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
|
||||||
->addOption('parse-tags', null, InputOption::VALUE_NONE, 'Parse custom tags')
|
->addOption('parse-tags', null, InputOption::VALUE_NONE, 'Parse custom tags')
|
||||||
->setHelp(<<<EOF
|
->setHelp(<<<EOF
|
||||||
|
@ -86,13 +86,18 @@ EOF
|
||||||
$this->format = $input->getOption('format');
|
$this->format = $input->getOption('format');
|
||||||
$this->displayCorrectFiles = $output->isVerbose();
|
$this->displayCorrectFiles = $output->isVerbose();
|
||||||
$flags = $input->getOption('parse-tags') ? Yaml::PARSE_CUSTOM_TAGS : 0;
|
$flags = $input->getOption('parse-tags') ? Yaml::PARSE_CUSTOM_TAGS : 0;
|
||||||
|
$hasStdin = '-' === ($filenames[0] ?? '');
|
||||||
|
|
||||||
if (0 === \count($filenames)) {
|
if ($hasStdin || 0 === \count($filenames)) {
|
||||||
if (!$stdin = $this->getStdin()) {
|
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.');
|
throw new RuntimeException('Please provide a filename or pipe file content to STDIN.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->display($io, [$this->validate($stdin, $flags)]);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->display($io, [$this->validate($this->getStdin(), $flags)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$filesInfo = [];
|
$filesInfo = [];
|
||||||
|
@ -199,18 +204,14 @@ EOF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getStdin(): ?string
|
private function getStdin(): string
|
||||||
{
|
{
|
||||||
if (0 !== ftell(STDIN)) {
|
$yaml = '';
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$inputs = '';
|
|
||||||
while (!feof(STDIN)) {
|
while (!feof(STDIN)) {
|
||||||
$inputs .= fread(STDIN, 1024);
|
$yaml .= fread(STDIN, 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $inputs;
|
return $yaml;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getParser()
|
private function getParser()
|
||||||
|
|
Reference in New Issue