Skip to content

Commit

Permalink
bug #37130 [Console] allow cursor to be used even when STDIN is not d…
Browse files Browse the repository at this point in the history
…efined (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
-------

aff1ffa allow cursor to be used even when STDIN is not defined
  • Loading branch information
fabpot committed Jun 8, 2020
2 parents 5de548b + aff1ffa commit 72ca171
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Symfony/Component/Console/Cursor.php
Expand Up @@ -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
Expand Down

0 comments on commit 72ca171

Please sign in to comment.