/** * @depends testHistory */ public function testHistoryEraseDups() { $readline = new GNUReadline($this->historyFile, 0, true); $this->assertEmpty($readline->listHistory()); $readline->addHistory('foo'); $readline->addHistory('bar'); $readline->addHistory('foo'); $this->assertEquals(array('bar', 'foo'), $readline->listHistory()); $readline->addHistory('baz'); $readline->addHistory('w00t'); $readline->addHistory('baz'); $this->assertEquals(array('bar', 'foo', 'w00t', 'baz'), $readline->listHistory()); $readline->clearHistory(); $this->assertEmpty($readline->listHistory()); }
/** * 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'; }
/** * 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; }