改名
This commit is contained in:
@@ -28,9 +28,10 @@ defined('ASPECT_ERROR') or define('ASPECT_ERROR', 'Aspect annotation must implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
public function execute(mixed $class, mixed $method = ''): mixed
|
*/
|
||||||
|
public function execute(mixed $class, mixed $method = ''): bool
|
||||||
{
|
{
|
||||||
// TODO: Change the autogenerated stub
|
// TODO: Change the autogenerated stub
|
||||||
if (!in_array(IAspect::class, class_implements($this->aspect))) {
|
if (!in_array(IAspect::class, class_implements($this->aspect))) {
|
||||||
|
|||||||
@@ -29,11 +29,12 @@ use Snowflake\Snowflake;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param mixed $class
|
||||||
|
* @param mixed|null $method
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function execute(mixed $class, mixed $method = null): mixed
|
public function execute(mixed $class, mixed $method = null): bool
|
||||||
{
|
{
|
||||||
$async = Snowflake::app()->getAsync();
|
$async = Snowflake::app()->getAsync();
|
||||||
$async->addAsync($this->name, $class);
|
$async->addAsync($this->name, $class);
|
||||||
|
|||||||
@@ -29,11 +29,12 @@ use Snowflake\Event as SEvent;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param mixed $class
|
||||||
|
* @param mixed|null $method
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function execute(mixed $class, mixed $method = null): mixed
|
public function execute(mixed $class, mixed $method = null): bool
|
||||||
{
|
{
|
||||||
// TODO: Implement execute() method.
|
// TODO: Implement execute() method.
|
||||||
SEvent::on($this->name, [$class, $method], $this->params);
|
SEvent::on($this->name, [$class, $method], $this->params);
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ interface IAnnotation
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param mixed $class
|
||||||
|
* @param mixed $method
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function execute(mixed $class, mixed $method = ''): mixed;
|
public function execute(mixed $class, mixed $method = ''): mixed;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace Annotation;
|
|||||||
|
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use ReflectionException;
|
||||||
use ReflectionProperty;
|
use ReflectionProperty;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
|
|
||||||
@@ -27,11 +28,13 @@ use Snowflake\Snowflake;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param mixed $class
|
||||||
* @return mixed
|
* @param mixed|null $method
|
||||||
|
* @return bool
|
||||||
|
* @throws ReflectionException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function execute(mixed $class, mixed $method = null): mixed
|
public function execute(mixed $class, mixed $method = null): bool
|
||||||
{
|
{
|
||||||
$injectValue = $this->parseInjectValue();
|
$injectValue = $this->parseInjectValue();
|
||||||
if (!($method instanceof ReflectionProperty)) {
|
if (!($method instanceof ReflectionProperty)) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
namespace Annotation;
|
namespace Annotation;
|
||||||
|
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use Kafka\ConsumerInterface;
|
use Kafka\ConsumerInterface;
|
||||||
use Kafka\TaskContainer;
|
use Kafka\TaskContainer;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
@@ -27,10 +28,12 @@ use Snowflake\Snowflake;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param mixed $class
|
||||||
* @return mixed
|
* @param mixed|null $method
|
||||||
|
* @return bool
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function execute(mixed $class, mixed $method = null): mixed
|
public function execute(mixed $class, mixed $method = null): bool
|
||||||
{
|
{
|
||||||
if (!($class instanceof ConsumerInterface)) {
|
if (!($class instanceof ConsumerInterface)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+33
-18
@@ -10,8 +10,11 @@ use Annotation\Model\Set;
|
|||||||
use Attribute;
|
use Attribute;
|
||||||
use DirectoryIterator;
|
use DirectoryIterator;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use ReflectionClass;
|
||||||
|
use ReflectionException;
|
||||||
use ReflectionMethod;
|
use ReflectionMethod;
|
||||||
use Snowflake\Abstracts\BaseObject;
|
use Snowflake\Abstracts\BaseObject;
|
||||||
|
use Snowflake\Exception\NotFindClassException;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
@@ -30,6 +33,9 @@ class Loader extends BaseObject
|
|||||||
private array $_directory = [];
|
private array $_directory = [];
|
||||||
|
|
||||||
|
|
||||||
|
private array $_annotationMaps = [];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@@ -183,24 +189,24 @@ class Loader extends BaseObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $path
|
* @param DirectoryIterator $path
|
||||||
* @param string $namespace
|
* @param string $namespace
|
||||||
* @return \ReflectionClass|null
|
* @return ReflectionClass|null
|
||||||
* @throws \ReflectionException
|
* @throws ReflectionException
|
||||||
* @throws \Snowflake\Exception\NotFindClassException
|
* @throws NotFindClassException
|
||||||
*/
|
*/
|
||||||
private function getReflect(DirectoryIterator $path, string $namespace): ?\ReflectionClass
|
private function getReflect(DirectoryIterator $path, string $namespace): ?ReflectionClass
|
||||||
{
|
{
|
||||||
return Snowflake::getDi()->getReflect($this->explodeFileName($path, $namespace));
|
return Snowflake::getDi()->getReflect($this->explodeFileName($path, $namespace));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \ReflectionClass $replace
|
* @param ReflectionClass $replace
|
||||||
* @param array $_array
|
* @param array $_array
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function _targets(\ReflectionClass $replace, array $_array): array
|
private function _targets(ReflectionClass $replace, array $_array): array
|
||||||
{
|
{
|
||||||
foreach ($replace->getAttributes() as $attribute) {
|
foreach ($replace->getAttributes() as $attribute) {
|
||||||
if ($attribute->getName() == Attribute::class) {
|
if ($attribute->getName() == Attribute::class) {
|
||||||
@@ -216,11 +222,11 @@ class Loader extends BaseObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \ReflectionClass $replace
|
* @param ReflectionClass $replace
|
||||||
* @param array $_array
|
* @param array $_array
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function _methods(\ReflectionClass $replace, array $_array): array
|
private function _methods(ReflectionClass $replace, array $_array): array
|
||||||
{
|
{
|
||||||
$methods = $replace->getMethods(ReflectionMethod::IS_PUBLIC);
|
$methods = $replace->getMethods(ReflectionMethod::IS_PUBLIC);
|
||||||
foreach ($methods as $method) {
|
foreach ($methods as $method) {
|
||||||
@@ -238,11 +244,11 @@ class Loader extends BaseObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \ReflectionClass $replace
|
* @param ReflectionClass $replace
|
||||||
* @param array $_array
|
* @param array $_array
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function _properties(\ReflectionClass $replace, array $_array): array
|
private function _properties(ReflectionClass $replace, array $_array): array
|
||||||
{
|
{
|
||||||
$methods = $replace->getProperties();
|
$methods = $replace->getProperties();
|
||||||
foreach ($methods as $method) {
|
foreach ($methods as $method) {
|
||||||
@@ -317,6 +323,7 @@ class Loader extends BaseObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $classes
|
* @param array $classes
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function execute(array $classes)
|
private function execute(array $classes)
|
||||||
{
|
{
|
||||||
@@ -330,12 +337,22 @@ class Loader extends BaseObject
|
|||||||
if ($annotations === null) {
|
if ($annotations === null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var \Annotation\Attribute $value */
|
|
||||||
foreach ($annotations['target'] ?? [] as $value) {
|
|
||||||
$value->execute($annotations['handler']);
|
|
||||||
}
|
|
||||||
foreach ($annotations['methods'] as $name => $attribute) {
|
foreach ($annotations['methods'] as $name => $attribute) {
|
||||||
|
$this->methods($annotations, $attribute, $annotation, $className, $name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $annotations
|
||||||
|
* @param $attribute
|
||||||
|
* @param $annotation
|
||||||
|
* @param $className
|
||||||
|
* @param $name
|
||||||
|
*/
|
||||||
|
private function methods($annotations, $attribute, $annotation, $className, $name)
|
||||||
|
{
|
||||||
foreach ($attribute as $value) {
|
foreach ($attribute as $value) {
|
||||||
if ($value instanceof Relation) {
|
if ($value instanceof Relation) {
|
||||||
$annotation->addRelate($className, $value->name, $name);
|
$annotation->addRelate($className, $value->name, $name);
|
||||||
@@ -348,7 +365,5 @@ class Loader extends BaseObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,10 +37,10 @@ use Snowflake\Snowflake;
|
|||||||
/**
|
/**
|
||||||
* @param object $class
|
* @param object $class
|
||||||
* @param string $method
|
* @param string $method
|
||||||
* @return mixed
|
* @return bool
|
||||||
* @throws \Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function execute(mixed $class, mixed $method = null): mixed
|
public function execute(mixed $class, mixed $method = null): bool
|
||||||
{
|
{
|
||||||
$class = ['class' => $class::class];
|
$class = ['class' => $class::class];
|
||||||
if (!empty($this->args)) {
|
if (!empty($this->args)) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace Annotation\Model;
|
|||||||
use Annotation\Annotation;
|
use Annotation\Annotation;
|
||||||
use Attribute;
|
use Attribute;
|
||||||
use Database\ActiveRecord;
|
use Database\ActiveRecord;
|
||||||
|
use Exception;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
|
|
||||||
|
|
||||||
@@ -28,8 +29,10 @@ use Snowflake\Snowflake;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param mixed $class
|
||||||
* @return ActiveRecord
|
* @param mixed|null $method
|
||||||
|
* @return bool
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function execute(mixed $class, mixed $method = null): bool
|
public function execute(mixed $class, mixed $method = null): bool
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace Annotation\Model;
|
|||||||
|
|
||||||
use Annotation\Attribute;
|
use Annotation\Attribute;
|
||||||
use Database\ActiveRecord;
|
use Database\ActiveRecord;
|
||||||
|
use Exception;
|
||||||
use JetBrains\PhpStorm\Pure;
|
use JetBrains\PhpStorm\Pure;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
|
|
||||||
@@ -28,8 +29,10 @@ use Snowflake\Snowflake;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param mixed $class
|
||||||
|
* @param mixed|null $method
|
||||||
* @return bool
|
* @return bool
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function execute(mixed $class, mixed $method = null): bool
|
public function execute(mixed $class, mixed $method = null): bool
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace Annotation\Model;
|
|||||||
|
|
||||||
use Annotation\Attribute;
|
use Annotation\Attribute;
|
||||||
use Database\ActiveRecord;
|
use Database\ActiveRecord;
|
||||||
|
use Exception;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
|
|
||||||
#[\Attribute(\Attribute::TARGET_METHOD)] class Set extends Attribute
|
#[\Attribute(\Attribute::TARGET_METHOD)] class Set extends Attribute
|
||||||
@@ -25,7 +26,7 @@ use Snowflake\Snowflake;
|
|||||||
* @param mixed $class
|
* @param mixed $class
|
||||||
* @param mixed|null $method
|
* @param mixed|null $method
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws \Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function execute(mixed $class, mixed $method = null): bool
|
public function execute(mixed $class, mixed $method = null): bool
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ use Annotation\Attribute;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param mixed $class
|
||||||
|
* @param mixed|null $method
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function execute(mixed $class, mixed $method = null): array
|
public function execute(mixed $class, mixed $method = null): array
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ use Snowflake\Snowflake;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param mixed $class
|
||||||
|
* @param mixed|null $method
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
public function execute(mixed $class, mixed $method = null): bool
|
public function execute(mixed $class, mixed $method = null): bool
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ use Snowflake\Snowflake;
|
|||||||
* @param string|array $interceptor
|
* @param string|array $interceptor
|
||||||
* @throws
|
* @throws
|
||||||
*/
|
*/
|
||||||
#[Pure] public function __construct(public string|array $interceptor)
|
public function __construct(public string|array $interceptor)
|
||||||
{
|
{
|
||||||
if (is_string($this->interceptor)) {
|
if (is_string($this->interceptor)) {
|
||||||
$this->interceptor = [$this->interceptor];
|
$this->interceptor = [$this->interceptor];
|
||||||
@@ -40,7 +40,8 @@ use Snowflake\Snowflake;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param mixed $class
|
||||||
|
* @param mixed|null $method
|
||||||
* @return Interceptor
|
* @return Interceptor
|
||||||
*/
|
*/
|
||||||
public function execute(mixed $class, mixed $method = null): static
|
public function execute(mixed $class, mixed $method = null): static
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ use Snowflake\Snowflake;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param mixed $class
|
||||||
|
* @param mixed|null $method
|
||||||
* @return Limits
|
* @return Limits
|
||||||
*/
|
*/
|
||||||
public function execute(mixed $class, mixed $method = null): static
|
public function execute(mixed $class, mixed $method = null): static
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ use HttpServer\IInterface\Middleware as IMiddleware;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param mixed $class
|
||||||
|
* @param mixed|null $method
|
||||||
* @return Middleware
|
* @return Middleware
|
||||||
*/
|
*/
|
||||||
public function execute(mixed $class, mixed $method = null): static
|
public function execute(mixed $class, mixed $method = null): static
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ use Snowflake\Snowflake;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param mixed $class
|
||||||
|
* @param mixed|null $method
|
||||||
* @return Router
|
* @return Router
|
||||||
* @throws ConfigException
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function execute(mixed $class, mixed $method = null): Router
|
public function execute(mixed $class, mixed $method = null): Router
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ use Snowflake\Snowflake;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param mixed $class
|
||||||
|
* @param mixed|null $method
|
||||||
* @return Router
|
* @return Router
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -28,11 +28,12 @@ use Snowflake\Snowflake;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param mixed $class
|
||||||
* @return mixed
|
* @param mixed $method
|
||||||
|
* @return bool
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function execute(mixed $class, mixed $method = ''): mixed
|
public function execute(mixed $class, mixed $method = ''): bool
|
||||||
{
|
{
|
||||||
$rpc = Snowflake::app()->getRpc();
|
$rpc = Snowflake::app()->getRpc();
|
||||||
$rpc->addConsumer($this->cmd, [$class, $method]);
|
$rpc->addConsumer($this->cmd, [$class, $method]);
|
||||||
|
|||||||
@@ -38,11 +38,12 @@ use Snowflake\Snowflake;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param mixed $class
|
||||||
* @return mixed
|
* @param mixed $method
|
||||||
|
* @return bool
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function execute(mixed $class, mixed $method = ''): mixed
|
public function execute(mixed $class, mixed $method = ''): bool
|
||||||
{
|
{
|
||||||
$rpc = Snowflake::app()->getRpc();
|
$rpc = Snowflake::app()->getRpc();
|
||||||
$rpc->addProducer($this->cmd, [$class, $method], $this->config);
|
$rpc->addProducer($this->cmd, [$class, $method], $this->config);
|
||||||
|
|||||||
Reference in New Issue
Block a user