allow vendord
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s

This commit is contained in:
2026-03-30 14:54:57 +07:00
parent 66aed7c4e8
commit b5e3a778ce
21316 changed files with 2777892 additions and 13 deletions

View File

@@ -0,0 +1,49 @@
<?php
/*
* This file is part of Psy Shell.
*
* (c) 2012-2025 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Psy\Util;
/**
* Utility for checking PHP function availability.
*/
class DependencyChecker
{
/**
* Check if all functions in a list are available (exist and not disabled).
*
* @param string[] $functions List of function names to check
*/
public static function functionsAvailable(array $functions): bool
{
foreach ($functions as $func) {
if (!\function_exists($func)) {
return false;
}
}
return empty(self::functionsDisabled($functions));
}
/**
* Check if any functions in a list are disabled.
*
* @param string[] $functions List of function names to check
*
* @return string[] List of disabled functions
*/
public static function functionsDisabled(array $functions): array
{
$disabled = \array_map('strtolower', \array_map('trim', \explode(',', \ini_get('disable_functions'))));
$disabledFunctions = \array_intersect($functions, $disabled);
return $disabledFunctions;
}
}

247
vendor/psy/psysh/src/Util/Docblock.php vendored Normal file
View File

@@ -0,0 +1,247 @@
<?php
/*
* This file is part of Psy Shell.
*
* (c) 2012-2025 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Psy\Util;
/**
* A docblock representation.
*
* Based on PHP-DocBlock-Parser by Paul Scott:
*
* {@link http://www.github.com/icio/PHP-DocBlock-Parser}
*
* @author Paul Scott <paul@duedil.com>
* @author Justin Hileman <justin@justinhileman.info>
*/
class Docblock
{
/**
* Tags in the docblock that have a whitespace-delimited number of parameters
* (such as `@param type var desc` and `@return type desc`) and the names of
* those parameters.
*
* @var array
*/
public static $vectors = [
'throws' => ['type', 'desc'],
'param' => ['type', 'var', 'desc'],
'return' => ['type', 'desc'],
];
protected $reflector;
/**
* The description of the symbol.
*
* @var string
*/
public $desc;
/**
* The tags defined in the docblock.
*
* The array has keys which are the tag names (excluding the @) and values
* that are arrays, each of which is an entry for the tag.
*
* In the case where the tag name is defined in {@see DocBlock::$vectors} the
* value within the tag-value array is an array in itself with keys as
* described by {@see DocBlock::$vectors}.
*
* @var array
*/
public $tags;
/**
* The entire DocBlock comment that was parsed.
*
* @var string
*/
public $comment;
/**
* Docblock constructor.
*
* @param \Reflector $reflector
*/
public function __construct(\Reflector $reflector)
{
$this->reflector = $reflector;
if ($reflector instanceof \ReflectionClass || $reflector instanceof \ReflectionClassConstant || $reflector instanceof \ReflectionFunctionAbstract || $reflector instanceof \ReflectionProperty) {
$this->setComment($reflector->getDocComment());
}
}
/**
* Set and parse the docblock comment.
*
* @param string $comment The docblock
*/
protected function setComment(string $comment)
{
$this->desc = '';
$this->tags = [];
$this->comment = $comment;
$this->parseComment($comment);
}
/**
* Find the length of the docblock prefix.
*
* @param array $lines
*
* @return int Prefix length
*/
protected static function prefixLength(array $lines): int
{
// find only lines with interesting things
$lines = \array_filter($lines, function ($line) {
return \substr($line, \strspn($line, "* \t\n\r\0\x0B"));
});
// if we sort the lines, we only have to compare two items
\sort($lines);
$first = \reset($lines);
$last = \end($lines);
// Special case for single-line comments
if (\count($lines) === 1) {
return \strspn($first, "* \t\n\r\0\x0B");
}
// find the longest common substring
$count = \min(\strlen($first), \strlen($last));
for ($i = 0; $i < $count; $i++) {
if ($first[$i] !== $last[$i]) {
return $i;
}
}
return $count;
}
/**
* Parse the comment into the component parts and set the state of the object.
*
* @param string $comment The docblock
*/
protected function parseComment(string $comment)
{
// Strip the opening and closing tags of the docblock
$comment = \substr($comment, 3, -2);
// Split into arrays of lines
$comment = \array_filter(\preg_split('/\r?\n\r?/', $comment));
// Trim asterisks and whitespace from the beginning and whitespace from the end of lines
$prefixLength = self::prefixLength($comment);
$comment = \array_map(function ($line) use ($prefixLength) {
return \rtrim(\substr($line, $prefixLength));
}, $comment);
// Group the lines together by @tags
$blocks = [];
$b = -1;
foreach ($comment as $line) {
if (self::isTagged($line)) {
$b++;
$blocks[] = [];
} elseif ($b === -1) {
$b = 0;
$blocks[] = [];
}
$blocks[$b][] = $line;
}
// Parse the blocks
foreach ($blocks as $block => $body) {
$body = \trim(\implode("\n", $body));
if ($block === 0 && !self::isTagged($body)) {
// This is the description block
$this->desc = $body;
} else {
// This block is tagged
$tag = \substr(self::strTag($body), 1);
$body = \ltrim(\substr($body, \strlen($tag) + 2));
if (isset(self::$vectors[$tag])) {
// The tagged block is a vector
$count = \count(self::$vectors[$tag]);
if ($body) {
$parts = \preg_split('/\s+/', $body, $count);
} else {
$parts = [];
}
// Default the trailing values
$parts = \array_pad($parts, $count, null);
// Store as a mapped array
$this->tags[$tag][] = \array_combine(self::$vectors[$tag], $parts);
} else {
// The tagged block is only text
$this->tags[$tag][] = $body;
}
}
}
}
/**
* Whether or not a docblock contains a given @tag.
*
* @param string $tag The name of the @tag to check for
*/
public function hasTag(string $tag): bool
{
return \is_array($this->tags) && \array_key_exists($tag, $this->tags);
}
/**
* The value of a tag.
*
* @param string $tag
*
* @return array|null
*/
public function tag(string $tag): ?array
{
return $this->hasTag($tag) ? $this->tags[$tag] : null;
}
/**
* Whether or not a string begins with a @tag.
*
* @param string $str
*/
public static function isTagged(string $str): bool
{
return isset($str[1]) && $str[0] === '@' && !\preg_match('/[^A-Za-z]/', $str[1]);
}
/**
* The tag at the beginning of a string.
*
* @param string $str
*
* @return string|null
*/
public static function strTag(string $str)
{
if (\preg_match('/^@[a-z0-9_]+/', $str, $matches)) {
return $matches[0];
}
return null;
}
}

