diff --git a/Annotation/Annotation.php b/Annotation/Annotation.php index 4dbcaffe..4d6784a3 100644 --- a/Annotation/Annotation.php +++ b/Annotation/Annotation.php @@ -4,6 +4,7 @@ namespace Annotation; +use Database\InjectProperty; use DirectoryIterator; use Exception; use Snowflake\Abstracts\Component; @@ -20,7 +21,7 @@ class Annotation extends Component private Loader $_loader; - public function init(): void + #[Aspect(InjectProperty::class)] public function init(): void { $this->_loader = new Loader(); } diff --git a/Database/Base/BaseActiveRecord.php b/Database/Base/BaseActiveRecord.php index 42de165a..e83d2b44 100644 --- a/Database/Base/BaseActiveRecord.php +++ b/Database/Base/BaseActiveRecord.php @@ -136,10 +136,10 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess /** - * @throws Exception + * @throws NotFindClassException + * @throws ReflectionException */ - #[Aspect(InjectProperty::class)] - public function init() + #[Aspect(InjectProperty::class)] public function init() { if (!Context::hasContext(Relation::class)) { $relation = Snowflake::createObject(Relation::class); diff --git a/Database/Connection.php b/Database/Connection.php index 5d42bf28..719df537 100644 --- a/Database/Connection.php +++ b/Database/Connection.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Database; +use Annotation\Aspect; use JetBrains\PhpStorm\Pure; use ReflectionException; use Snowflake\Abstracts\Component; @@ -66,7 +67,7 @@ class Connection extends Component /** * @throws Exception */ - public function init() + #[Aspect(InjectProperty::class)] public function init() { $event = Snowflake::app()->getEvent(); $event->on(Event::SYSTEM_RESOURCE_CLEAN, [$this, 'disconnect']); diff --git a/HttpServer/Events/OnRequest.php b/HttpServer/Events/OnRequest.php index c50096c2..8196d210 100644 --- a/HttpServer/Events/OnRequest.php +++ b/HttpServer/Events/OnRequest.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace HttpServer\Events; +use Annotation\Aspect; +use Database\InjectProperty; use Exception; use HttpServer\Abstracts\Callback; use HttpServer\Exception\ExitException; @@ -36,7 +38,7 @@ class OnRequest extends Callback /** * @throws Exception */ - public function init() + #[Aspect(InjectProperty::class)] public function init() { $this->event = Snowflake::app()->getEvent(); $this->logger = Snowflake::app()->getLogger(); diff --git a/HttpServer/Route/Router.php b/HttpServer/Route/Router.php index 42ad790f..df9e7b37 100644 --- a/HttpServer/Route/Router.php +++ b/HttpServer/Route/Router.php @@ -3,7 +3,9 @@ declare(strict_types=1); namespace HttpServer\Route; +use Annotation\Aspect; use Closure; +use Database\InjectProperty; use Exception; use HttpServer\Abstracts\HttpService; use HttpServer\Http\Request; @@ -57,7 +59,7 @@ class Router extends HttpService implements RouterInterface * @throws ConfigException * 初始化函数路径 */ - public function init() + #[Aspect(InjectProperty::class)] public function init() { $this->dir = Config::get('http.namespace', false, $this->dir); } diff --git a/HttpServer/Shutdown.php b/HttpServer/Shutdown.php index fa624f37..e5bba0c7 100644 --- a/HttpServer/Shutdown.php +++ b/HttpServer/Shutdown.php @@ -4,6 +4,8 @@ namespace HttpServer; +use Annotation\Aspect; +use Database\InjectProperty; use Exception; use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Config; @@ -30,7 +32,7 @@ class Shutdown extends Component /** * @throws Exception */ - public function init() + #[Aspect(InjectProperty::class)] public function init() { $this->taskDirectory = storage(null, 'pid/task'); $this->workerDirectory = storage(null, 'pid/worker'); diff --git a/System/Abstracts/BaseObject.php b/System/Abstracts/BaseObject.php index 12ab7fd0..2d938b67 100644 --- a/System/Abstracts/BaseObject.php +++ b/System/Abstracts/BaseObject.php @@ -12,11 +12,6 @@ namespace Snowflake\Abstracts; use Exception; use JetBrains\PhpStorm\Pure; -use ReflectionException; -use Snowflake\Aop; -use Snowflake\Error\Logger; -use Snowflake\Exception\ComponentException; -use Snowflake\Exception\NotFindClassException; use Snowflake\Snowflake; use Swoole\Coroutine; diff --git a/System/Application.php b/System/Application.php index 00f88079..cb3016e3 100644 --- a/System/Application.php +++ b/System/Application.php @@ -10,9 +10,11 @@ declare(strict_types=1); namespace Snowflake; +use Annotation\Aspect; use Console\Console; use Console\ConsoleProviders; use Database\DatabasesProviders; +use Database\InjectProperty; use Exception; use HttpServer\ServerProviders; use Snowflake\Abstracts\BaseApplication; @@ -46,7 +48,7 @@ class Application extends BaseApplication /** * @throws NotFindClassException */ - public function init() + #[Aspect(InjectProperty::class)] public function init() { $this->import(ConsoleProviders::class); $this->import(DatabasesProviders::class); diff --git a/System/Cache/Redis.php b/System/Cache/Redis.php index f633cbe7..27423aed 100644 --- a/System/Cache/Redis.php +++ b/System/Cache/Redis.php @@ -9,6 +9,8 @@ declare(strict_types=1); namespace Snowflake\Cache; +use Annotation\Aspect; +use Database\InjectProperty; use Exception; use ReflectionException; use Snowflake\Abstracts\Component; @@ -36,7 +38,7 @@ class Redis extends Component /** * @throws Exception */ - public function init() + #[Aspect(InjectProperty::class)] public function init() { $event = Snowflake::app()->getEvent(); $event->on(Event::SYSTEM_RESOURCE_CLEAN, [$this, 'destroy']); diff --git a/System/Jwt/Jwt.php b/System/Jwt/Jwt.php index f13cecbd..8709efb1 100644 --- a/System/Jwt/Jwt.php +++ b/System/Jwt/Jwt.php @@ -3,6 +3,8 @@ declare(strict_types=1); namespace Snowflake\Jwt; +use Annotation\Aspect; +use Database\InjectProperty; use Exception; use HttpServer\Http\HttpHeaders; use ReflectionException; @@ -79,7 +81,7 @@ mlAZUEjsoaT9vjvjGTxl3uCm0TX5KTgtSJIt2kA1tYVjQef+/iZTHxY= /** * @throws ConfigException */ - public function init() + #[Aspect(InjectProperty::class)] public function init() { if (!Config::has('ssl.public') || !Config::has('ssl.private')) { return;