public function addHistory($line)
{
if ($this->eraseDups) {
- if (($key = array_search($line, $this->history)) !== false) {
+ if (($key = \array_search($line, $this->history)) !== false) {
unset($this->history[$key]);
}
}
$this->history[] = $line;
if ($this->historySize > 0) {
- $histsize = count($this->history);
+ $histsize = \count($this->history);
if ($histsize > $this->historySize) {
- $this->history = array_slice($this->history, $histsize - $this->historySize);
+ $this->history = \array_slice($this->history, $histsize - $this->historySize);
}
}
- $this->history = array_values($this->history);
+ $this->history = \array_values($this->history);
return true;
}
{
echo $prompt;
- return rtrim(fgets($this->getStdin(), 1024));
+ return \rtrim(\fgets($this->getStdin()), "\n\r");
}
/**
private function getStdin()
{
if (!isset($this->stdin)) {
- $this->stdin = fopen('php://stdin', 'r');
+ $this->stdin = \fopen('php://stdin', 'r');
}
- if (feof($this->stdin)) {
+ if (\feof($this->stdin)) {
throw new BreakException('Ctrl+D');
}