mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-03-17 20:54:52 +08:00
add PHP8 Attribute compatibility (build 439, 2.7.0-beta4)
This commit is contained in:
parent
12363aebf0
commit
c897da29c6
@ -36,18 +36,20 @@
|
|||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"ext-posix": "*",
|
"ext-posix": "*",
|
||||||
"doctrine/annotations": "~1.12 || ~1.4.0",
|
"doctrine/annotations": "~1.12 || ~1.4.0",
|
||||||
"symfony/polyfill-ctype": "^1.19",
|
"doctrine/dbal": "^2.13.1",
|
||||||
"symfony/polyfill-mbstring": "^1.19",
|
|
||||||
"symfony/console": "~5.0 || ~4.0 || ~3.0",
|
|
||||||
"symfony/routing": "~5.0 || ~4.0 || ~3.0",
|
|
||||||
"zhamao/console": "^1.0",
|
|
||||||
"zhamao/config": "^1.0",
|
|
||||||
"zhamao/request": "^1.1",
|
|
||||||
"zhamao/connection-manager": "^1.0",
|
|
||||||
"jelix/version": "^2.0",
|
"jelix/version": "^2.0",
|
||||||
|
"koriym/attributes": "^1.0",
|
||||||
"league/climate": "^3.6",
|
"league/climate": "^3.6",
|
||||||
"psy/psysh": "@stable",
|
"psy/psysh": "@stable",
|
||||||
"doctrine/dbal": "^2.13.1"
|
"symfony/console": "~5.0 || ~4.0 || ~3.0",
|
||||||
|
"symfony/polyfill-ctype": "^1.19",
|
||||||
|
"symfony/polyfill-mbstring": "^1.19",
|
||||||
|
"symfony/polyfill-php80": "^1.16",
|
||||||
|
"symfony/routing": "~5.0 || ~4.0 || ~3.0",
|
||||||
|
"zhamao/config": "^1.0",
|
||||||
|
"zhamao/connection-manager": "^1.0",
|
||||||
|
"zhamao/console": "^1.0",
|
||||||
|
"zhamao/request": "^1.1"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-ctype": "Use C/C++ extension instead of polyfill will be more efficient",
|
"ext-ctype": "Use C/C++ extension instead of polyfill will be more efficient",
|
||||||
@ -88,4 +90,4 @@
|
|||||||
"analyse": "phpstan analyse --memory-limit 300M -l 0 ./src",
|
"analyse": "phpstan analyse --memory-limit 300M -l 0 ./src",
|
||||||
"cs-fix": "php-cs-fixer fix $1"
|
"cs-fix": "php-cs-fixer fix $1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Custom\Annotation;
|
namespace Custom\Annotation;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
use ZM\Annotation\Interfaces\CustomAnnotation;
|
use ZM\Annotation\Interfaces\CustomAnnotation;
|
||||||
@ -11,10 +13,17 @@ use ZM\Annotation\Interfaces\CustomAnnotation;
|
|||||||
/**
|
/**
|
||||||
* Class CustomAnnotation
|
* Class CustomAnnotation
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("ALL")
|
* @Target("ALL")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_ALL)]
|
||||||
class Example extends AnnotationBase implements CustomAnnotation
|
class Example extends AnnotationBase implements CustomAnnotation
|
||||||
{
|
{
|
||||||
/** @var string */
|
/** @var string */
|
||||||
public $str = '';
|
public $str = '';
|
||||||
|
|
||||||
|
public function __construct($str = '')
|
||||||
|
{
|
||||||
|
$this->str = $str;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,9 +8,9 @@ use Closure;
|
|||||||
|
|
||||||
abstract class AnnotationBase
|
abstract class AnnotationBase
|
||||||
{
|
{
|
||||||
public $method;
|
public $method = '';
|
||||||
|
|
||||||
public $class;
|
public $class = '';
|
||||||
|
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,6 +5,8 @@ declare(strict_types=1);
|
|||||||
namespace ZM\Annotation;
|
namespace ZM\Annotation;
|
||||||
|
|
||||||
use Doctrine\Common\Annotations\AnnotationReader;
|
use Doctrine\Common\Annotations\AnnotationReader;
|
||||||
|
use Koriym\Attributes\AttributeReader;
|
||||||
|
use Koriym\Attributes\DualReader;
|
||||||
use ReflectionClass;
|
use ReflectionClass;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use ReflectionMethod;
|
use ReflectionMethod;
|
||||||
@ -63,13 +65,12 @@ class AnnotationParser
|
|||||||
foreach ($this->path_list as $path) {
|
foreach ($this->path_list as $path) {
|
||||||
Console::debug('parsing annotation in ' . $path[0] . ':' . $path[1]);
|
Console::debug('parsing annotation in ' . $path[0] . ':' . $path[1]);
|
||||||
$all_class = ZMUtil::getClassesPsr4($path[0], $path[1]);
|
$all_class = ZMUtil::getClassesPsr4($path[0], $path[1]);
|
||||||
$this->reader = new AnnotationReader();
|
$this->reader = new DualReader(new AnnotationReader(), new AttributeReader());
|
||||||
foreach ($all_class as $v) {
|
foreach ($all_class as $v) {
|
||||||
Console::debug('正在检索 ' . $v);
|
Console::debug('正在检索 ' . $v);
|
||||||
$reflection_class = new ReflectionClass($v);
|
$reflection_class = new ReflectionClass($v);
|
||||||
$methods = $reflection_class->getMethods(ReflectionMethod::IS_PUBLIC);
|
$methods = $reflection_class->getMethods(ReflectionMethod::IS_PUBLIC);
|
||||||
$class_annotations = $this->reader->getClassAnnotations($reflection_class);
|
$class_annotations = $this->reader->getClassAnnotations($reflection_class);
|
||||||
|
|
||||||
// 这段为新加的:start
|
// 这段为新加的:start
|
||||||
//这里将每个类里面所有的类注解、方法注解通通加到一颗大树上,后期解析
|
//这里将每个类里面所有的类注解、方法注解通通加到一颗大树上,后期解析
|
||||||
/*
|
/*
|
||||||
@ -133,8 +134,7 @@ class AnnotationParser
|
|||||||
if (!isset($inserted[$v][$method_name])) {
|
if (!isset($inserted[$v][$method_name])) {
|
||||||
// 在这里在其他中间件前插入插入全局的中间件
|
// 在这里在其他中间件前插入插入全局的中间件
|
||||||
foreach ($middlewares as $middleware) {
|
foreach ($middlewares as $middleware) {
|
||||||
$mid_class = new Middleware();
|
$mid_class = new Middleware($middleware);
|
||||||
$mid_class->middleware = $middleware;
|
|
||||||
$mid_class->class = $v;
|
$mid_class->class = $v;
|
||||||
$mid_class->method = $method_name;
|
$mid_class->method = $method_name;
|
||||||
$this->middleware_map[$v][$method_name][] = $mid_class;
|
$this->middleware_map[$v][$method_name][] = $mid_class;
|
||||||
|
|||||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\CQ;
|
namespace ZM\Annotation\CQ;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Required;
|
use Doctrine\Common\Annotations\Annotation\Required;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
@ -11,8 +13,10 @@ use ZM\Annotation\AnnotationBase;
|
|||||||
/**
|
/**
|
||||||
* Class CQAPIResponse
|
* Class CQAPIResponse
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class CQAPIResponse extends AnnotationBase
|
class CQAPIResponse extends AnnotationBase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -20,4 +24,9 @@ class CQAPIResponse extends AnnotationBase
|
|||||||
* @Required()
|
* @Required()
|
||||||
*/
|
*/
|
||||||
public $retcode;
|
public $retcode;
|
||||||
|
|
||||||
|
public function __construct($retcode)
|
||||||
|
{
|
||||||
|
$this->retcode = $retcode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\CQ;
|
namespace ZM\Annotation\CQ;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
use ZM\Annotation\Interfaces\Level;
|
use ZM\Annotation\Interfaces\Level;
|
||||||
@ -11,8 +13,10 @@ use ZM\Annotation\Interfaces\Level;
|
|||||||
/**
|
/**
|
||||||
* Class CQAfter
|
* Class CQAfter
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class CQAfter extends AnnotationBase implements Level
|
class CQAfter extends AnnotationBase implements Level
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -23,6 +27,12 @@ class CQAfter extends AnnotationBase implements Level
|
|||||||
|
|
||||||
public $level = 20;
|
public $level = 20;
|
||||||
|
|
||||||
|
public function __construct($cq_event, $level = 20)
|
||||||
|
{
|
||||||
|
$this->cq_event = $cq_event;
|
||||||
|
$this->level = $level;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\CQ;
|
namespace ZM\Annotation\CQ;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Required;
|
use Doctrine\Common\Annotations\Annotation\Required;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
@ -12,8 +14,10 @@ use ZM\Annotation\Interfaces\Level;
|
|||||||
/**
|
/**
|
||||||
* Class CQBefore
|
* Class CQBefore
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class CQBefore extends AnnotationBase implements Level
|
class CQBefore extends AnnotationBase implements Level
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -24,6 +28,12 @@ class CQBefore extends AnnotationBase implements Level
|
|||||||
|
|
||||||
public $level = 20;
|
public $level = 20;
|
||||||
|
|
||||||
|
public function __construct($cq_event, $level = 20)
|
||||||
|
{
|
||||||
|
$this->cq_event = $cq_event;
|
||||||
|
$this->level = $level;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\CQ;
|
namespace ZM\Annotation\CQ;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
use ZM\Annotation\Interfaces\Level;
|
use ZM\Annotation\Interfaces\Level;
|
||||||
@ -11,8 +13,10 @@ use ZM\Annotation\Interfaces\Level;
|
|||||||
/**
|
/**
|
||||||
* Class CQCommand
|
* Class CQCommand
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor
|
||||||
* @Target("ALL")
|
* @Target("ALL")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_ALL)]
|
||||||
class CQCommand extends AnnotationBase implements Level
|
class CQCommand extends AnnotationBase implements Level
|
||||||
{
|
{
|
||||||
/** @var string */
|
/** @var string */
|
||||||
@ -51,6 +55,22 @@ class CQCommand extends AnnotationBase implements Level
|
|||||||
/** @var int */
|
/** @var int */
|
||||||
public $level = 20;
|
public $level = 20;
|
||||||
|
|
||||||
|
public function __construct($match = '', $pattern = '', $regex = '', $start_with = '', $end_with = '', $keyword = '', $alias = [], $message_type = '', $user_id = 0, $group_id = 0, $discuss_id = 0, $level = 20)
|
||||||
|
{
|
||||||
|
$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->discuss_id = $discuss_id;
|
||||||
|
$this->level = $level;
|
||||||
|
}
|
||||||
|
|
||||||
public function getLevel(): int
|
public function getLevel(): int
|
||||||
{
|
{
|
||||||
return $this->level;
|
return $this->level;
|
||||||
|
|||||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\CQ;
|
namespace ZM\Annotation\CQ;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
use ZM\Annotation\Interfaces\Level;
|
use ZM\Annotation\Interfaces\Level;
|
||||||
@ -11,8 +13,10 @@ use ZM\Annotation\Interfaces\Level;
|
|||||||
/**
|
/**
|
||||||
* Class CQMessage
|
* Class CQMessage
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("ALL")
|
* @Target("ALL")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_ALL)]
|
||||||
class CQMessage extends AnnotationBase implements Level
|
class CQMessage extends AnnotationBase implements Level
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -38,6 +42,17 @@ class CQMessage extends AnnotationBase implements Level
|
|||||||
/** @var int */
|
/** @var int */
|
||||||
public $level = 20;
|
public $level = 20;
|
||||||
|
|
||||||
|
public function __construct($message_type = '', $user_id = 0, $group_id = 0, $discuss_id = 0, $message = '', $raw_message = '', $level = 20)
|
||||||
|
{
|
||||||
|
$this->message_type = $message_type;
|
||||||
|
$this->user_id = $user_id;
|
||||||
|
$this->group_id = $group_id;
|
||||||
|
$this->discuss_id = $discuss_id;
|
||||||
|
$this->message = $message;
|
||||||
|
$this->raw_message = $raw_message;
|
||||||
|
$this->level = $level;
|
||||||
|
}
|
||||||
|
|
||||||
public function getLevel(): int
|
public function getLevel(): int
|
||||||
{
|
{
|
||||||
return $this->level;
|
return $this->level;
|
||||||
|
|||||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\CQ;
|
namespace ZM\Annotation\CQ;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Required;
|
use Doctrine\Common\Annotations\Annotation\Required;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
@ -12,18 +14,26 @@ use ZM\Annotation\Interfaces\Level;
|
|||||||
/**
|
/**
|
||||||
* Class CQMetaEvent
|
* Class CQMetaEvent
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("ALL")
|
* @Target("ALL")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_ALL)]
|
||||||
class CQMetaEvent extends AnnotationBase implements Level
|
class CQMetaEvent extends AnnotationBase implements Level
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
* @Required()
|
* @Required()
|
||||||
*/
|
*/
|
||||||
public $meta_event_type = '';
|
public $meta_event_type;
|
||||||
|
|
||||||
/** @var int */
|
/** @var int */
|
||||||
public $level;
|
public $level = 20;
|
||||||
|
|
||||||
|
public function __construct($meta_event_type, $level = 20)
|
||||||
|
{
|
||||||
|
$this->meta_event_type = $meta_event_type;
|
||||||
|
$this->level = $level;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
|||||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\CQ;
|
namespace ZM\Annotation\CQ;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
use ZM\Annotation\Interfaces\Level;
|
use ZM\Annotation\Interfaces\Level;
|
||||||
@ -11,8 +13,10 @@ use ZM\Annotation\Interfaces\Level;
|
|||||||
/**
|
/**
|
||||||
* Class CQNotice
|
* Class CQNotice
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("ALL")
|
* @Target("ALL")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_ALL)]
|
||||||
class CQNotice extends AnnotationBase implements Level
|
class CQNotice extends AnnotationBase implements Level
|
||||||
{
|
{
|
||||||
/** @var string */
|
/** @var string */
|
||||||
@ -30,6 +34,15 @@ class CQNotice extends AnnotationBase implements Level
|
|||||||
/** @var int */
|
/** @var int */
|
||||||
public $level = 20;
|
public $level = 20;
|
||||||
|
|
||||||
|
public function __construct($notice_type = '', $sub_type = '', $group_id = 0, $operator_id = 0, $level = 20)
|
||||||
|
{
|
||||||
|
$this->notice_type = $notice_type;
|
||||||
|
$this->sub_type = $sub_type;
|
||||||
|
$this->group_id = $group_id;
|
||||||
|
$this->operator_id = $operator_id;
|
||||||
|
$this->level = $level;
|
||||||
|
}
|
||||||
|
|
||||||
public function getLevel(): int
|
public function getLevel(): int
|
||||||
{
|
{
|
||||||
return $this->level;
|
return $this->level;
|
||||||
|
|||||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\CQ;
|
namespace ZM\Annotation\CQ;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
use ZM\Annotation\Interfaces\Level;
|
use ZM\Annotation\Interfaces\Level;
|
||||||
@ -11,8 +13,10 @@ use ZM\Annotation\Interfaces\Level;
|
|||||||
/**
|
/**
|
||||||
* Class CQRequest
|
* Class CQRequest
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("ALL")
|
* @Target("ALL")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_ALL)]
|
||||||
class CQRequest extends AnnotationBase implements Level
|
class CQRequest extends AnnotationBase implements Level
|
||||||
{
|
{
|
||||||
/** @var string */
|
/** @var string */
|
||||||
@ -30,6 +34,15 @@ class CQRequest extends AnnotationBase implements Level
|
|||||||
/** @var int */
|
/** @var int */
|
||||||
public $level = 20;
|
public $level = 20;
|
||||||
|
|
||||||
|
public function __construct($request_type = '', $sub_type = '', $user_id = 0, $comment = '', $level = 20)
|
||||||
|
{
|
||||||
|
$this->request_type = $request_type;
|
||||||
|
$this->sub_type = $sub_type;
|
||||||
|
$this->user_id = $user_id;
|
||||||
|
$this->comment = $comment;
|
||||||
|
$this->level = $level;
|
||||||
|
}
|
||||||
|
|
||||||
public function getLevel(): int
|
public function getLevel(): int
|
||||||
{
|
{
|
||||||
return $this->level;
|
return $this->level;
|
||||||
|
|||||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Command;
|
namespace ZM\Annotation\Command;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Required;
|
use Doctrine\Common\Annotations\Annotation\Required;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
@ -11,8 +13,10 @@ use ZM\Annotation\AnnotationBase;
|
|||||||
/**
|
/**
|
||||||
* Class TerminalCommand
|
* Class TerminalCommand
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class TerminalCommand extends AnnotationBase
|
class TerminalCommand extends AnnotationBase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -27,4 +31,11 @@ class TerminalCommand extends AnnotationBase
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $description = '';
|
public $description = '';
|
||||||
|
|
||||||
|
public function __construct($command, $alias = '', $description = '')
|
||||||
|
{
|
||||||
|
$this->command = $command;
|
||||||
|
$this->alias = $alias;
|
||||||
|
$this->description = $description;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Http;
|
namespace ZM\Annotation\Http;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Required;
|
use Doctrine\Common\Annotations\Annotation\Required;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
@ -12,8 +14,10 @@ use ZM\Annotation\Interfaces\ErgodicAnnotation;
|
|||||||
/**
|
/**
|
||||||
* Class Controller
|
* Class Controller
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("CLASS")
|
* @Target("CLASS")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
|
||||||
class Controller extends AnnotationBase implements ErgodicAnnotation
|
class Controller extends AnnotationBase implements ErgodicAnnotation
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -21,4 +25,9 @@ class Controller extends AnnotationBase implements ErgodicAnnotation
|
|||||||
* @Required()
|
* @Required()
|
||||||
*/
|
*/
|
||||||
public $prefix = '';
|
public $prefix = '';
|
||||||
|
|
||||||
|
public function __construct(string $prefix)
|
||||||
|
{
|
||||||
|
$this->prefix = $prefix;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,14 +4,18 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Http;
|
namespace ZM\Annotation\Http;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class HandleAfter
|
* Class HandleAfter
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class HandleAfter extends AnnotationBase
|
class HandleAfter extends AnnotationBase
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,14 +4,18 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Http;
|
namespace ZM\Annotation\Http;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class HandleBefore
|
* Class HandleBefore
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class HandleBefore extends AnnotationBase
|
class HandleBefore extends AnnotationBase
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Http;
|
namespace ZM\Annotation\Http;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use Exception;
|
use Exception;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
@ -11,12 +13,19 @@ use ZM\Annotation\AnnotationBase;
|
|||||||
/**
|
/**
|
||||||
* Class HandleException
|
* Class HandleException
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class HandleException extends AnnotationBase
|
class HandleException extends AnnotationBase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $class_name = Exception::class;
|
public $class_name = Exception::class;
|
||||||
|
|
||||||
|
public function __construct($class_name = Exception::class)
|
||||||
|
{
|
||||||
|
$this->class_name = $class_name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Http;
|
namespace ZM\Annotation\Http;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Required;
|
use Doctrine\Common\Annotations\Annotation\Required;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
@ -12,8 +14,10 @@ use ZM\Annotation\Interfaces\ErgodicAnnotation;
|
|||||||
/**
|
/**
|
||||||
* Class Middleware
|
* Class Middleware
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("ALL")
|
* @Target("ALL")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_ALL)]
|
||||||
class Middleware extends AnnotationBase implements ErgodicAnnotation
|
class Middleware extends AnnotationBase implements ErgodicAnnotation
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -26,4 +30,10 @@ class Middleware extends AnnotationBase implements ErgodicAnnotation
|
|||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
public $params = [];
|
public $params = [];
|
||||||
|
|
||||||
|
public function __construct($middleware, $params = [])
|
||||||
|
{
|
||||||
|
$this->middleware = $middleware;
|
||||||
|
$this->params = $params;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Http;
|
namespace ZM\Annotation\Http;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Required;
|
use Doctrine\Common\Annotations\Annotation\Required;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
@ -11,8 +13,10 @@ use ZM\Annotation\AnnotationBase;
|
|||||||
/**
|
/**
|
||||||
* Class MiddlewareClass
|
* Class MiddlewareClass
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("CLASS")
|
* @Target("CLASS")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
|
||||||
class MiddlewareClass extends AnnotationBase
|
class MiddlewareClass extends AnnotationBase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -20,4 +24,9 @@ class MiddlewareClass extends AnnotationBase
|
|||||||
* @Required()
|
* @Required()
|
||||||
*/
|
*/
|
||||||
public $name = '';
|
public $name = '';
|
||||||
|
|
||||||
|
public function __construct($name)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Http;
|
namespace ZM\Annotation\Http;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Required;
|
use Doctrine\Common\Annotations\Annotation\Required;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
@ -11,8 +13,10 @@ use ZM\Annotation\AnnotationBase;
|
|||||||
/**
|
/**
|
||||||
* Class RequestMapping
|
* Class RequestMapping
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class RequestMapping extends AnnotationBase
|
class RequestMapping extends AnnotationBase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -36,4 +40,12 @@ class RequestMapping extends AnnotationBase
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $params = [];
|
public $params = [];
|
||||||
|
|
||||||
|
public function __construct($route, $name = '', $request_method = [RequestMethod::GET, RequestMethod::POST], $params = [])
|
||||||
|
{
|
||||||
|
$this->route = $route;
|
||||||
|
$this->name = $name;
|
||||||
|
$this->request_method = $request_method;
|
||||||
|
$this->params = $params;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,13 +4,19 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Http;
|
namespace ZM\Annotation\Http;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Required;
|
use Doctrine\Common\Annotations\Annotation\Required;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RequestMethod
|
* Class RequestMethod
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
|
* @Target("METHOD")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class RequestMethod extends AnnotationBase
|
class RequestMethod extends AnnotationBase
|
||||||
{
|
{
|
||||||
public const GET = 'GET';
|
public const GET = 'GET';
|
||||||
@ -32,4 +38,9 @@ class RequestMethod extends AnnotationBase
|
|||||||
* @Required()
|
* @Required()
|
||||||
*/
|
*/
|
||||||
public $method = self::GET;
|
public $method = self::GET;
|
||||||
|
|
||||||
|
public function __construct($method)
|
||||||
|
{
|
||||||
|
$this->method = $method;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,14 +4,18 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Module;
|
namespace ZM\Annotation\Module;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Closed
|
* Class Closed
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("CLASS")
|
* @Target("CLASS")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
|
||||||
class Closed extends AnnotationBase
|
class Closed extends AnnotationBase
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,17 +4,28 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Swoole;
|
namespace ZM\Annotation\Swoole;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
* Class OnCloseEvent
|
* Class OnCloseEvent
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class OnCloseEvent extends OnSwooleEventBase
|
class OnCloseEvent extends OnSwooleEventBase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $connect_type = 'default';
|
public $connect_type = 'default';
|
||||||
|
|
||||||
|
public function __construct($connect_type = 'default', $rule = '', $level = 20)
|
||||||
|
{
|
||||||
|
$this->connect_type = $connect_type;
|
||||||
|
$this->rule = $rule;
|
||||||
|
$this->level = $level;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,13 +4,22 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Swoole;
|
namespace ZM\Annotation\Swoole;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
* @since 2.7.0
|
* @since 2.7.0
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class OnManagerStartEvent extends OnSwooleEventBase
|
class OnManagerStartEvent extends OnSwooleEventBase
|
||||||
{
|
{
|
||||||
|
public function __construct($rule = '', $level = 20)
|
||||||
|
{
|
||||||
|
$this->rule = $rule;
|
||||||
|
$this->level = $level;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,17 +4,28 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Swoole;
|
namespace ZM\Annotation\Swoole;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* Class OnMessageEvent
|
* Class OnMessageEvent
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class OnMessageEvent extends OnSwooleEventBase
|
class OnMessageEvent extends OnSwooleEventBase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $connect_type = 'default';
|
public $connect_type = 'default';
|
||||||
|
|
||||||
|
public function __construct($connect_type = 'default', $rule = '', $level = 20)
|
||||||
|
{
|
||||||
|
$this->connect_type = $connect_type;
|
||||||
|
$this->rule = $rule;
|
||||||
|
$this->level = $level;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,17 +4,28 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Swoole;
|
namespace ZM\Annotation\Swoole;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
* Class OnOpenEvent
|
* Class OnOpenEvent
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class OnOpenEvent extends OnSwooleEventBase
|
class OnOpenEvent extends OnSwooleEventBase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $connect_type = 'default';
|
public $connect_type = 'default';
|
||||||
|
|
||||||
|
public function __construct($connect_type = 'default', $rule = '', $level = 20)
|
||||||
|
{
|
||||||
|
$this->connect_type = $connect_type;
|
||||||
|
$this->rule = $rule;
|
||||||
|
$this->level = $level;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Swoole;
|
namespace ZM\Annotation\Swoole;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Required;
|
use Doctrine\Common\Annotations\Annotation\Required;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
@ -11,8 +13,10 @@ use ZM\Annotation\AnnotationBase;
|
|||||||
/**
|
/**
|
||||||
* Class OnPipeMessageEvent
|
* Class OnPipeMessageEvent
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class OnPipeMessageEvent extends AnnotationBase
|
class OnPipeMessageEvent extends AnnotationBase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -20,4 +24,9 @@ class OnPipeMessageEvent extends AnnotationBase
|
|||||||
* @Required()
|
* @Required()
|
||||||
*/
|
*/
|
||||||
public $action;
|
public $action;
|
||||||
|
|
||||||
|
public function __construct($action)
|
||||||
|
{
|
||||||
|
$this->action = $action;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,13 +4,22 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Swoole;
|
namespace ZM\Annotation\Swoole;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
* Class OnRequestEvent
|
* Class OnRequestEvent
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class OnRequestEvent extends OnSwooleEventBase
|
class OnRequestEvent extends OnSwooleEventBase
|
||||||
{
|
{
|
||||||
|
public function __construct($rule = '', $level = 20)
|
||||||
|
{
|
||||||
|
$this->rule = $rule;
|
||||||
|
$this->level = $level;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,14 +4,18 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Swoole;
|
namespace ZM\Annotation\Swoole;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class OnSave
|
* Class OnSave
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class OnSave extends AnnotationBase
|
class OnSave extends AnnotationBase
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,14 +4,18 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Swoole;
|
namespace ZM\Annotation\Swoole;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ZMSetup
|
* Class ZMSetup
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class OnSetup extends AnnotationBase
|
class OnSetup extends AnnotationBase
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,18 +4,27 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Swoole;
|
namespace ZM\Annotation\Swoole;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class OnWorkerStart
|
* Class OnWorkerStart
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class OnStart extends AnnotationBase
|
class OnStart extends AnnotationBase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
public $worker_id = 0;
|
public $worker_id = 0;
|
||||||
|
|
||||||
|
public function __construct($worker_id = 0)
|
||||||
|
{
|
||||||
|
$this->worker_id = $worker_id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,14 +4,18 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Swoole;
|
namespace ZM\Annotation\Swoole;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Required;
|
use Doctrine\Common\Annotations\Annotation\Required;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class OnSwooleEvent
|
* Class OnSwooleEvent
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class OnSwooleEvent extends OnSwooleEventBase
|
class OnSwooleEvent extends OnSwooleEventBase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -20,6 +24,13 @@ class OnSwooleEvent extends OnSwooleEventBase
|
|||||||
*/
|
*/
|
||||||
public $type;
|
public $type;
|
||||||
|
|
||||||
|
public function __construct($type, $rule = '', $level = 20)
|
||||||
|
{
|
||||||
|
$this->type = $type;
|
||||||
|
$this->rule = $rule;
|
||||||
|
$this->level = $level;
|
||||||
|
}
|
||||||
|
|
||||||
public function getType(): string
|
public function getType(): string
|
||||||
{
|
{
|
||||||
return $this->type;
|
return $this->type;
|
||||||
|
|||||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Swoole;
|
namespace ZM\Annotation\Swoole;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Required;
|
use Doctrine\Common\Annotations\Annotation\Required;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
@ -12,8 +14,10 @@ use ZM\Annotation\Interfaces\Rule;
|
|||||||
/**
|
/**
|
||||||
* Class OnTask
|
* Class OnTask
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class OnTask extends AnnotationBase implements Rule
|
class OnTask extends AnnotationBase implements Rule
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -27,6 +31,12 @@ class OnTask extends AnnotationBase implements Rule
|
|||||||
*/
|
*/
|
||||||
public $rule = '';
|
public $rule = '';
|
||||||
|
|
||||||
|
public function __construct($task_name, $rule = '')
|
||||||
|
{
|
||||||
|
$this->task_name = $task_name;
|
||||||
|
$this->rule = $rule;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -4,13 +4,22 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Swoole;
|
namespace ZM\Annotation\Swoole;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class OnTaskEvent
|
* Class OnTaskEvent
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
||||||
class OnTaskEvent extends OnSwooleEventBase
|
class OnTaskEvent extends OnSwooleEventBase
|
||||||
{
|
{
|
||||||
|
public function __construct($rule = '', $level = 20)
|
||||||
|
{
|
||||||
|
$this->rule = $rule;
|
||||||
|
$this->level = $level;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Swoole;
|
namespace ZM\Annotation\Swoole;
|
||||||
|
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Required;
|
use Doctrine\Common\Annotations\Annotation\Required;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
@ -11,6 +12,7 @@ use ZM\Annotation\AnnotationBase;
|
|||||||
/**
|
/**
|
||||||
* Class OnTick
|
* Class OnTick
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
* @since 1.2
|
* @since 1.2
|
||||||
*/
|
*/
|
||||||
@ -26,4 +28,10 @@ class OnTick extends AnnotationBase
|
|||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
public $worker_id = 0;
|
public $worker_id = 0;
|
||||||
|
|
||||||
|
public function __construct($tick_ms, $worker_id = 0)
|
||||||
|
{
|
||||||
|
$this->tick_ms = $tick_ms;
|
||||||
|
$this->worker_id = $worker_id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Swoole;
|
namespace ZM\Annotation\Swoole;
|
||||||
|
|
||||||
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Required;
|
use Doctrine\Common\Annotations\Annotation\Required;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
use ZM\Annotation\AnnotationBase;
|
use ZM\Annotation\AnnotationBase;
|
||||||
@ -11,6 +12,7 @@ use ZM\Annotation\AnnotationBase;
|
|||||||
/**
|
/**
|
||||||
* Class SwooleHandler
|
* Class SwooleHandler
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
* @NamedArgumentConstructor()
|
||||||
* @Target("ALL")
|
* @Target("ALL")
|
||||||
*/
|
*/
|
||||||
class SwooleHandler extends AnnotationBase
|
class SwooleHandler extends AnnotationBase
|
||||||
@ -20,4 +22,13 @@ class SwooleHandler extends AnnotationBase
|
|||||||
* @Required()
|
* @Required()
|
||||||
*/
|
*/
|
||||||
public $event;
|
public $event;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
public $params = '';
|
||||||
|
|
||||||
|
public function __construct($event, $params = '')
|
||||||
|
{
|
||||||
|
$this->event = $event;
|
||||||
|
$this->params = $params;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,9 +28,9 @@ use ZM\Exception\InitException;
|
|||||||
|
|
||||||
class ConsoleApplication extends Application
|
class ConsoleApplication extends Application
|
||||||
{
|
{
|
||||||
public const VERSION_ID = 438;
|
public const VERSION_ID = 439;
|
||||||
|
|
||||||
public const VERSION = '2.7.0-beta3';
|
public const VERSION = '2.7.0-beta4';
|
||||||
|
|
||||||
private static $obj;
|
private static $obj;
|
||||||
|
|
||||||
|
|||||||
@ -30,7 +30,10 @@ class EventTracer
|
|||||||
public static function getCurrentEventMiddlewares()
|
public static function getCurrentEventMiddlewares()
|
||||||
{
|
{
|
||||||
$current_event = self::getCurrentEvent();
|
$current_event = self::getCurrentEvent();
|
||||||
if (!isset($current_event->class, $current_event->method)) {
|
if (empty($current_event->class)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (empty($current_event->method)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return EventManager::$middleware_map[$current_event->class][$current_event->method] ?? [];
|
return EventManager::$middleware_map[$current_event->class][$current_event->method] ?? [];
|
||||||
|
|||||||
@ -39,7 +39,7 @@ class OnRequest implements SwooleEvent
|
|||||||
|
|
||||||
$dis1 = new EventDispatcher(OnRequestEvent::class);
|
$dis1 = new EventDispatcher(OnRequestEvent::class);
|
||||||
$dis1->setRuleFunction(function ($v) {
|
$dis1->setRuleFunction(function ($v) {
|
||||||
return eval('return ' . $v->getRule() . ';') ? true : false;
|
return (bool) eval('return ' . $v->getRule() . ';');
|
||||||
});
|
});
|
||||||
|
|
||||||
$dis = new EventDispatcher(OnSwooleEvent::class);
|
$dis = new EventDispatcher(OnSwooleEvent::class);
|
||||||
@ -61,8 +61,7 @@ class OnRequest implements SwooleEvent
|
|||||||
if ($result === true) {
|
if ($result === true) {
|
||||||
ctx()->setCache('params', $params);
|
ctx()->setCache('params', $params);
|
||||||
$dispatcher = new EventDispatcher(RequestMapping::class);
|
$dispatcher = new EventDispatcher(RequestMapping::class);
|
||||||
$div = new RequestMapping();
|
$div = new RequestMapping($node['route']);
|
||||||
$div->route = $node['route'];
|
|
||||||
$div->params = $params;
|
$div->params = $params;
|
||||||
$div->method = $node['method'];
|
$div->method = $node['method'];
|
||||||
$div->request_method = $node['request_method'];
|
$div->request_method = $node['request_method'];
|
||||||
|
|||||||
@ -4,6 +4,12 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Exception;
|
namespace ZM\Exception;
|
||||||
|
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
class InvalidArgumentException extends ZMException
|
class InvalidArgumentException extends ZMException
|
||||||
{
|
{
|
||||||
|
public function __construct($message = '', $code = 0, Throwable $previous = null)
|
||||||
|
{
|
||||||
|
parent::__construct(zm_internal_errcode('E00074') . $message, $code, $previous);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,6 +76,7 @@ class Response
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed ...$params
|
* @param mixed ...$params
|
||||||
|
* @param mixed $name
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function rawcookie($name, ...$params)
|
public function rawcookie($name, ...$params)
|
||||||
|
|||||||
@ -35,6 +35,7 @@ class AnnotationParserRegisterTest extends TestCase
|
|||||||
public function testAnnotation() {
|
public function testAnnotation() {
|
||||||
ob_start();
|
ob_start();
|
||||||
$gen = $this->parser->generateAnnotationEvents();
|
$gen = $this->parser->generateAnnotationEvents();
|
||||||
|
//zm_dump($gen);
|
||||||
$m = $gen[OnStart::class][0]->method;
|
$m = $gen[OnStart::class][0]->method;
|
||||||
$class = $gen[OnStart::class][0]->class;
|
$class = $gen[OnStart::class][0]->class;
|
||||||
$c = new $class();
|
$c = new $class();
|
||||||
@ -43,12 +44,10 @@ class AnnotationParserRegisterTest extends TestCase
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
}
|
}
|
||||||
$result = ob_get_clean();
|
$result = ob_get_clean();
|
||||||
echo $result;
|
|
||||||
$this->assertStringContainsString("我开始了!", $result);
|
$this->assertStringContainsString("我开始了!", $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAnnotation2() {
|
public function testAnnotation2() {
|
||||||
|
|
||||||
foreach ($this->parser->generateAnnotationEvents() as $k => $v) {
|
foreach ($this->parser->generateAnnotationEvents() as $k => $v) {
|
||||||
foreach ($v as $vs) {
|
foreach ($v as $vs) {
|
||||||
$this->assertTrue($vs->method === null || $vs->method != '');
|
$this->assertTrue($vs->method === null || $vs->method != '');
|
||||||
@ -57,22 +56,9 @@ class AnnotationParserRegisterTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAnnotationMap() {
|
|
||||||
$map = $this->parser->getMiddlewareMap();
|
|
||||||
$this->assertContainsEquals("timer", $map[Hello::class]["timer"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testMiddlewares() {
|
public function testMiddlewares() {
|
||||||
$wares = $this->parser->getMiddlewares();
|
$wares = $this->parser->getMiddlewares();
|
||||||
|
zm_dump($wares);
|
||||||
$this->assertArrayHasKey("timer", $wares);
|
$this->assertArrayHasKey("timer", $wares);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testReqMapping() {
|
|
||||||
$mapping = $this->parser->getReqMapping();
|
|
||||||
$this->assertEquals("index", $mapping["method"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testTracer() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user