mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-03-17 20:54:52 +08:00
cs-fix
This commit is contained in:
parent
2d9f879994
commit
ef1a9646e4
@ -66,6 +66,8 @@ return (new PhpCsFixer\Config())
|
||||
'multiline_comment_opening_closing' => true,
|
||||
'phpdoc_summary' => false,
|
||||
'php_unit_test_class_requires_covers' => false,
|
||||
'fully_qualified_strict_types' => false,
|
||||
'new_with_parentheses' => false,
|
||||
])
|
||||
->setFinder(
|
||||
PhpCsFixer\Finder::create()
|
||||
|
||||
@ -65,7 +65,7 @@ define('WORKING_DIR', getcwd());
|
||||
define('SOURCE_ROOT_DIR', Phar::running() !== '' ? Phar::running() : WORKING_DIR);
|
||||
|
||||
if (DIRECTORY_SEPARATOR === '\\') {
|
||||
define('TMP_DIR', 'C:\\Windows\\Temp');
|
||||
define('TMP_DIR', 'C:\Windows\Temp');
|
||||
} elseif (!empty(getenv('TMPDIR'))) {
|
||||
define('TMP_DIR', getenv('TMPDIR'));
|
||||
} elseif (is_writable('/tmp')) {
|
||||
|
||||
@ -13,7 +13,6 @@ use OneBot\Driver\Workerman\WebSocketClient;
|
||||
use OneBot\V12\Object\MessageSegment;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use ZM\Config\Environment;
|
||||
use ZM\Config\ZMConfig;
|
||||
use ZM\Container\ContainerHolder;
|
||||
@ -148,7 +147,7 @@ function is_assoc_array(array $array): bool
|
||||
*/
|
||||
function match_pattern(string $pattern, string $subject): bool
|
||||
{
|
||||
$pattern = str_replace(['\*', '\\\\.*'], ['.*', '\*'], preg_quote($pattern, '/'));
|
||||
$pattern = str_replace(['\*', '\\\.*'], ['.*', '\*'], preg_quote($pattern, '/'));
|
||||
$pattern = '/^' . $pattern . '$/i';
|
||||
return preg_match($pattern, $subject) === 1;
|
||||
}
|
||||
@ -302,7 +301,7 @@ function redis(string $name = 'default'): RedisWrapper
|
||||
* @param null|mixed $default 默认值
|
||||
* @return mixed|void|ZMConfig
|
||||
*/
|
||||
function config(array|string $key = null, mixed $default = null)
|
||||
function config(null|array|string $key = null, mixed $default = null)
|
||||
{
|
||||
$config = ZMConfig::getInstance();
|
||||
if (is_null($key)) {
|
||||
@ -329,7 +328,6 @@ function bot_connect(int $flag, int $fd)
|
||||
* 获取一个 KV 库实例
|
||||
*
|
||||
* @param string $name KV 库名称
|
||||
* @return CacheInterface
|
||||
*/
|
||||
function kv(string $name = ''): Psr\SimpleCache\CacheInterface
|
||||
{
|
||||
|
||||
@ -49,6 +49,6 @@ function _zm_setup_loader()
|
||||
|
||||
// 在*nix等支持多进程环境的情况,可直接运行此文件,那么就执行
|
||||
if (debug_backtrace() === []) {
|
||||
require((!is_dir(__DIR__ . '/../../vendor')) ? getcwd() : (__DIR__ . '/../..')) . '/vendor/autoload.php';
|
||||
require ((!is_dir(__DIR__ . '/../../vendor')) ? getcwd() : (__DIR__ . '/../..')) . '/vendor/autoload.php';
|
||||
echo _zm_setup_loader();
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ namespace ZM\Annotation;
|
||||
abstract class AnnotationBase implements \IteratorAggregate, \Stringable
|
||||
{
|
||||
/** @var array|\Closure|string 方法名或闭包 */
|
||||
public \Closure|string|array $method = '';
|
||||
public array|\Closure|string $method = '';
|
||||
|
||||
public $class = '';
|
||||
|
||||
@ -40,7 +40,7 @@ abstract class AnnotationBase implements \IteratorAggregate, \Stringable
|
||||
/**
|
||||
* 在 InstantPlugin 下调用,设置回调或匿名函数
|
||||
*/
|
||||
public function on(\Closure|callable|string $method): AnnotationBase
|
||||
public function on(callable|\Closure|string $method): AnnotationBase
|
||||
{
|
||||
$this->method = $method;
|
||||
return $this;
|
||||
|
||||
@ -21,7 +21,7 @@ class AnnotationHandler
|
||||
|
||||
public const STATUS_RULE_FAILED = 4; // 判断事件执行的规则函数判定为false,所以不执行此方法
|
||||
|
||||
private string|AnnotationBase $annotation_class;
|
||||
private AnnotationBase|string $annotation_class;
|
||||
|
||||
/** @var callable */
|
||||
private $rule_callback;
|
||||
|
||||
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
|
||||
@ -15,6 +14,4 @@ use Doctrine\Common\Annotations\Annotation\Target;
|
||||
* @Target("ALL")
|
||||
*/
|
||||
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_ALL)]
|
||||
class Closed extends AnnotationBase
|
||||
{
|
||||
}
|
||||
class Closed extends AnnotationBase {}
|
||||
|
||||
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Annotation\Framework;
|
||||
|
||||
use Attribute;
|
||||
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||
use Doctrine\Common\Annotations\Annotation\Required;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
@ -32,8 +31,7 @@ class BindEvent extends AnnotationBase implements Level
|
||||
*/
|
||||
public string $event_class,
|
||||
public int $level = 800
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function getLevel(): int
|
||||
{
|
||||
|
||||
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Annotation\Framework;
|
||||
|
||||
use Attribute;
|
||||
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
use ZM\Annotation\AnnotationBase;
|
||||
@ -20,9 +19,7 @@ use ZM\Annotation\Interfaces\Level;
|
||||
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
|
||||
class Init extends AnnotationBase implements Level
|
||||
{
|
||||
public function __construct(public int $worker = 0, public int $level = 20)
|
||||
{
|
||||
}
|
||||
public function __construct(public int $worker = 0, public int $level = 20) {}
|
||||
|
||||
public function getLevel()
|
||||
{
|
||||
|
||||
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Annotation\Framework;
|
||||
|
||||
use Attribute;
|
||||
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
use ZM\Annotation\AnnotationBase;
|
||||
@ -17,6 +16,4 @@ use ZM\Annotation\AnnotationBase;
|
||||
* @since 3.0.0
|
||||
*/
|
||||
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
|
||||
class Setup extends AnnotationBase
|
||||
{
|
||||
}
|
||||
class Setup extends AnnotationBase {}
|
||||
|
||||
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Annotation\Http;
|
||||
|
||||
use Attribute;
|
||||
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||
use Doctrine\Common\Annotations\Annotation\Required;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
@ -25,6 +24,5 @@ class Controller extends AnnotationBase implements ErgodicAnnotation
|
||||
* @Required()
|
||||
*/
|
||||
public string $prefix
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Annotation\Http;
|
||||
|
||||
use Attribute;
|
||||
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||
use Doctrine\Common\Annotations\Annotation\Required;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
@ -30,8 +29,7 @@ class Route extends AnnotationBase
|
||||
* Routing path params binding. eg. {"id"="\d+"}
|
||||
*/
|
||||
public $params = []
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public static function make($route, $name = '', $request_method = ['GET', 'POST'], $params = []): static
|
||||
{
|
||||
|
||||
@ -4,6 +4,4 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Annotation\Interfaces;
|
||||
|
||||
interface CustomAnnotation
|
||||
{
|
||||
}
|
||||
interface CustomAnnotation {}
|
||||
|
||||
@ -4,6 +4,4 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Annotation\Interfaces;
|
||||
|
||||
interface ErgodicAnnotation
|
||||
{
|
||||
}
|
||||
interface ErgodicAnnotation {}
|
||||
|
||||
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Annotation\Middleware;
|
||||
|
||||
use Attribute;
|
||||
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||
use Doctrine\Common\Annotations\Annotation\Required;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
@ -22,6 +21,7 @@ class Middleware extends AnnotationBase implements ErgodicAnnotation
|
||||
{
|
||||
/**
|
||||
* @param string[] $args
|
||||
* @param mixed $name
|
||||
*/
|
||||
public function __construct(
|
||||
/**
|
||||
@ -29,6 +29,5 @@ class Middleware extends AnnotationBase implements ErgodicAnnotation
|
||||
*/
|
||||
public $name,
|
||||
public array $args = []
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
}
|
||||
|
||||
@ -17,9 +17,7 @@ use ZM\Annotation\Interfaces\Level;
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
class BotAction extends AnnotationBase implements Level
|
||||
{
|
||||
public function __construct(public string $action = '', public bool $need_response = false, public int $level = 20)
|
||||
{
|
||||
}
|
||||
public function __construct(public string $action = '', public bool $need_response = false, public int $level = 20) {}
|
||||
|
||||
public static function make(callable $callback, string $action, bool $need_response = false, int $level = 20): BotAction
|
||||
{
|
||||
|
||||
@ -20,9 +20,7 @@ use ZM\Annotation\Interfaces\Level;
|
||||
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
|
||||
class BotActionResponse extends AnnotationBase implements Level
|
||||
{
|
||||
public function __construct(public ?string $status = null, public ?int $retcode = null, public int $level = 20)
|
||||
{
|
||||
}
|
||||
public function __construct(public ?string $status = null, public ?int $retcode = null, public int $level = 20) {}
|
||||
|
||||
public function getLevel()
|
||||
{
|
||||
|
||||
@ -39,8 +39,7 @@ class BotCommand extends AnnotationBase implements Level
|
||||
public string $detail_type = '',
|
||||
public string $prefix = '',
|
||||
public int $level = 20
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public static function make(
|
||||
string $name = '',
|
||||
|
||||
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Annotation\OneBot;
|
||||
|
||||
use Attribute;
|
||||
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
use ZM\Annotation\AnnotationBase;
|
||||
@ -20,9 +19,7 @@ use ZM\Annotation\Interfaces\Level;
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
class BotEvent extends AnnotationBase implements Level
|
||||
{
|
||||
public function __construct(public ?string $type = null, public ?string $detail_type = null, public ?string $sub_type = null, public int $level = 20)
|
||||
{
|
||||
}
|
||||
public function __construct(public ?string $type = null, public ?string $detail_type = null, public ?string $sub_type = null, public int $level = 20) {}
|
||||
|
||||
public static function make(
|
||||
?string $type = null,
|
||||
|
||||
@ -41,7 +41,7 @@ class CommandArgument extends AnnotationBase implements ErgodicAnnotation
|
||||
string $type = 'string',
|
||||
public bool $required = false,
|
||||
public string $prompt = '',
|
||||
public string|\Closure|array|int|float|null $default = '',
|
||||
public null|array|\Closure|float|int|string $default = '',
|
||||
public int $timeout = 60,
|
||||
public int $error_prompt_policy = 1
|
||||
) {
|
||||
|
||||
@ -22,8 +22,7 @@ class CommandHelp extends AnnotationBase
|
||||
public string $description,
|
||||
public string $usage,
|
||||
public string $example,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public static function make(
|
||||
string $description,
|
||||
|
||||
@ -83,7 +83,7 @@ class BuildCommand extends Command
|
||||
$separator = '\\' . DIRECTORY_SEPARATOR;
|
||||
// 只打包 bin / config / resources / src / vendor 目录以及 composer.json / composer.lock / entry.php
|
||||
$files = array_filter($files, function ($file) use ($separator) {
|
||||
return preg_match('/^(bin|config|resources|src|vendor)' . $separator . '|^(composer\\.json|README\\.md)$/', $file);
|
||||
return preg_match('/^(bin|config|resources|src|vendor)' . $separator . '|^(composer\.json|README\.md)$/', $file);
|
||||
});
|
||||
sort($files);
|
||||
|
||||
|
||||
@ -26,7 +26,6 @@ abstract class Command extends \Symfony\Component\Console\Command\Command implem
|
||||
protected OutputInterface $output;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @internal 不建议覆写此方法,建议使用 {@see handle()} 方法
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
|
||||
@ -18,9 +18,6 @@ class TextGenerateCommand extends Command
|
||||
$this->setDescription('生成一些框架本身的文本(内部' . PHP_EOL . '当前包含:class-alias-md,update-log-md');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function handle(): int
|
||||
{
|
||||
return match ($this->input->getArgument('name')) {
|
||||
|
||||
@ -20,9 +20,6 @@ class PluginInstallCommand extends PluginCommand
|
||||
$this->addOption('github-token', null, InputOption::VALUE_REQUIRED, '提供的 GitHub Token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function handle(): int
|
||||
{
|
||||
$addr = $this->input->getArgument('address');
|
||||
|
||||
@ -27,7 +27,6 @@ class PluginMakeCommand extends PluginCommand
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
protected function handle(): int
|
||||
|
||||
@ -19,9 +19,6 @@ class PluginPackCommand extends PluginCommand
|
||||
$this->addOption('build-dir', 'D', InputOption::VALUE_REQUIRED, '指定输出文件位置', WORKING_DIR . '/build');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function handle(): int
|
||||
{
|
||||
try {
|
||||
|
||||
@ -17,9 +17,6 @@ class PluginRemoveCommand extends PluginCommand
|
||||
$this->addArgument('name', InputArgument::REQUIRED, '插件名称');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function handle(): int
|
||||
{
|
||||
$plugin_name = $this->input->getArgument('name');
|
||||
|
||||
@ -29,9 +29,6 @@ class Environment implements EnvironmentInterface
|
||||
$this->values = $values + $_ENV + $_SERVER;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set(string $name, mixed $value): self
|
||||
{
|
||||
if (array_key_exists($name, $this->values) && !$this->overwrite) {
|
||||
@ -45,9 +42,6 @@ class Environment implements EnvironmentInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get(string $name, mixed $default = null): mixed
|
||||
{
|
||||
if (isset($this->values[$name])) {
|
||||
@ -57,9 +51,6 @@ class Environment implements EnvironmentInterface
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAll(): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
@ -14,7 +14,7 @@ class RuntimePreferences
|
||||
|
||||
protected string $config_dir = SOURCE_ROOT_DIR . '/config';
|
||||
|
||||
public function environment(...$environments): string|bool
|
||||
public function environment(...$environments): bool|string
|
||||
{
|
||||
if (empty($environments)) {
|
||||
return $this->environment;
|
||||
|
||||
@ -64,7 +64,7 @@ class ZMConfig
|
||||
*
|
||||
* @throws ConfigException 配置文件加载出错
|
||||
*/
|
||||
public function __construct(array $init_config = null)
|
||||
public function __construct(?array $init_config = null)
|
||||
{
|
||||
// 合并初始化配置,构造传入优先
|
||||
$conf = array_merge_recursive($this->loadInitConfig(), $init_config ?? []);
|
||||
@ -332,7 +332,7 @@ class ZMConfig
|
||||
// 读取并解析配置
|
||||
$content = file_get_contents($path);
|
||||
// TODO: 使用 Loader 替代
|
||||
// $config = $this->loader->load($path);
|
||||
// $config = $this->loader->load($path);
|
||||
$config = [];
|
||||
switch ($ext) {
|
||||
case 'php':
|
||||
|
||||
@ -46,9 +46,6 @@ final class ConsoleApplication extends Application
|
||||
self::$obj = $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function doRun(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
try {
|
||||
@ -73,9 +70,6 @@ final class ConsoleApplication extends Application
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
// 初始化内核
|
||||
@ -99,7 +93,7 @@ final class ConsoleApplication extends Application
|
||||
// 先加载框架内置命令
|
||||
$command_classes = array_merge(
|
||||
$command_classes,
|
||||
FileSystem::getClassesPsr4(FRAMEWORK_ROOT_DIR . '/src/ZM/Command', 'ZM\\Command')
|
||||
FileSystem::getClassesPsr4(FRAMEWORK_ROOT_DIR . '/src/ZM/Command', 'ZM\Command')
|
||||
);
|
||||
// 再加载用户自定义命令(如存在)
|
||||
if (is_dir(SOURCE_ROOT_DIR . '/src/Command')) {
|
||||
|
||||
@ -28,9 +28,7 @@ class ContainerBindingListener
|
||||
}
|
||||
}
|
||||
|
||||
public static function callback(): void
|
||||
{
|
||||
}
|
||||
public static function callback(): void {}
|
||||
|
||||
public static function cleanCallback(): void
|
||||
{
|
||||
|
||||
@ -15,9 +15,7 @@ class BotConnectContext
|
||||
|
||||
protected ?array $self = null;
|
||||
|
||||
public function __construct(private int $flag, private int $fd)
|
||||
{
|
||||
}
|
||||
public function __construct(private int $flag, private int $fd) {}
|
||||
|
||||
public function getFd(): int
|
||||
{
|
||||
|
||||
@ -54,7 +54,7 @@ class BotContext implements ContextInterface
|
||||
* @noinspection PhpDocMissingThrowsInspection
|
||||
* @noinspection PhpUnhandledExceptionInspection
|
||||
*/
|
||||
public function reply(\Stringable|MessageSegment|array|string $message, int $reply_mode = ZM_REPLY_NONE): ActionResponse|bool
|
||||
public function reply(array|MessageSegment|string|\Stringable $message, int $reply_mode = ZM_REPLY_NONE): ActionResponse|bool
|
||||
{
|
||||
if (container()->has('bot.event')) {
|
||||
// 这里直接使用当前上下文的事件里面的参数,不再重新挨个获取怎么发消息的参数
|
||||
@ -87,7 +87,7 @@ class BotContext implements ContextInterface
|
||||
* @noinspection PhpDocMissingThrowsInspection
|
||||
* @noinspection PhpUnhandledExceptionInspection
|
||||
*/
|
||||
public function prompt(string|\Stringable|MessageSegment|array $prompt = '', int $timeout = 600, string|\Stringable|MessageSegment|array $timeout_prompt = '', int $option = ZM_PROMPT_NONE): null|OneBotEvent|array|string
|
||||
public function prompt(array|MessageSegment|string|\Stringable $prompt = '', int $timeout = 600, array|MessageSegment|string|\Stringable $timeout_prompt = '', int $option = ZM_PROMPT_NONE): null|array|OneBotEvent|string
|
||||
{
|
||||
if (!container()->has('bot.event')) {
|
||||
throw new OneBot12Exception('bot()->prompt() can only be used in message event');
|
||||
@ -135,7 +135,7 @@ class BotContext implements ContextInterface
|
||||
* 如果是多级群组,则等待最小级下当前消息人的消息
|
||||
* @noinspection PhpUnhandledExceptionInspection
|
||||
*/
|
||||
public function promptString(string|\Stringable|MessageSegment|array $prompt = '', int $timeout = 600, string|\Stringable|MessageSegment|array $timeout_prompt = '', int $option = ZM_PROMPT_NONE): string
|
||||
public function promptString(array|MessageSegment|string|\Stringable $prompt = '', int $timeout = 600, array|MessageSegment|string|\Stringable $timeout_prompt = '', int $option = ZM_PROMPT_NONE): string
|
||||
{
|
||||
return $this->prompt($prompt, $timeout, $timeout_prompt, $option | ZM_PROMPT_RETURN_STRING);
|
||||
}
|
||||
@ -194,12 +194,12 @@ class BotContext implements ContextInterface
|
||||
*
|
||||
* @param int|string $name 参数名称或索引
|
||||
*/
|
||||
public function getParam(string|int $name): mixed
|
||||
public function getParam(int|string $name): mixed
|
||||
{
|
||||
return $this->params[$name] ?? null;
|
||||
}
|
||||
|
||||
public function getParamString(string|int $name): ?string
|
||||
public function getParamString(int|string $name): ?string
|
||||
{
|
||||
return MessageUtil::getAltMessage($this->params[$name] ?? null);
|
||||
}
|
||||
@ -242,7 +242,7 @@ class BotContext implements ContextInterface
|
||||
* @param OneBotEvent $event 事件对象
|
||||
* @return array 消息段
|
||||
*/
|
||||
private function applyPromptMode(int $option, array|string|\Stringable|MessageSegment $prompt, OneBotEvent $event): array
|
||||
private function applyPromptMode(int $option, array|MessageSegment|string|\Stringable $prompt, OneBotEvent $event): array
|
||||
{
|
||||
// 先格式化消息
|
||||
if ($prompt instanceof MessageSegment) {
|
||||
@ -268,7 +268,7 @@ class BotContext implements ContextInterface
|
||||
* @return null|array|OneBotEvent|string 根据不同匹配类型返回不同的东西
|
||||
* @throws OneBot12Exception
|
||||
*/
|
||||
private function applyPromptReturn(mixed $result, int $option): null|OneBotEvent|array|string
|
||||
private function applyPromptReturn(mixed $result, int $option): null|array|OneBotEvent|string
|
||||
{
|
||||
// 必须是 OneBotEvent 且是消息类型
|
||||
if (!$result instanceof OneBotEvent || $result->type !== 'message') {
|
||||
|
||||
@ -4,6 +4,4 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Context;
|
||||
|
||||
interface ContextInterface
|
||||
{
|
||||
}
|
||||
interface ContextInterface {}
|
||||
|
||||
@ -35,7 +35,7 @@ trait BotActionTrait
|
||||
* @param array|MessageSegment|string|\Stringable $message 消息内容,可以是消息段、字符串
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function sendMessage(\Stringable|array|MessageSegment|string $message, string $detail_type, array $params = []): ActionResponse|bool
|
||||
public function sendMessage(array|MessageSegment|string|\Stringable $message, string $detail_type, array $params = []): ActionResponse|bool
|
||||
{
|
||||
$message = MessageUtil::convertToArr($message);
|
||||
$params['message'] = $message;
|
||||
@ -48,7 +48,7 @@ trait BotActionTrait
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function sendAction(string $action, array $params = [], ?array $self = null): bool|ActionResponse
|
||||
public function sendAction(string $action, array $params = [], ?array $self = null): ActionResponse|bool
|
||||
{
|
||||
if ($self === null && $this->self !== null) {
|
||||
$self = $this->self;
|
||||
|
||||
@ -110,8 +110,7 @@ class WorkerEventListener
|
||||
}
|
||||
// Windows 系统的 CtrlC 由于和 Select 有一定的冲突,如果没事件解析的话 CtrlC 会阻塞,所以必须添加一个空的计时器
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
Framework::getInstance()->getDriver()->getEventLoop()->addTimer(1000, function () {
|
||||
}, 0);
|
||||
Framework::getInstance()->getDriver()->getEventLoop()->addTimer(1000, function () {}, 0);
|
||||
}
|
||||
// 回显 debug 日志:进程占用的内存
|
||||
$memory_total = memory_get_usage() / 1024 / 1024;
|
||||
|
||||
@ -4,6 +4,4 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Exception;
|
||||
|
||||
class DriverException extends ZMException
|
||||
{
|
||||
}
|
||||
class DriverException extends ZMException {}
|
||||
|
||||
@ -4,6 +4,4 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Exception;
|
||||
|
||||
class FileSystemException extends ZMException
|
||||
{
|
||||
}
|
||||
class FileSystemException extends ZMException {}
|
||||
|
||||
@ -7,6 +7,4 @@ namespace ZM\Exception;
|
||||
/**
|
||||
* 初始化命令(./zhamao init)出现的错误
|
||||
*/
|
||||
class InitException extends ZMException
|
||||
{
|
||||
}
|
||||
class InitException extends ZMException {}
|
||||
|
||||
@ -6,7 +6,7 @@ namespace ZM\Exception;
|
||||
|
||||
class InterruptException extends ZMException
|
||||
{
|
||||
public function __construct(public $return_var = null, $message = '', $code = 0, \Throwable $previous = null)
|
||||
public function __construct(public $return_var = null, $message = '', $code = 0, ?\Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
@ -4,6 +4,4 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Exception;
|
||||
|
||||
class InvalidArgumentException extends ZMException
|
||||
{
|
||||
}
|
||||
class InvalidArgumentException extends ZMException {}
|
||||
|
||||
@ -4,6 +4,4 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Exception;
|
||||
|
||||
class OneBot12Exception extends PluginException
|
||||
{
|
||||
}
|
||||
class OneBot12Exception extends PluginException {}
|
||||
|
||||
@ -7,6 +7,4 @@ namespace ZM\Exception;
|
||||
/**
|
||||
* 插件加载器出现的错误
|
||||
*/
|
||||
class PluginException extends ZMException
|
||||
{
|
||||
}
|
||||
class PluginException extends ZMException {}
|
||||
|
||||
@ -10,8 +10,7 @@ class Solution
|
||||
private string $title,
|
||||
private string $description,
|
||||
private array $links,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function getSolutionTitle(): string
|
||||
{
|
||||
|
||||
@ -14,11 +14,11 @@ class WaitTimeoutException extends ZMException
|
||||
|
||||
public function __construct(
|
||||
public mixed $module,
|
||||
string|\MessageSegment|array|\Stringable $timeout_prompt = '',
|
||||
array|\MessageSegment|string|\Stringable $timeout_prompt = '',
|
||||
private ?ActionResponse $prompt_response = null,
|
||||
private ?OneBotEvent $user_event = null,
|
||||
private int $prompt_option = ZM_PROMPT_NONE,
|
||||
\Throwable $previous = null
|
||||
?\Throwable $previous = null
|
||||
) {
|
||||
parent::__construct('wait timeout!', 0, $previous);
|
||||
if ($timeout_prompt === '') {
|
||||
|
||||
@ -4,6 +4,4 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Exception;
|
||||
|
||||
abstract class ZMException extends \Exception
|
||||
{
|
||||
}
|
||||
abstract class ZMException extends \Exception {}
|
||||
|
||||
@ -9,7 +9,7 @@ use JetBrains\PhpStorm\Deprecated;
|
||||
#[Deprecated(reason: '建议使用具体的异常类')]
|
||||
class ZMKnownException extends ZMException
|
||||
{
|
||||
public function __construct($err_code, $message = '', $code = 0, \Throwable $previous = null)
|
||||
public function __construct($err_code, $message = '', $code = 0, ?\Throwable $previous = null)
|
||||
{
|
||||
parent::__construct(zm_internal_errcode($err_code) . $message, $code, $previous);
|
||||
if ($err_code === 'E99999') {
|
||||
|
||||
@ -61,7 +61,7 @@ class Framework
|
||||
protected array $argv;
|
||||
|
||||
/** @var null|Driver|SwooleDriver|WorkermanDriver OneBot驱动 */
|
||||
protected SwooleDriver|Driver|WorkermanDriver|null $driver = null;
|
||||
protected null|Driver|SwooleDriver|WorkermanDriver $driver = null;
|
||||
|
||||
/** @var array<array<string, string>> 启动注解列表 */
|
||||
protected array $setup_annotations = [];
|
||||
|
||||
@ -4,6 +4,4 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Middleware;
|
||||
|
||||
interface MiddlewareInterface
|
||||
{
|
||||
}
|
||||
interface MiddlewareInterface {}
|
||||
|
||||
@ -41,7 +41,7 @@ class WebSocketFilter implements MiddlewareInterface, PipelineInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
private function filterMessageAndClose(WebSocketMessageEvent|WebSocketCloseEvent $event): bool
|
||||
private function filterMessageAndClose(WebSocketCloseEvent|WebSocketMessageEvent $event): bool
|
||||
{
|
||||
// 过滤存在 flag 设置的情况
|
||||
if (($this->args['flag'] ?? null) !== null && $this->args['flag'] !== $event->getSocketFlag()) {
|
||||
|
||||
@ -10,9 +10,7 @@ use ZM\Annotation\OneBot\CommandHelp;
|
||||
|
||||
class StaticManualFactory
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
public function __construct() {}
|
||||
|
||||
public function __invoke(BotCommand $command, array $template, array $adjacent_annotations): string
|
||||
{
|
||||
|
||||
@ -69,7 +69,7 @@ class BotMap
|
||||
* @param int $fd 绑定的反向 ws 连接的客户端对应 fd
|
||||
* @param int $flag fd 所在 server 监听端口
|
||||
*/
|
||||
public static function registerBotWithFd(string|int $bot_id, string $platform, bool $status, int $fd, int $flag): bool
|
||||
public static function registerBotWithFd(int|string $bot_id, string $platform, bool $status, int $fd, int $flag): bool
|
||||
{
|
||||
logger()->debug('正在注册机器人:' . "{$platform}:{$bot_id}, fd:{$fd}, flag:{$flag}");
|
||||
self::$bot_fds[$platform][strval($bot_id)] = [$flag, $fd];
|
||||
@ -87,12 +87,12 @@ class BotMap
|
||||
return self::$bot_fds;
|
||||
}
|
||||
|
||||
public static function getBotFd(string|int $bot_id, string $platform): ?array
|
||||
public static function getBotFd(int|string $bot_id, string $platform): ?array
|
||||
{
|
||||
return self::$bot_fds[$platform][$bot_id] ?? null;
|
||||
}
|
||||
|
||||
public static function unregisterBot(string|int $bot_id, string $platform): void
|
||||
public static function unregisterBot(int|string $bot_id, string $platform): void
|
||||
{
|
||||
logger()->debug('取消注册 bot: ' . $bot_id);
|
||||
unset(self::$bot_fds[$platform][$bot_id], self::$bot_status[$platform][$bot_id], self::$bot_ctx_cache[$platform][$bot_id]);
|
||||
@ -117,7 +117,7 @@ class BotMap
|
||||
}
|
||||
}
|
||||
|
||||
public static function getBotContext(string|int $bot_id = '', string $platform = ''): BotContext
|
||||
public static function getBotContext(int|string $bot_id = '', string $platform = ''): BotContext
|
||||
{
|
||||
if (isset(self::$bot_ctx_cache[$platform][$bot_id])) {
|
||||
return self::$bot_ctx_cache[$platform][$bot_id];
|
||||
@ -152,7 +152,7 @@ class BotMap
|
||||
return self::$bot_ctx_cache[$platform][$bot_id] = new (self::$custom_contexts[$platform][$bot_id] ?? BotContext::class)($bot_id, $platform);
|
||||
}
|
||||
|
||||
public static function setCustomContext(string|int $bot_id, string $platform, string $context_class = BotContext::class): void
|
||||
public static function setCustomContext(int|string $bot_id, string $platform, string $context_class = BotContext::class): void
|
||||
{
|
||||
self::$custom_contexts[$platform][$bot_id] = $context_class;
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ class ProcessStateManager
|
||||
* @throws ZMKnownException
|
||||
* @internal
|
||||
*/
|
||||
public static function removeProcessState(int $type, int|string $id_or_name = null): void
|
||||
public static function removeProcessState(int $type, null|int|string $id_or_name = null): void
|
||||
{
|
||||
switch ($type) {
|
||||
case ZM_PROCESS_MASTER:
|
||||
|
||||
@ -13,9 +13,7 @@ use Doctrine\DBAL\ParameterType;
|
||||
|
||||
class DBStatement implements \IteratorAggregate, Statement
|
||||
{
|
||||
public function __construct(private \PDOStatement $statement)
|
||||
{
|
||||
}
|
||||
public function __construct(private \PDOStatement $statement) {}
|
||||
|
||||
public function closeCursor()
|
||||
{
|
||||
|
||||
@ -14,9 +14,7 @@ use Doctrine\DBAL\ForwardCompatibility\Result;
|
||||
|
||||
class DBStatementWrapper
|
||||
{
|
||||
public function __construct(public ?Result $stmt)
|
||||
{
|
||||
}
|
||||
public function __construct(public ?Result $stmt) {}
|
||||
|
||||
/**
|
||||
* 获取结果的迭代器
|
||||
@ -41,7 +39,7 @@ class DBStatementWrapper
|
||||
/**
|
||||
* wrapper method
|
||||
* @return array|false|mixed
|
||||
*@throws DBException
|
||||
* @throws DBException
|
||||
*/
|
||||
public function fetchNumeric()
|
||||
{
|
||||
@ -55,7 +53,7 @@ class DBStatementWrapper
|
||||
/**
|
||||
* wrapper method
|
||||
* @return array|false|mixed
|
||||
*@throws DBException
|
||||
* @throws DBException
|
||||
*/
|
||||
public function fetchAssociative()
|
||||
{
|
||||
@ -69,7 +67,7 @@ class DBStatementWrapper
|
||||
/**
|
||||
* wrapper method
|
||||
* @return false|mixed
|
||||
*@throws DBException
|
||||
* @throws DBException
|
||||
*/
|
||||
public function fetchOne()
|
||||
{
|
||||
|
||||
@ -104,7 +104,7 @@ class LightCache implements KVInterface
|
||||
/**
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool
|
||||
public function set(string $key, mixed $value, null|\DateInterval|int $ttl = null): bool
|
||||
{
|
||||
$this->validateKey($key);
|
||||
self::$caches[$this->name][$key] = $value;
|
||||
@ -139,7 +139,7 @@ class LightCache implements KVInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function setMultiple(iterable $values, \DateInterval|int|null $ttl = null): bool
|
||||
public function setMultiple(iterable $values, null|\DateInterval|int $ttl = null): bool
|
||||
{
|
||||
foreach ($values as $k => $v) {
|
||||
if (!$this->set($k, $v, $ttl)) {
|
||||
|
||||
@ -21,9 +21,6 @@ class KVRedis implements KVInterface
|
||||
return new KVRedis($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get(string $key, mixed $default = null): mixed
|
||||
{
|
||||
/** @var ZMRedis $redis */
|
||||
@ -38,10 +35,7 @@ class KVRedis implements KVInterface
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function set(string $key, mixed $value, \DateInterval|int|null $ttl = null): bool
|
||||
public function set(string $key, mixed $value, null|\DateInterval|int $ttl = null): bool
|
||||
{
|
||||
/** @var ZMRedis $redis */
|
||||
$redis = RedisPool::pool($this->pool_name)->get();
|
||||
@ -50,9 +44,6 @@ class KVRedis implements KVInterface
|
||||
return (bool) $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function delete(string $key): bool
|
||||
{
|
||||
/** @var ZMRedis $redis */
|
||||
@ -62,9 +53,6 @@ class KVRedis implements KVInterface
|
||||
return (bool) $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function clear(): bool
|
||||
{
|
||||
/** @var ZMRedis $redis */
|
||||
@ -74,9 +62,6 @@ class KVRedis implements KVInterface
|
||||
return (bool) $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getMultiple(iterable $keys, mixed $default = null): iterable
|
||||
{
|
||||
/** @var ZMRedis $redis */
|
||||
@ -93,10 +78,7 @@ class KVRedis implements KVInterface
|
||||
RedisPool::pool($this->pool_name)->put($redis);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function setMultiple(iterable $values, \DateInterval|int|null $ttl = null): bool
|
||||
public function setMultiple(iterable $values, null|\DateInterval|int $ttl = null): bool
|
||||
{
|
||||
/** @var ZMRedis $redis */
|
||||
$redis = RedisPool::pool($this->pool_name)->get();
|
||||
@ -108,9 +90,6 @@ class KVRedis implements KVInterface
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function deleteMultiple(iterable $keys): bool
|
||||
{
|
||||
/** @var ZMRedis $redis */
|
||||
@ -123,9 +102,6 @@ class KVRedis implements KVInterface
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function has(string $key): bool
|
||||
{
|
||||
/** @var ZMRedis $redis */
|
||||
|
||||
@ -6,6 +6,4 @@ namespace ZM\Store\KV\Redis;
|
||||
|
||||
use ZM\Exception\ZMException;
|
||||
|
||||
class RedisException extends ZMException
|
||||
{
|
||||
}
|
||||
class RedisException extends ZMException {}
|
||||
|
||||
@ -241,9 +241,7 @@ namespace ZM\Store\KV\Redis;
|
||||
*/
|
||||
class RedisWrapper
|
||||
{
|
||||
public function __construct(private string $pool = 'default')
|
||||
{
|
||||
}
|
||||
public function __construct(private string $pool = 'default') {}
|
||||
|
||||
public function __call(string $name, array $arguments)
|
||||
{
|
||||
|
||||
@ -14,7 +14,7 @@ class CatCode
|
||||
* @param array|MessageSegment|string $message_segment MessageSegment 对象或数组
|
||||
* @param bool $encode_text 是否对文本进行 CatCode 编码(默认为否)
|
||||
*/
|
||||
public static function fromSegment(string|array|MessageSegment $message_segment, bool $encode_text = false): string
|
||||
public static function fromSegment(array|MessageSegment|string $message_segment, bool $encode_text = false): string
|
||||
{
|
||||
// 传入的必须是段数组或段对象
|
||||
if (is_array($message_segment)) {
|
||||
@ -40,7 +40,7 @@ class CatCode
|
||||
* @param bool $is_param 如果是转义CatCode本体内容,则为false(默认),如果是参数内的字符串,则为true
|
||||
* @return string 转义后的CatCode
|
||||
*/
|
||||
public static function encode(\Stringable|int|string $msg, bool $is_param = false): string
|
||||
public static function encode(int|string|\Stringable $msg, bool $is_param = false): string
|
||||
{
|
||||
$msg = str_replace(['&', '[', ']'], ['&', '[', ']'], (string) $msg);
|
||||
if ($is_param) {
|
||||
@ -56,7 +56,7 @@ class CatCode
|
||||
* @param bool $is_param 如果是解码CatCode本体内容,则为false(默认),如果是参数内的字符串,则为true
|
||||
* @return string 转义后的CatCode
|
||||
*/
|
||||
public static function decode(\Stringable|int|string $msg, bool $is_param = false): string
|
||||
public static function decode(int|string|\Stringable $msg, bool $is_param = false): string
|
||||
{
|
||||
$msg = str_replace(['&', '[', ']'], ['&', '[', ']'], (string) $msg);
|
||||
if ($is_param) {
|
||||
|
||||
@ -14,9 +14,7 @@ use ZM\Utils\ZMUtil;
|
||||
*/
|
||||
class PluginGenerator
|
||||
{
|
||||
public function __construct(private string $name, private string $plugin_dir)
|
||||
{
|
||||
}
|
||||
public function __construct(private string $name, private string $plugin_dir) {}
|
||||
|
||||
/**
|
||||
* 开始生成
|
||||
|
||||
@ -61,7 +61,7 @@ class MessageUtil
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public static function convertToArr(MessageSegment|\Stringable|array|string $message): array
|
||||
public static function convertToArr(array|MessageSegment|string|\Stringable $message): array
|
||||
{
|
||||
if (is_array($message)) {
|
||||
foreach ($message as $k => $v) {
|
||||
@ -99,7 +99,7 @@ class MessageUtil
|
||||
return $ls;
|
||||
}
|
||||
|
||||
public static function getAltMessage(null|array|string|MessageSegment $message): string
|
||||
public static function getAltMessage(null|array|MessageSegment|string $message): string
|
||||
{
|
||||
if ($message === null) {
|
||||
return '';
|
||||
|
||||
@ -20,9 +20,7 @@ class OneBot12FileUploader
|
||||
* @param BotContext $ctx 机器人上下文,用于调用发送动作
|
||||
* @param int $buffer_size 分片传输的大小,默认为 65536 字节,建议调整小于 2MB
|
||||
*/
|
||||
public function __construct(private BotContext $ctx, private int $buffer_size = 131072)
|
||||
{
|
||||
}
|
||||
public function __construct(private BotContext $ctx, private int $buffer_size = 131072) {}
|
||||
|
||||
/**
|
||||
* 通过文件内容上传一个文件
|
||||
|
||||
@ -81,7 +81,7 @@ class ReflectionUtil
|
||||
* @param callable|string $callback 回调
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public static function isNonStaticMethod(callable|array|string $callback): bool
|
||||
public static function isNonStaticMethod(array|callable|string $callback): bool
|
||||
{
|
||||
if (is_array($callback) && is_string($callback[0])) {
|
||||
$reflection = new \ReflectionMethod($callback[0], $callback[1]);
|
||||
|
||||
@ -22,7 +22,7 @@ class ZMRequest
|
||||
* @param bool $only_body 是否只返回 Response 的 body 部分,默认为 True
|
||||
* @return bool|ResponseInterface|string 返回 False 代表请求失败,返回 string 为仅 Body 的内容,返回 Response 接口对象表明是回包
|
||||
*/
|
||||
public static function get(string|UriInterface|\Stringable $url, array $headers = [], array $config = [], bool $only_body = true): bool|ResponseInterface|string
|
||||
public static function get(string|\Stringable|UriInterface $url, array $headers = [], array $config = [], bool $only_body = true): bool|ResponseInterface|string
|
||||
{
|
||||
$socket = Framework::getInstance()->getDriver()->createHttpClientSocket(array_merge_recursive([
|
||||
'url' => ($url instanceof UriInterface ? $url->__toString() : $url),
|
||||
@ -51,7 +51,7 @@ class ZMRequest
|
||||
* @param bool $only_body 是否只返回 Response 的 body 部分,默认为 True
|
||||
* @return bool|ResponseInterface|string 返回 False 代表请求失败,返回 string 为仅 Body 的内容,返回 Response 接口对象表明是回包
|
||||
*/
|
||||
public static function post(string|UriInterface|\Stringable $url, array $header, mixed $data, array $config = [], bool $only_body = true): bool|ResponseInterface|string
|
||||
public static function post(string|\Stringable|UriInterface $url, array $header, mixed $data, array $config = [], bool $only_body = true): bool|ResponseInterface|string
|
||||
{
|
||||
$socket = Framework::getInstance()->getDriver()->createHttpClientSocket(array_merge_recursive([
|
||||
'url' => ($url instanceof UriInterface ? $url->__toString() : $url),
|
||||
|
||||
@ -68,8 +68,8 @@ class ZMConfigTest extends TestCase
|
||||
public function testGetValueWhenKeyContainsDot(): void
|
||||
{
|
||||
$this->markTestSkipped('should it be supported?');
|
||||
// $this->assertEquals('c', $this->config->get('test.a.b'));
|
||||
// $this->assertEquals('d', $this->config->get('test.a.b.c'));
|
||||
// $this->assertEquals('c', $this->config->get('test.a.b'));
|
||||
// $this->assertEquals('d', $this->config->get('test.a.b.c'));
|
||||
}
|
||||
|
||||
public function testGetBooleanValue(): void
|
||||
|
||||
@ -95,7 +95,7 @@ class HttpEventListenerTest extends TestCase
|
||||
return $event->reveal();
|
||||
}
|
||||
|
||||
private function mockHandler(bool $should_be_called, callable $callback = null): self
|
||||
private function mockHandler(bool $should_be_called, ?callable $callback = null): self
|
||||
{
|
||||
$handler = $this->prophesize(self::class);
|
||||
if ($should_be_called) {
|
||||
|
||||
@ -68,8 +68,7 @@ class ReflectionUtilTest extends TestCase
|
||||
|
||||
public function provideTestGetCallReflector(): array
|
||||
{
|
||||
$closure = function () {
|
||||
};
|
||||
$closure = function () {};
|
||||
|
||||
return [
|
||||
'callable' => [[new ReflectionUtilTestClass(), 'method'], new \ReflectionMethod(ReflectionUtilTestClass::class, 'method')],
|
||||
@ -83,18 +82,12 @@ class ReflectionUtilTest extends TestCase
|
||||
|
||||
class ReflectionUtilTestClass
|
||||
{
|
||||
public function method(string $string, ReflectionUtilTestClass $class): void
|
||||
{
|
||||
}
|
||||
public function method(string $string, ReflectionUtilTestClass $class): void {}
|
||||
|
||||
public static function staticMethod(string $string, ReflectionUtilTestClass $class): void
|
||||
{
|
||||
}
|
||||
public static function staticMethod(string $string, ReflectionUtilTestClass $class): void {}
|
||||
}
|
||||
|
||||
class InvokableClass
|
||||
{
|
||||
public function __invoke(): void
|
||||
{
|
||||
}
|
||||
public function __invoke(): void {}
|
||||
}
|
||||
|
||||
@ -16,19 +16,19 @@ class ZMRequestTest extends TestCase
|
||||
public function testPost()
|
||||
{
|
||||
$this->markTestIncomplete('Potential dead on Windows');
|
||||
// $r = ZMRequest::post('http://httpbin.org/post', [], 'niubi=123');
|
||||
// $this->assertStringContainsString('123', $r);
|
||||
// $r2 = ZMRequest::post('http://httpbin.org/post', ['User-Agent' => 'test'], 'oijoij=ooo', [], false);
|
||||
// $this->assertInstanceOf(ResponseInterface::class, $r2);
|
||||
// $this->assertStringContainsString('ooo', $r2->getBody()->getContents());
|
||||
// $r = ZMRequest::post('http://httpbin.org/post', [], 'niubi=123');
|
||||
// $this->assertStringContainsString('123', $r);
|
||||
// $r2 = ZMRequest::post('http://httpbin.org/post', ['User-Agent' => 'test'], 'oijoij=ooo', [], false);
|
||||
// $this->assertInstanceOf(ResponseInterface::class, $r2);
|
||||
// $this->assertStringContainsString('ooo', $r2->getBody()->getContents());
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$this->markTestIncomplete('Potential dead on Windows');
|
||||
// $r = ZMRequest::get('http://httpbin.org/get', [
|
||||
// 'X-Test' => '123',
|
||||
// ]);
|
||||
// $this->assertStringContainsString('123', $r);
|
||||
// $r = ZMRequest::get('http://httpbin.org/get', [
|
||||
// 'X-Test' => '123',
|
||||
// ]);
|
||||
// $this->assertStringContainsString('123', $r);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user