Aggiornato Composer

This commit is contained in:
Paolo A
2024-05-17 12:24:19 +00:00
parent 4ac62108b5
commit ec201d75b2
2238 changed files with 38684 additions and 59785 deletions

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2022 Justin Hileman
* (c) 2012-2023 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -34,8 +34,6 @@ class GNUReadline implements Readline
*
* NOTE: As of PHP 7.4, PHP sometimes has history support in the Libedit
* wrapper, so that will use the GNUReadline implementation as well!
*
* @return bool
*/
public static function isSupported(): bool
{
@@ -46,21 +44,12 @@ class GNUReadline implements Readline
* Check whether this readline implementation supports bracketed paste.
*
* Currently, the GNU readline implementation does, but the libedit wrapper does not.
*
* @return bool
*/
public static function supportsBracketedPaste(): bool
{
return self::isSupported() && \stripos(\readline_info('library_version') ?: '', 'editline') === false;
}
/**
* GNU Readline constructor.
*
* @param string|false $historyFile
* @param int $historySize
* @param bool $eraseDups
*/
public function __construct($historyFile = null, $historySize = 0, $eraseDups = false)
{
$this->historyFile = ($historyFile !== null) ? $historyFile : false;
@@ -116,7 +105,7 @@ class GNUReadline implements Readline
/**
* {@inheritdoc}
*/
public function readline(string $prompt = null)
public function readline(?string $prompt = null)
{
return \readline($prompt);
}

View File

@@ -1,129 +0,0 @@
<?php
/*
* This file is part of Psy Shell.
*
* (c) 2012-2022 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Psy\Readline;
use Hoa\Console\Console;
use Hoa\Console\Cursor;
use Hoa\Console\Readline\Readline as HoaReadline;
use Psy\Exception\BreakException;
/**
* Hoa\Console Readline implementation.
*/
class HoaConsole implements Readline
{
/** @var HoaReadline */
private $hoaReadline;
/** @var string|null */
private $lastPrompt;
/**
* @return bool
*/
public static function isSupported(): bool
{
return \class_exists(Console::class, true);
}
/**
* {@inheritdoc}
*/
public static function supportsBracketedPaste(): bool
{
return false;
}
public function __construct()
{
$this->hoaReadline = new HoaReadline();
$this->hoaReadline->addMapping('\C-l', function () {
$this->redisplay();
return HoaReadline::STATE_NO_ECHO;
});
}
/**
* {@inheritdoc}
*/
public function addHistory(string $line): bool
{
$this->hoaReadline->addHistory($line);
return true;
}
/**
* {@inheritdoc}
*/
public function clearHistory(): bool
{
$this->hoaReadline->clearHistory();
return true;
}
/**
* {@inheritdoc}
*/
public function listHistory(): array
{
$i = 0;
$list = [];
while (($item = $this->hoaReadline->getHistory($i++)) !== null) {
$list[] = $item;
}
return $list;
}
/**
* {@inheritdoc}
*/
public function readHistory(): bool
{
return true;
}
/**
* {@inheritdoc}
*
* @throws BreakException if user hits Ctrl+D
*
* @return false|string
*/
public function readline(string $prompt = null)
{
$this->lastPrompt = $prompt;
return $this->hoaReadline->readLine($prompt);
}
/**
* {@inheritdoc}
*/
public function redisplay()
{
$currentLine = $this->hoaReadline->getLine();
Cursor::clear('all');
echo $this->lastPrompt, $currentLine;
}
/**
* {@inheritdoc}
*/
public function writeHistory(): bool
{
return true;
}
}

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2022 Justin Hileman
* (c) 2012-2023 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -29,8 +29,6 @@ class Libedit extends GNUReadline
/**
* Let's emulate GNU Readline by manually reading and parsing the history file!
*
* @return bool
*/
public static function isSupported(): bool
{
@@ -65,6 +63,7 @@ class Libedit extends GNUReadline
// decode the line
$history = \array_map([$this, 'parseHistoryLine'], $history);
// filter empty lines & comments
return \array_values(\array_filter($history));
}

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2022 Justin Hileman
* (c) 2012-2023 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -16,17 +16,20 @@ namespace Psy\Readline;
*/
interface Readline
{
/**
* @param string|false $historyFile
* @param int|null $historySize
* @param bool|null $eraseDups
*/
public function __construct($historyFile = null, $historySize = 0, $eraseDups = false);
/**
* Check whether this Readline class is supported by the current system.
*
* @return bool
*/
public static function isSupported(): bool;
/**
* Check whether this Readline class supports bracketed paste.
*
* @return bool
*/
public static function supportsBracketedPaste(): bool;
@@ -49,7 +52,7 @@ interface Readline
/**
* List the command history.
*
* @return array
* @return string[]
*/
public function listHistory(): array;
@@ -67,7 +70,7 @@ interface Readline
*
* @return false|string
*/
public function readline(string $prompt = null);
public function readline(?string $prompt = null);
/**
* Redraw readline to redraw the display.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2022 Justin Hileman
* (c) 2012-2023 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -110,7 +110,7 @@ class Transient implements Readline
*
* @return false|string
*/
public function readline(string $prompt = null)
public function readline(?string $prompt = null)
{
echo $prompt;