bug #37130 [Console] allow cursor to be used even when STDIN is not defined (xabbuh)

This PR was merged into the 5.1 branch.

Discussion
----------

[Console] allow cursor to be used even when STDIN is not defined

| Q             | A
| ------------- | ---
| Branch?       | 5.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #37124
| License       | MIT
| Doc PR        |

This allows to use the `Cursor` class introduced in Symfony 5.1 even when the `STDIN` constant is not defined. We did a similar bugfix in the past in the `QuestionHelper` class in #10798.

Commits
-------

aff1ffaeff allow cursor to be used even when STDIN is not defined
This commit is contained in:
Fabien Potencier 2020-06-08 08:06:34 +02:00
commit 72ca171dbb
1 changed files with 2 additions and 2 deletions

View File

@ -21,10 +21,10 @@ final class Cursor
private $output;
private $input;
public function __construct(OutputInterface $output, $input = STDIN)
public function __construct(OutputInterface $output, $input = null)
{
$this->output = $output;
$this->input = $input;
$this->input = $input ?? (\defined('STDIN') ? STDIN : fopen('php://input', 'r+'));
}
public function moveUp(int $lines = 1): self