*/
public static function isSupported()
{
- return function_exists('readline_list_history');
+ return \function_exists('readline_list_history');
}
/**
*/
public function addHistory($line)
{
- if ($res = readline_add_history($line)) {
+ if ($res = \readline_add_history($line)) {
$this->writeHistory();
}
*/
public function clearHistory()
{
- if ($res = readline_clear_history()) {
+ if ($res = \readline_clear_history()) {
$this->writeHistory();
}
//
// https://github.com/php/php-src/blob/423a057023ef3c00d2ffc16a6b43ba01d0f71796/NEWS#L19-L21
//
- if (version_compare(PHP_VERSION, '5.6.7', '>=') || !ini_get('open_basedir')) {
- readline_read_history();
+ if (\version_compare(PHP_VERSION, '5.6.7', '>=') || !\ini_get('open_basedir')) {
+ \readline_read_history();
}
- readline_clear_history();
+ \readline_clear_history();
- return readline_read_history($this->historyFile);
+ return \readline_read_history($this->historyFile);
}
/**
*/
public function readline($prompt = null)
{
- return readline($prompt);
+ return \readline($prompt);
}
/**
*/
public function redisplay()
{
- readline_redisplay();
+ \readline_redisplay();
}
/**
// We have to write history first, since it is used
// by Libedit to list history
if ($this->historyFile !== false) {
- $res = readline_write_history($this->historyFile);
+ $res = \readline_write_history($this->historyFile);
} else {
$res = true;
}
if ($this->eraseDups) {
// flip-flip technique: removes duplicates, latest entries win.
- $hist = array_flip(array_flip($hist));
+ $hist = \array_flip(\array_flip($hist));
// sort on keys to get the order back
- ksort($hist);
+ \ksort($hist);
}
if ($this->historySize > 0) {
- $histsize = count($hist);
+ $histsize = \count($hist);
if ($histsize > $this->historySize) {
- $hist = array_slice($hist, $histsize - $this->historySize);
+ $hist = \array_slice($hist, $histsize - $this->historySize);
}
}
- readline_clear_history();
+ \readline_clear_history();
foreach ($hist as $line) {
- readline_add_history($line);
+ \readline_add_history($line);
}
if ($this->historyFile !== false) {
- return readline_write_history($this->historyFile);
+ return \readline_write_history($this->historyFile);
}
return true;