/** * Get the appropriate Readline implementation class name. * * @see self::getReadline * * @return string */ private function getReadlineClass() { if ($this->useReadline()) { if (GNUReadline::isSupported()) { return 'Psy\\Readline\\GNUReadline'; } elseif (Libedit::isSupported()) { return 'Psy\\Readline\\Libedit'; } } return 'Psy\\Readline\\Transient'; }
/** * {@inheritDoc} */ public function clearHistory() { $this->history = array(); return parent::clearHistory(); }
/** * Libedit being a BSD library, * it doesn't support non-unix line separators. */ public function testLinebreaksSupport() { $readline = new Libedit($this->historyFile); file_put_contents($this->historyFile, "foo\rbar\nbaz\r\nw00t", FILE_APPEND); $this->assertEquals(array("foo\rbar", "baz\r", 'w00t'), $readline->listHistory()); $readline->clearHistory(); }
/** * Get the Psy Shell readline service. * * By default, this service uses (in order of preference): * * * GNU Readline * * Libedit * * A transient array-based readline emulation. * * @return Readline */ public function getReadline() { if (!isset($this->readline)) { if ($this->useReadline()) { $historyFile = $this->getHistoryFile(); if (GNUReadline::isSupported()) { $this->readline = new GNUReadline($historyFile); } elseif (Libedit::isSupported()) { $this->readline = new Libedit($historyFile); } elseif (LibeditTransient::isSupported()) { $this->readline = new LibeditTransient($historyFile); } } if (!isset($this->readline)) { $this->readline = new Transient(); } } return $this->readline; }