/** * {@inheritDoc} */ public function clearHistory() { if ($res = readline_clear_history()) { $this->writeHistory(); } return $res; }
public function setUp() { if (!function_exists('readline_list_history')) { $this->markTestSkipped('GNUReadline not enabled'); } readline_clear_history(); $this->historyFile = tempnam(sys_get_temp_dir() . '/psysh/test/', 'history'); $this->readline = new GNUReadline($this->historyFile); }
public function setUp() { if (!function_exists('readline')) { $this->markTestSkipped('Libedit not enabled'); } if (`which unvis` === null) { $this->markTestSkipped('Missing unvis library'); } readline_clear_history(); $this->historyFile = tempnam(sys_get_temp_dir() . '/psysh/test/', 'history'); $this->readline = new Libedit($this->historyFile); }
public function setUp() { if (!Libedit::isSupported()) { $this->markTestSkipped('Libedit not enabled'); } $this->historyFile = tempnam(sys_get_temp_dir(), 'psysh_test_history'); if (false === file_put_contents($this->historyFile, "_HiStOrY_V2_\n")) { $this->fail('Unable to write history file: ' . $this->historyFile); } // Calling readline_read_history before readline_clear_history // avoids segfault with PHP 5.5.7 & libedit v3.1 readline_read_history($this->historyFile); readline_clear_history(); }
<?php $name = tempnam('/tmp', 'readline.tmp'); readline_add_history('foo'); readline_add_history(''); readline_add_history(1); readline_add_history(NULL); var_dump(readline_write_history($name)); var_dump(readline_read_history($name)); var_dump(file_get_contents($name)); readline_clear_history(); readline_write_history($name); var_dump(file_get_contents($name)); unlink($name);
public function clear() { $this->userInputs = []; return @readline_clear_history(); }
/** * {@inheritdoc} */ public function writeHistory() { // We have to write history first, since it is used // by Libedit to list history $res = readline_write_history($this->historyFile); 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); } return readline_write_history($this->historyFile); }
<?php var_dump(readline_clear_history()); var_dump(readline_clear_history(1));
/** * Clear the history * * @return bool success */ public function clearHistory() { return readline_clear_history(); }
/** * {@inheritDoc} */ public function readHistory() { // Workaround PHP bug #69054 // // If open_basedir is set, readline_read_history() segfaults. This will be fixed in 5.6.7: // // https://github.com/php/php-src/blob/423a057023ef3c00d2ffc16a6b43ba01d0f71796/NEWS#L19-L21 // // TODO: add a PHP version check after next point release if (!ini_get('open_basedir')) { readline_read_history(); } readline_clear_history(); return readline_read_history($this->historyFile); }