/var/www/vhosts/ihelp.ro/httpdocs/vendor/psy/psysh/src/Readline
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/psy/psysh/src/Readline/GNUReadline.php (4132B)
historyFile = ($historyFile !== null) ? $historyFile : false;
$this->historySize = $historySize;
$this->eraseDups = $eraseDups;
\readline_info('readline_name', 'psysh');
}
/**
* {@inheritdoc}
*/
public function addHistory(string $line): bool
{
if ($res = \readline_add_history($line)) {
$this->writeHistory();
}
return $res;
}
/**
* {@inheritdoc}
*/
public function clearHistory(): bool
{
if ($res = \readline_clear_history()) {
$this->writeHistory();
}
return $res;
}
/**
* {@inheritdoc}
*/
public function listHistory(): array
{
return \readline_list_history();
}
/**
* {@inheritdoc}
*/
public function readHistory(): bool
{
\readline_read_history();
\readline_clear_history();
return \readline_read_history($this->historyFile);
}
/**
* {@inheritdoc}
*/
public function readline(string $prompt = null)
{
return \readline($prompt);
}
/**
* {@inheritdoc}
*/
public function redisplay()
{
\readline_redisplay();
}
/**
* {@inheritdoc}
*/
public function writeHistory(): bool
{
// 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);
} else {
$res = true;
}
if (!$res || !$this->eraseDups && !$this->historySize > 0) {
return $res;
}
$hist = $this->listHistory();
if (!$hist) {
return true;
}
if ($this->eraseDups) {
// flip-flip technique: removes duplicates, latest entries win.
$hist = \array_flip(\array_flip($hist));
// sort on keys to get the order back
\ksort($hist);
}
if ($this->historySize > 0) {
$histsize = \count($hist);
if ($histsize > $this->historySize) {
$hist = \array_slice($hist, $histsize - $this->historySize);
}
}
\readline_clear_history();
foreach ($hist as $line) {
\readline_add_history($line);
}
if ($this->historyFile !== false) {
return \readline_write_history($this->historyFile);
}
return true;
}
}