mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-20 15:15:35 +08:00
PHP80 小修 (#187)
* migrate-php80 fix styles fix static analyse * fix some bugs
This commit is contained in:
@@ -22,59 +22,13 @@ use ZM\Exception\ZMKnownException;
|
||||
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
|
||||
class BotCommand extends AnnotationBase implements Level
|
||||
{
|
||||
public string $name = '';
|
||||
|
||||
public string $match = '';
|
||||
|
||||
public string $pattern = '';
|
||||
|
||||
public string $regex = '';
|
||||
|
||||
public string $start_with = '';
|
||||
|
||||
public string $end_with = '';
|
||||
|
||||
public string $keyword = '';
|
||||
|
||||
/** @var string[] */
|
||||
public array $alias = [];
|
||||
|
||||
public string $message_type = '';
|
||||
|
||||
public string $user_id = '';
|
||||
|
||||
public string $group_id = '';
|
||||
|
||||
public int $level = 20;
|
||||
|
||||
private array $arguments = [];
|
||||
|
||||
public function __construct(
|
||||
$name = '',
|
||||
$match = '',
|
||||
$pattern = '',
|
||||
$regex = '',
|
||||
$start_with = '',
|
||||
$end_with = '',
|
||||
$keyword = '',
|
||||
$alias = [],
|
||||
$message_type = '',
|
||||
$user_id = '',
|
||||
$group_id = '',
|
||||
$level = 20
|
||||
) {
|
||||
$this->name = $name;
|
||||
$this->match = $match;
|
||||
$this->pattern = $pattern;
|
||||
$this->regex = $regex;
|
||||
$this->start_with = $start_with;
|
||||
$this->end_with = $end_with;
|
||||
$this->keyword = $keyword;
|
||||
$this->alias = $alias;
|
||||
$this->message_type = $message_type;
|
||||
$this->user_id = $user_id;
|
||||
$this->group_id = $group_id;
|
||||
$this->level = $level;
|
||||
/**
|
||||
* @param string[] $alias
|
||||
*/
|
||||
public function __construct(public $name = '', public $match = '', public $pattern = '', public $regex = '', public $start_with = '', public $end_with = '', public $keyword = '', public $alias = [], public $message_type = '', public $user_id = '', public $group_id = '', public $level = 20)
|
||||
{
|
||||
}
|
||||
|
||||
public static function make(
|
||||
@@ -95,7 +49,6 @@ class BotCommand extends AnnotationBase implements Level
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @throws InvalidArgumentException
|
||||
* @throws ZMKnownException
|
||||
*/
|
||||
|
||||
@@ -19,32 +19,8 @@ use ZM\Annotation\AnnotationBase;
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
class BotEvent extends AnnotationBase
|
||||
{
|
||||
public ?string $type;
|
||||
|
||||
public ?string $detail_type;
|
||||
|
||||
public ?string $impl;
|
||||
|
||||
public ?string $platform;
|
||||
|
||||
public ?string $self_id;
|
||||
|
||||
public ?string $sub_type;
|
||||
|
||||
public function __construct(
|
||||
?string $type = null,
|
||||
?string $detail_type = null,
|
||||
?string $impl = null,
|
||||
?string $platform = null,
|
||||
?string $self_id = null,
|
||||
?string $sub_type = null
|
||||
) {
|
||||
$this->type = $type;
|
||||
$this->detail_type = $detail_type;
|
||||
$this->impl = $impl;
|
||||
$this->platform = $platform;
|
||||
$this->self_id = $self_id;
|
||||
$this->sub_type = $sub_type;
|
||||
public function __construct(public ?string $type = null, public ?string $detail_type = null, public ?string $impl = null, public ?string $platform = null, public ?string $self_id = null, public ?string $sub_type = null)
|
||||
{
|
||||
}
|
||||
|
||||
public static function make(
|
||||
|
||||
@@ -20,25 +20,8 @@ use ZM\Exception\ZMKnownException;
|
||||
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_ALL)]
|
||||
class CommandArgument extends AnnotationBase implements ErgodicAnnotation
|
||||
{
|
||||
/**
|
||||
* @Required()
|
||||
*/
|
||||
public string $name;
|
||||
|
||||
public string $description = '';
|
||||
|
||||
public string $type = 'string';
|
||||
|
||||
public bool $required = false;
|
||||
|
||||
public string $prompt = '';
|
||||
|
||||
public string $default = '';
|
||||
|
||||
public int $timeout = 60;
|
||||
|
||||
public int $error_prompt_policy = 1;
|
||||
|
||||
/**
|
||||
* @param string $name 参数名称(可以是中文)
|
||||
* @param string $description 参数描述(默认为空)
|
||||
@@ -49,23 +32,19 @@ class CommandArgument extends AnnotationBase implements ErgodicAnnotation
|
||||
* @throws InvalidArgumentException|ZMKnownException
|
||||
*/
|
||||
public function __construct(
|
||||
string $name,
|
||||
string $description = '',
|
||||
/**
|
||||
* @Required()
|
||||
*/
|
||||
public string $name,
|
||||
public string $description = '',
|
||||
string $type = 'string',
|
||||
bool $required = false,
|
||||
string $prompt = '',
|
||||
string $default = '',
|
||||
int $timeout = 60,
|
||||
int $error_prompt_policy = 1
|
||||
public bool $required = false,
|
||||
public string $prompt = '',
|
||||
public string $default = '',
|
||||
public int $timeout = 60,
|
||||
public int $error_prompt_policy = 1
|
||||
) {
|
||||
$this->name = $name;
|
||||
$this->description = $description;
|
||||
$this->type = $this->fixTypeName($type);
|
||||
$this->required = $required;
|
||||
$this->prompt = $prompt;
|
||||
$this->default = $default;
|
||||
$this->timeout = $timeout;
|
||||
$this->error_prompt_policy = $error_prompt_policy;
|
||||
if ($this->type === 'bool') {
|
||||
if ($this->default === '') {
|
||||
$this->default = 'yes';
|
||||
|
||||
Reference in New Issue
Block a user