Skip to content

Commit

Permalink
Rename Configuration::$hasReadline hasNativeReadline
Browse files Browse the repository at this point in the history
  • Loading branch information
zonuexe committed Jul 11, 2022
1 parent ef4f22d commit 064b869
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
26 changes: 20 additions & 6 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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;
}

/**
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 064b869

Please sign in to comment.