Skip to content

Commit

Permalink
Merge branch '4.4' into 5.0
Browse files Browse the repository at this point in the history
* 4.4:
  [FrameworkBundle] fix "samesite" in XSD
  [Console] Consider STDIN interactive
  Update UserPasswordEncoderCommand.php
  [HttpFoundation][FrameworkBundle] fix support for samesite in session cookies
  [DoctrineBridge] Fixed submitting ids with query limit or offset
  • Loading branch information
nicolas-grekas committed Feb 7, 2020
2 parents d4d34ad + 55b6ebf commit 515c7ee
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
13 changes: 0 additions & 13 deletions Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\StreamableInputInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -858,18 +857,6 @@ protected function configureIO(InputInterface $input, OutputInterface $output)

if (true === $input->hasParameterOption(['--no-interaction', '-n'], true)) {
$input->setInteractive(false);
} else {
$inputStream = null;

if ($input instanceof StreamableInputInterface) {
$inputStream = $input->getStream();
}

$inputStream = !$inputStream && \defined('STDIN') ? STDIN : $inputStream;

if ((!$inputStream || !stream_isatty($inputStream)) && false === getenv('SHELL_INTERACTIVE')) {
$input->setInteractive(false);
}
}

switch ($shellVerbosity = (int) getenv('SHELL_VERBOSITY')) {
Expand Down
9 changes: 1 addition & 8 deletions Tester/ApplicationTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,12 @@ public function run(array $input, array $options = [])
$this->input->setInteractive($options['interactive']);
}

$shellInteractive = getenv('SHELL_INTERACTIVE');

if ($this->inputs) {
$this->input->setStream(self::createStream($this->inputs));
putenv('SHELL_INTERACTIVE=1');
}

$this->initOutput($options);

$this->statusCode = $this->application->run($this->input, $this->output);

putenv($shellInteractive ? "SHELL_INTERACTIVE=$shellInteractive" : 'SHELL_INTERACTIVE');

return $this->statusCode;
return $this->statusCode = $this->application->run($this->input, $this->output);
}
}
28 changes: 28 additions & 0 deletions Tests/phpt/uses_stdin_as_interactive_input.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--STDIN--
Hello World
--FILE--
<?php

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;

$vendor = __DIR__;
while (!file_exists($vendor.'/vendor')) {
$vendor = \dirname($vendor);
}
require $vendor.'/vendor/autoload.php';

(new Application())
->register('app')
->setCode(function(InputInterface $input, OutputInterface $output) {
$output->writeln((new QuestionHelper())->ask($input, $output, new Question('Foo?')));
})
->getApplication()
->setDefaultCommand('app', true)
->run()
;
--EXPECT--
Foo?Hello World

0 comments on commit 515c7ee

Please sign in to comment.