31
vendor/psy/psysh/src/Util/Json.php vendored Normal file
View File

@@ -0,0 +1,31 @@
<?php
/*
* This file is part of Psy Shell.
*
* (c) 2012-2025 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Psy\Util;
/**
* A static class to wrap JSON encoding/decoding with PsySH's default options.
*/
class Json
{
/**
* Encode a value as JSON.
*
* @param mixed $val
* @param int $opt
*/
public static function encode($val, int $opt = 0): string
{
$opt |= \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE;
return \json_encode($val, $opt);
}
}

149
vendor/psy/psysh/src/Util/Mirror.php vendored Normal file
View File

@@ -0,0 +1,149 @@
<?php
/*
* This file is part of Psy Shell.
*
* (c) 2012-2025 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Psy\Util;
use Psy\Exception\RuntimeException;
use Psy\Reflection\ReflectionConstant;
use Psy\Reflection\ReflectionNamespace;
/**
* A utility class for getting Reflectors.
*/
class Mirror
{
const CONSTANT = 1;
const METHOD = 2;
const STATIC_PROPERTY = 4;
const PROPERTY = 8;
/**
* Get a Reflector for a function, class or instance, constant, method or property.
*
* Optionally, pass a $filter param to restrict the types of members checked. For example, to only Reflectors for
* static properties and constants, pass:
*
* $filter = Mirror::CONSTANT | Mirror::STATIC_PROPERTY
*
* @throws \Psy\Exception\RuntimeException when a $member specified but not present on $value
* @throws \InvalidArgumentException if $value is something other than an object or class/function name
*
* @param mixed $value Class or function name, or variable instance
* @param string|null $member Optional: property, constant or method name (default: null)
* @param int $filter (default: CONSTANT | METHOD | PROPERTY | STATIC_PROPERTY)
*
* @return \Reflector
*/
public static function get($value, ?string $member = null, int $filter = 15): \Reflector
{
if ($member === null && \is_string($value)) {
if (\function_exists($value)) {
return new \ReflectionFunction($value);
} elseif (\defined($value) || ReflectionConstant::isMagicConstant($value)) {
return new ReflectionConstant($value);
}
}
$class = self::getClass($value);
if ($member === null) {
return $class;
} elseif ($filter & self::CONSTANT && $class->hasConstant($member)) {
return new \ReflectionClassConstant($value, $member);
} elseif ($filter & self::METHOD && $class->hasMethod($member)) {
return $class->getMethod($member);
} elseif ($filter & self::PROPERTY && $class->hasProperty($member)) {
return $class->getProperty($member);
} elseif ($filter & self::STATIC_PROPERTY && $class->hasProperty($member) && $class->getProperty($member)->isStatic()) {
return $class->getProperty($member);
} else {
throw new RuntimeException(\sprintf('Unknown member %s on class %s', $member, \is_object($value) ? \get_class($value) : $value));
}
}
/**
* Get a ReflectionClass (or ReflectionObject, or ReflectionNamespace) if possible.
*
* @throws \InvalidArgumentException if $value is not a namespace or class name or instance
*
* @param mixed $value
*
* @return \ReflectionClass|ReflectionNamespace
*/
private static function getClass($value)
{
if (\is_object($value)) {
return new \ReflectionObject($value);
}
if (!\is_string($value)) {
throw new \InvalidArgumentException('Mirror expects an object or class');
}
if (\class_exists($value) || \interface_exists($value) || \trait_exists($value)) {
return new \ReflectionClass($value);
}
$namespace = \preg_replace('/(^\\\\|\\\\$)/', '', $value);
if (self::namespaceExists($namespace)) {
return new ReflectionNamespace($namespace);
}
throw new \InvalidArgumentException('Unknown namespace, class or function: '.$value);
}
/**
* Check declared namespaces for a given namespace.
*/
private static function namespaceExists(string $value): bool
{
return \in_array(\strtolower($value), self::getDeclaredNamespaces());
}
/**
* Get an array of all currently declared namespaces.
*
* Note that this relies on at least one function, class, interface, trait
* or constant to have been declared in that namespace.
*/
private static function getDeclaredNamespaces(): array
{
$functions = \get_defined_functions();
$allNames = \array_merge(
$functions['internal'],
$functions['user'],
\get_declared_classes(),
\get_declared_interfaces(),
\get_declared_traits(),
\array_keys(\get_defined_constants())
);
$namespaces = [];
foreach ($allNames as $name) {
$chunks = \explode('\\', \strtolower($name));
// the last one is the function or class or whatever...
\array_pop($chunks);
while (!empty($chunks)) {
$namespaces[\implode('\\', $chunks)] = true;
\array_pop($chunks);
}
}
$namespaceNames = \array_keys($namespaces);
\sort($namespaceNames);
return $namespaceNames;
}
}

