Skip to content

Commit

Permalink
Merge branch '4.4'
Browse files Browse the repository at this point in the history
* 4.4: (21 commits)
  [appveyor] exclude tty group
  [HttpFoundation] Add types to private/final/internal methods and constructors.
  Add types to private/final/internal methods and constructors.
  SCA: minor code tweaks
  Tweak output
  [FrameworkBundle] Added --sort option for TranslationUpdateCommand
  [HttpClient] fallbackto CURLMOPT_MAXCONNECTS when CURLMOPT_MAX_HOST_CONNECTIONS is not available
  [DI] generate preload.php file for PHP 7.4 in cache folder
  Allow version 2 of the contracts package.
  [Serializer] Allow multi-dimenstion object array in AbstractObjectNormalizer
  fixed typo
  [HttpKernel] Fix Apache mod_expires Session Cache-Control issue
  deprecated not passing dash symbol (-) to STDIN commands
  [VarDumper] display ellipsed FQCN for nested classes
  [VarDumper] Display fully qualified title
  [Mailer] Change the syntax for DSNs using failover or roundrobin
  Removed workaround introduced in 4.3
  [Console] Added support for definition list
  [OptionsResolver] Display full nested options hierarchy in exceptions
  New welcome page
  ...
  • Loading branch information
nicolas-grekas committed Sep 8, 2019
2 parents 173ba14 + 41c2218 commit c959659
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -19,6 +19,7 @@ CHANGELOG
-----

* 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
-----
Expand Down
25 changes: 13 additions & 12 deletions Command/XliffLintCommand.php
Expand Up @@ -53,7 +53,7 @@ protected function configure()
{
$this
->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')
->setHelp(<<<EOF
The <info>%command.name%</info> command lints a XLIFF file and outputs to STDOUT
Expand Down Expand Up @@ -83,13 +83,18 @@ 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 (0 === \count($filenames)) {
if (!$stdin = $this->getStdin()) {
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.');
}

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 = [];
Expand Down Expand Up @@ -223,18 +228,14 @@ private function getFiles(string $fileOrDirectory)
}
}

private function getStdin(): ?string
private function getStdin(): string
{
if (0 !== ftell(STDIN)) {
return null;
}

$inputs = '';
$xliff = '';
while (!feof(STDIN)) {
$inputs .= fread(STDIN, 1024);
$xliff .= fread(STDIN, 1024);
}

return $inputs;
return $xliff;
}

private function getDirectoryIterator(string $directory)
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -18,15 +18,15 @@
"require": {
"php": "^7.2.9",
"symfony/polyfill-mbstring": "~1.0",
"symfony/translation-contracts": "^1.1.6"
"symfony/translation-contracts": "^1.1.6|^2"
},
"require-dev": {
"symfony/config": "^4.4|^5.0",
"symfony/console": "^4.4|^5.0",
"symfony/dependency-injection": "^5.0",
"symfony/http-kernel": "^5.0",
"symfony/intl": "^4.4|^5.0",
"symfony/service-contracts": "^1.1.2",
"symfony/service-contracts": "^1.1.2|^2",
"symfony/var-dumper": "^4.4|^5.0",
"symfony/yaml": "^4.4|^5.0",
"symfony/finder": "^4.4|^5.0",
Expand Down

0 comments on commit c959659

Please sign in to comment.