From 064b869629584d282fd7766a3cff5e9c36894747 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Tue, 12 Jul 2022 01:52:19 +0900 Subject: [PATCH] Rename Configuration::$hasReadline hasNativeReadline --- src/Configuration.php | 26 ++++++++++++++++++++------ test/ConfigurationTest.php | 2 +- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/Configuration.php b/src/Configuration.php index d7039d81..0c4382f4 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -87,7 +87,8 @@ class Configuration private $historySize; private $eraseDuplicates; private $manualDbFile; - private $hasReadline; + /** @bool Native readline implementation provided by {@see readline()} function */ + private $hasNativeReadline; private $useReadline; private $useBracketedPaste; private $hasPcntl; @@ -370,7 +371,7 @@ public static function getInputOptions(): array public function init() { // feature detection - $this->hasReadline = \function_exists('readline'); + $this->hasNativeReadline = \function_exists('readline'); $this->hasPcntl = ProcessForker::isSupported(); if ($configFile = $this->getConfigFile()) { @@ -735,13 +736,24 @@ public function getPipe(string $type, int $pid): string } /** - * Check whether this PHP instance has Readline available. + * Check whether this PHP instance has native readline available. * + * @deprecated Call {@see Configuration::hasNativeReadline()} instead * @return bool True if Readline is available */ public function hasReadline(): bool { - return $this->hasReadline; + return $this->hasNativeReadline; + } + + /** + * Check whether this PHP instance has native readline available. + * + * @return bool True if Readline is available + */ + public function hasNativeReadline(): bool + { + return $this->hasNativeReadline; } /** @@ -764,7 +776,7 @@ public function setUseReadline(bool $useReadline) */ public function useReadline(): bool { - return isset($this->useReadline) ? ($this->hasReadline && $this->useReadline) : $this->hasReadline; + return isset($this->useReadline) ? ($this->hasNativeReadline && $this->useReadline) : $this->hasNativeReadline; } /** @@ -1081,7 +1093,9 @@ public function setTabCompletion(bool $useTabCompletion) */ public function useTabCompletion(): bool { - return isset($this->useTabCompletion) ? ($this->hasReadline && $this->useTabCompletion) : $this->hasReadline; + // TODO: In the future, if stability other than GNU Readline improves, + // it will no longer depend on $this->hasNativeReadline property. + return isset($this->useTabCompletion) ? $this->useTabCompletion : $this->hasNativeReadline; } /** diff --git a/test/ConfigurationTest.php b/test/ConfigurationTest.php index e8d90c60..55340412 100644 --- a/test/ConfigurationTest.php +++ b/test/ConfigurationTest.php @@ -35,7 +35,7 @@ public function testDefaults() { $config = $this->getConfig(); - $this->assertSame(\function_exists('readline'), $config->hasReadline()); + $this->assertSame(\function_exists('readline'), $config->hasNativeReadline()); $this->assertSame(\function_exists('readline'), $config->useReadline()); $this->assertSame(ProcessForker::isSupported(), $config->hasPcntl()); $this->assertSame($config->hasPcntl(), $config->usePcntl());