127
vendor/psy/psysh/src/Util/Str.php vendored Normal file
View File

@@ -0,0 +1,127 @@
<?php
/*
* This file is part of Psy Shell.
*
* (c) 2012-2025 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Psy\Util;
/**
* String utility methods.
*
* @author ju1ius
*/
class Str
{
const UNVIS_RX = <<<'EOS'
/
\\(?:
((?:040)|s)
| (240)
| (?: M-(.) )
| (?: M\^(.) )
| (?: \^(.) )
)
/xS
EOS;
/**
* Decodes a string encoded by libsd's strvis.
*
* From `man 3 vis`:
*
* Use an M to represent meta characters (characters with the 8th bit set),
* and use a caret ^ to represent control characters (see iscntrl(3)).
* The following formats are used:
*
* \040 Represents ASCII space.
*
* \240 Represents Meta-space (&nbsp in HTML).
*
* \M-C Represents character C with the 8th bit set.
* Spans characters \241 through \376.
*
* \M^C Represents control character C with the 8th bit set.
* Spans characters \200 through \237, and \377 (as \M^?).
*
* \^C Represents the control character C.
* Spans characters \000 through \037, and \177 (as \^?).
*
* The other formats are supported by PHP's stripcslashes,
* except for the \s sequence (ASCII space).
*
* @param string $input The string to decode
*/
public static function unvis(string $input): string
{
$output = \preg_replace_callback(self::UNVIS_RX, [self::class, 'unvisReplace'], $input);
// other escapes & octal are handled by stripcslashes
return \stripcslashes($output);
}
/**
* Callback for Str::unvis.
*
* @param array $match The matches passed by preg_replace_callback
*/
protected static function unvisReplace(array $match): string
{
// \040, \s
if (!empty($match[1])) {
return "\x20";
}
// \240
if (!empty($match[2])) {
return "\xa0";
}
// \M-(.)
if (isset($match[3]) && $match[3] !== '') {
$chr = $match[3];
// unvis S_META1
$cp = 0200;
$cp |= \ord($chr);
return \chr($cp);
}
// \M^(.)
if (isset($match[4]) && $match[4] !== '') {
$chr = $match[4];
// unvis S_META | S_CTRL
$cp = 0200;
$cp |= ($chr === '?') ? 0177 : \ord($chr) & 037;
return \chr($cp);
}
// \^(.)
if (isset($match[5]) && $match[5] !== '') {
$chr = $match[5];
// unvis S_CTRL
$cp = 0;
$cp |= ($chr === '?') ? 0177 : \ord($chr) & 037;
return \chr($cp);
}
}
/**
* Check whether a given string is a valid PHP class name.
*
* Validates that the name follows PHP identifier rules, with optional
* namespace separators.
*
* @param string $name The name to check
*
* @return bool True if the name is syntactically valid
*/
public static function isValidClassName(string $name): bool
{
// Regex based on https://www.php.net/manual/en/language.oop5.basic.php#language.oop5.basic.class
return \preg_match('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*(\\\\[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)*$/', $name) === 1;
}
}