This commit is contained in:
2021-07-27 14:15:08 +08:00
parent dcb588e02d
commit 8ee27b9b14
2 changed files with 245 additions and 247 deletions
+4 -7
View File
@@ -9,7 +9,6 @@ use Annotation\Route\RpcProducer;
use Closure;
use Exception;
use HttpServer\Abstracts\HttpService;
use HttpServer\Controller;
use HttpServer\Http\Context;
use HttpServer\Http\Request;
use JetBrains\PhpStorm\Pure;
@@ -116,26 +115,24 @@ class Node extends HttpService
/** @var Aop $aop */
$aop = Snowflake::app()->get('aop');
if ($this->handler instanceof Closure || !$aop->hasAop($this->handler)) {
return static function () use ($application) {
return (static function ($application) {
$dispatchParam = Context::getContext('dispatch-param', [\request()]);
if (is_array($application->handler)) {
Snowflake::injectProperty($application->handler[0]);
}
return call_user_func($application->handler, ...$dispatchParam);
};
})($application);
}
$reflect = $aop->getAop($this->handler);
$callback = [$reflect->getMethod('invoke'), 'invokeArgs'];
return static function () use ($callback, $application, $reflect) {
return (static function ($callback, $application, $reflect) {
$dispatchParam = Context::getContext('dispatch-param', [\request()]);
$asp = $reflect->newInstance($application->handler);
if (is_array($application->handler)) {
Snowflake::injectProperty($application->handler[0]);
}
call_user_func($callback, $asp, $dispatchParam);
};
})([$reflect->getMethod('invoke'), 'invokeArgs'], $application, $reflect);
}
+2 -1
View File
@@ -12,6 +12,7 @@ use Exception;
use HttpServer\IInterface\Task;
use JetBrains\PhpStorm\Pure;
use ReflectionException;
use ReflectionProperty;
use Snowflake\Abstracts\Config;
use Snowflake\Core\Json;
use Snowflake\Di\Container;
@@ -58,7 +59,7 @@ class Snowflake
$attributes = static::getDi()->getClassProperty($class::class);
/**
* @var string $property
* @var \ReflectionProperty $attribute
* @var ReflectionProperty $attribute
*/
foreach ($attributes as $property => $attribute) {