Fix --disable-readline command-line option does not work, close #34 (#35)

* Fix --disable-readline command-line option does not work, close #34

* add parentheses
This commit is contained in:
Dylan K. Taylor 2016-10-18 14:33:38 +01:00 committed by GitHub
parent 4bc2275fc3
commit ebcc16d283

View File

@ -31,6 +31,8 @@ class CommandReader extends Thread{
public function __construct(){ public function __construct(){
$this->buffer = new \Threaded; $this->buffer = new \Threaded;
$opts = getopt("", ["disable-readline"]);
$this->readline = (extension_loaded("readline") and !isset($opts["disable-readline"]));
$this->start(); $this->start();
} }
@ -71,14 +73,10 @@ class CommandReader extends Thread{
} }
public function run(){ public function run(){
$opts = getopt("", ["disable-readline"]); if(!$this->readline){
if(extension_loaded("readline") and !isset($opts["disable-readline"])){
$this->readline = true;
}else{
global $stdin; global $stdin;
$stdin = fopen("php://stdin", "r"); $stdin = fopen("php://stdin", "r");
stream_set_blocking($stdin, 0); stream_set_blocking($stdin, 0);
$this->readline = false;
} }
$lastLine = microtime(true); $lastLine = microtime(true);