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
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:
173
vendor/psy/psysh/src/Reflection/ReflectionConstant.php
vendored
Normal file
173
vendor/psy/psysh/src/Reflection/ReflectionConstant.php
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
<?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\Reflection;
|
||||
|
||||
/**
|
||||
* Somehow the standard reflection library doesn't include constants.
|
||||
*
|
||||
* ReflectionConstant corrects that omission.
|
||||
*/
|
||||
class ReflectionConstant implements \Reflector
|
||||
{
|
||||
public $name;
|
||||
/** @var mixed */
|
||||
private $value;
|
||||
|
||||
private const MAGIC_CONSTANTS = [
|
||||
'__LINE__',
|
||||
'__FILE__',
|
||||
'__DIR__',
|
||||
'__FUNCTION__',
|
||||
'__CLASS__',
|
||||
'__TRAIT__',
|
||||
'__METHOD__',
|
||||
'__NAMESPACE__',
|
||||
'__COMPILER_HALT_OFFSET__',
|
||||
];
|
||||
|
||||
/**
|
||||
* Construct a ReflectionConstant object.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
if (!\defined($name) && !self::isMagicConstant($name)) {
|
||||
throw new \InvalidArgumentException('Unknown constant: '.$name);
|
||||
}
|
||||
|
||||
if (!self::isMagicConstant($name)) {
|
||||
$this->value = @\constant($name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports a reflection.
|
||||
*
|
||||
* @param string $name
|
||||
* @param bool $return pass true to return the export, as opposed to emitting it
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function export(string $name, bool $return = false)
|
||||
{
|
||||
$refl = new self($name);
|
||||
$value = $refl->getValue();
|
||||
|
||||
$str = \sprintf('Constant [ %s %s ] { %s }', \gettype($value), $refl->getName(), $value);
|
||||
|
||||
if ($return) {
|
||||
return $str;
|
||||
}
|
||||
|
||||
echo $str."\n";
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function isMagicConstant($name)
|
||||
{
|
||||
return \in_array($name, self::MAGIC_CONSTANTS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the constant's docblock.
|
||||
*
|
||||
* @return false
|
||||
*/
|
||||
public function getDocComment(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the constant name.
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the namespace name.
|
||||
*
|
||||
* Returns '' when the constant is not namespaced.
|
||||
*/
|
||||
public function getNamespaceName(): string
|
||||
{
|
||||
if (!$this->inNamespace()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return \preg_replace('/\\\\[^\\\\]+$/', '', $this->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the constant.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this constant is defined in a namespace.
|
||||
*/
|
||||
public function inNamespace(): bool
|
||||
{
|
||||
return \strpos($this->name, '\\') !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the constant's file name.
|
||||
*
|
||||
* Currently returns null, because if it returns a file name the signature
|
||||
* formatter will barf.
|
||||
*/
|
||||
public function getFileName()
|
||||
{
|
||||
return;
|
||||
// return $this->class->getFileName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the code start line.
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function getStartLine()
|
||||
{
|
||||
throw new \RuntimeException('Not yet implemented because it\'s unclear what I should do here :)');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the code end line.
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function getEndLine()
|
||||
{
|
||||
return $this->getStartLine();
|
||||
}
|
||||
}
|
||||
159
vendor/psy/psysh/src/Reflection/ReflectionLanguageConstruct.php
vendored
Normal file
159
vendor/psy/psysh/src/Reflection/ReflectionLanguageConstruct.php
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
<?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\Reflection;
|
||||
|
||||
/**
|
||||
* A fake ReflectionFunction but for language constructs.
|
||||
*/
|
||||
class ReflectionLanguageConstruct extends \ReflectionFunctionAbstract
|
||||
{
|
||||
public $keyword;
|
||||
|
||||
/**
|
||||
* Language construct parameter definitions.
|
||||
*/
|
||||
private const LANGUAGE_CONSTRUCTS = [
|
||||
'isset' => [
|
||||
'var' => [],
|
||||
'...' => [
|
||||
'isOptional' => true,
|
||||
'defaultValue' => null,
|
||||
],
|
||||
],
|
||||
|
||||
'unset' => [
|
||||
'var' => [],
|
||||
'...' => [
|
||||
'isOptional' => true,
|
||||
'defaultValue' => null,
|
||||
],
|
||||
],
|
||||
|
||||
'empty' => [
|
||||
'var' => [],
|
||||
],
|
||||
|
||||
'echo' => [
|
||||
'arg1' => [],
|
||||
'...' => [
|
||||
'isOptional' => true,
|
||||
'defaultValue' => null,
|
||||
],
|
||||
],
|
||||
|
||||
'print' => [
|
||||
'arg' => [],
|
||||
],
|
||||
|
||||
'die' => [
|
||||
'status' => [
|
||||
'isOptional' => true,
|
||||
'defaultValue' => 0,
|
||||
],
|
||||
],
|
||||
|
||||
'exit' => [
|
||||
'status' => [
|
||||
'isOptional' => true,
|
||||
'defaultValue' => 0,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Construct a ReflectionLanguageConstruct object.
|
||||
*
|
||||
* @param string $keyword
|
||||
*/
|
||||
public function __construct(string $keyword)
|
||||
{
|
||||
if (!self::isLanguageConstruct($keyword)) {
|
||||
throw new \InvalidArgumentException('Unknown language construct: '.$keyword);
|
||||
}
|
||||
|
||||
$this->keyword = $keyword;
|
||||
}
|
||||
|
||||
/**
|
||||
* This can't (and shouldn't) do anything :).
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public static function export($name)
|
||||
{
|
||||
throw new \RuntimeException('Not yet implemented because it\'s unclear what I should do here :)');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get language construct name.
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->keyword;
|
||||
}
|
||||
|
||||
/**
|
||||
* None of these return references.
|
||||
*/
|
||||
public function returnsReference(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get language construct params.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getParameters(): array
|
||||
{
|
||||
$params = [];
|
||||
foreach (self::LANGUAGE_CONSTRUCTS[$this->keyword] as $parameter => $opts) {
|
||||
$params[] = new ReflectionLanguageConstructParameter($this->keyword, $parameter, $opts);
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the file name from a language construct.
|
||||
*
|
||||
* (Hint: it always returns false)
|
||||
*
|
||||
* @todo remove \ReturnTypeWillChange attribute after dropping support for PHP 7.x (when we can use union types)
|
||||
*
|
||||
* @return string|false (false)
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getFileName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether keyword is a (known) language construct.
|
||||
*
|
||||
* @param string $keyword
|
||||
*/
|
||||
public static function isLanguageConstruct(string $keyword): bool
|
||||
{
|
||||
return \array_key_exists($keyword, self::LANGUAGE_CONSTRUCTS);
|
||||
}
|
||||
}
|
||||
115
vendor/psy/psysh/src/Reflection/ReflectionLanguageConstructParameter.php
vendored
Normal file
115
vendor/psy/psysh/src/Reflection/ReflectionLanguageConstructParameter.php
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
<?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\Reflection;
|
||||
|
||||
/**
|
||||
* A fake ReflectionParameter but for language construct parameters.
|
||||
*
|
||||
* It stubs out all the important bits and returns whatever was passed in $opts.
|
||||
*/
|
||||
class ReflectionLanguageConstructParameter extends \ReflectionParameter
|
||||
{
|
||||
/** @var string|array|object */
|
||||
private $function;
|
||||
/** @var int|string */
|
||||
private $parameter;
|
||||
private array $opts;
|
||||
|
||||
/**
|
||||
* @param string|array|object $function
|
||||
* @param int|string $parameter
|
||||
* @param array $opts
|
||||
*/
|
||||
public function __construct($function, $parameter, array $opts)
|
||||
{
|
||||
$this->function = $function;
|
||||
$this->parameter = $parameter;
|
||||
$this->opts = $opts;
|
||||
}
|
||||
|
||||
/**
|
||||
* No class here.
|
||||
*/
|
||||
public function getClass(): ?\ReflectionClass
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the param an array?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isArray(): bool
|
||||
{
|
||||
return \array_key_exists('isArray', $this->opts) && $this->opts['isArray'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get param default value.
|
||||
*
|
||||
* @todo remove \ReturnTypeWillChange attribute after dropping support for PHP 7.x (when we can use mixed type)
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getDefaultValue()
|
||||
{
|
||||
if ($this->isDefaultValueAvailable()) {
|
||||
return $this->opts['defaultValue'];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get param name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->parameter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the param optional?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isOptional(): bool
|
||||
{
|
||||
return \array_key_exists('isOptional', $this->opts) && $this->opts['isOptional'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the param have a default value?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDefaultValueAvailable(): bool
|
||||
{
|
||||
return \array_key_exists('defaultValue', $this->opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the param passed by reference?
|
||||
*
|
||||
* (I don't think this is true for anything we need to fake a param for)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isPassedByReference(): bool
|
||||
{
|
||||
return \array_key_exists('isPassedByReference', $this->opts) && $this->opts['isPassedByReference'];
|
||||
}
|
||||
}
|
||||
60
vendor/psy/psysh/src/Reflection/ReflectionNamespace.php
vendored
Normal file
60
vendor/psy/psysh/src/Reflection/ReflectionNamespace.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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\Reflection;
|
||||
|
||||
/**
|
||||
* A fake Reflector for namespaces.
|
||||
*/
|
||||
class ReflectionNamespace implements \Reflector
|
||||
{
|
||||
private string $name;
|
||||
|
||||
/**
|
||||
* Construct a ReflectionNamespace object.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the constant name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* This can't (and shouldn't) do anything :).
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public static function export($name)
|
||||
{
|
||||
throw new \RuntimeException('Not yet implemented because it\'s unclear what I should do here :)');
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->getName();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user