├── LICENSE ├── README.md ├── composer.json ├── config └── config.php └── src ├── Aop ├── AfterReturningJoinPoint.php ├── AfterThrowingJoinPoint.php ├── Annotation │ ├── After.php │ ├── AfterReturning.php │ ├── AfterThrowing.php │ ├── Around.php │ ├── Aspect.php │ ├── BaseInjectValue.php │ ├── Before.php │ ├── CallableValue.php │ ├── ConstValue.php │ ├── FilterArg.php │ ├── Inject.php │ ├── InjectArg.php │ ├── PointCut.php │ └── RequestInject.php ├── Aop │ ├── FilterArgAop.php │ └── InjectArgAop.php ├── AopAnnotationLoader.php ├── AopManager.php ├── AroundJoinPoint.php ├── JoinPoint.php ├── Listener │ ├── BuildRuntimeListener.php │ ├── ImiInit.php │ └── LoadRuntimeListener.php ├── Model │ └── AopItem.php └── PointCutType.php ├── App.php ├── AppContexts.php ├── Async ├── Annotation │ ├── Async.php │ ├── Defer.php │ └── DeferAsync.php ├── Aop │ └── AsyncAop.php ├── Async.php ├── AsyncResult.php ├── Contract │ ├── IAsyncHandler.php │ └── IAsyncResult.php ├── Exception │ └── AsyncTimeoutException.php └── Sync │ └── SyncHandler.php ├── Bean ├── Annotation.php ├── Annotation │ ├── AnnotationManager.php │ ├── Base.php │ ├── Bean.php │ ├── Callback.php │ ├── ClassEventListener.php │ ├── Inherit.php │ ├── Listener.php │ ├── Model │ │ ├── AnnotationRelation.php │ │ ├── ClassAnnotation.php │ │ ├── ClassAnnotationRelation.php │ │ ├── ConstantAnnotationRelation.php │ │ ├── IAnnotationRelation.php │ │ ├── MethodAnnotationRelation.php │ │ └── PropertyAnnotationRelation.php │ ├── Parser.php │ └── Partial.php ├── AnnotationLoader.php ├── AnnotationParser.php ├── BeanFactory.php ├── BeanManager.php ├── BeanProxy.php ├── Container.php ├── Exception │ ├── ContainerException.php │ └── NotFoundException.php ├── IBean.php ├── Listener │ ├── BuildRuntimeListener.php │ └── LoadRuntimeListener.php ├── Parser │ ├── BaseParser.php │ ├── BeanParser.php │ ├── ClassEventParser.php │ ├── IParser.php │ ├── ListenerParser.php │ ├── NullParser.php │ └── PartialParser.php ├── PartialManager.php ├── ReflectionContainer.php ├── ReflectionUtil.php ├── Scanner.php ├── Traits │ └── TAutoInject.php └── Util │ ├── AttributeUtil.php │ ├── PhpParser.php │ └── TokenParser.php ├── Cache ├── Annotation │ ├── CacheEvict.php │ ├── CachePut.php │ └── Cacheable.php ├── Aop │ ├── CacheEvictAop.php │ ├── CachePutAop.php │ ├── CacheableAop.php │ └── TCacheAopHelper.php ├── CacheException.php ├── CacheManager.php ├── Handler │ ├── Apcu.php │ ├── Base.php │ ├── File.php │ ├── Memory.php │ ├── Redis.php │ ├── RedisHash.php │ └── RequestContext.php └── InvalidArgumentException.php ├── Cli ├── Annotation │ ├── Argument.php │ ├── Command.php │ ├── CommandAction.php │ └── Option.php ├── ArgType.php ├── CliApp.php ├── CliAppContexts.php ├── CliManager.php ├── Contract │ └── BaseCommand.php ├── Event │ └── CommandEvents.php ├── ImiArgvInput.php ├── ImiCommand.php ├── ImiConsoleOutput.php ├── Listener │ ├── BuildRuntimeListener.php │ └── LoadRuntimeListener.php ├── Parser │ └── ToolParser.php ├── Tools │ └── Imi │ │ └── Imi.php ├── bin │ └── imi-cli └── bootstrap.php ├── Config.php ├── Config ├── Annotation │ ├── ConfigValue.php │ └── EnvValue.php └── DotEnv │ ├── DotEnv.php │ ├── EntryParser.php │ └── Parser.php ├── ConnectionContext.php ├── Contract └── IWorker.php ├── Controller ├── HttpController.php ├── README.md ├── TcpController.php ├── UdpController.php └── WebSocketController.php ├── Core ├── App │ ├── Contract │ │ ├── BaseApp.php │ │ └── IApp.php │ └── Enum │ │ └── LoadRuntimeResult.php ├── Component │ ├── ComponentManager.php │ └── Listener │ │ ├── BuildRuntimeListener.php │ │ └── LoadRuntimeListener.php ├── Context │ ├── ContextData.php │ ├── Contract │ │ └── IContextManager.php │ ├── DefaultContextManager.php │ └── Exception │ │ ├── ContextExistsException.php │ │ └── ContextNotFoundException.php ├── CoreEvents.php └── Runtime │ ├── Contract │ └── IRuntimeModeHandler.php │ ├── Event │ ├── BuildRuntimeInfoEvent.php │ └── LoadRuntimeInfoEvent.php │ ├── Handler │ └── DefaultRuntimeModeHandler.php │ └── Runtime.php ├── Cron ├── Annotation │ └── Cron.php ├── Client.php ├── Consts │ ├── CronTaskType.php │ └── UniqueLevel.php ├── Contract │ ├── ICronManager.php │ ├── ICronTask.php │ └── IScheduler.php ├── CronCalculator.php ├── CronLock.php ├── CronManager.php ├── CronRule.php ├── CronTask.php ├── CronWorker.php ├── Listener │ └── Init.php ├── Message │ ├── AddCron.php │ ├── Clear.php │ ├── CommonMsg.php │ ├── GetRealTasks.php │ ├── GetTask.php │ ├── HasTask.php │ ├── IMessage.php │ ├── RemoveCron.php │ └── Result.php ├── Scheduler.php ├── Traits │ └── TWorkerReport.php └── Util │ └── CronUtil.php ├── Env.php ├── Event ├── CaseInsensitiveListenerProvider.php ├── ClassEventManager.php ├── CommonEvent.php ├── Contract │ ├── IEvent.php │ ├── IEventDispatcher.php │ └── IListenerProvider.php ├── Event.php ├── EventController.php ├── EventDispatcher.php ├── EventManager.php ├── EventParam.php ├── IEvent.php ├── IEventListener.php ├── Listener │ ├── BuildRuntimeListener.php │ └── LoadRuntimeListener.php ├── ListenerProvider.php ├── RegisteredListener.php └── TEvent.php ├── Facade ├── Annotation │ └── Facade.php ├── BaseFacade.php └── Cli │ ├── FacadeGenerate.php │ └── template.tpl ├── HotUpdate ├── Event │ ├── HotUpdateBeginBuildEvent.php │ └── HotUpdateEvents.php └── Monitor │ ├── BaseMonitor.php │ ├── FileMTime.php │ ├── IMonitor.php │ └── Inotify.php ├── HttpValidate ├── Annotation │ └── HttpValidation.php └── Aop │ └── AutoValidationAop.php ├── IDEHelper └── BuildIDEHelper.php ├── Lock ├── Annotation │ └── Lockable.php ├── Aop │ ├── LockAop.php │ └── TLockableParser.php ├── Exception │ └── LockFailException.php ├── Handler │ ├── BaseLock.php │ ├── ILockHandler.php │ └── Redis.php ├── Lock.php └── LockConfigOption.php ├── Log ├── AbstractErrorEventHandler.php ├── ErrorLog.php ├── Formatter │ └── ConsoleLineFormatter.php ├── Handler │ └── ConsoleHandler.php ├── IErrorEventHandler.php ├── Log.php ├── LogLevel.php ├── Logger.php └── MonoLogger.php ├── Main.php ├── Main ├── AppBaseMain.php ├── BaseMain.php ├── Helper.php └── IMain.php ├── Pool ├── Annotation │ └── PoolResource.php ├── BasePool.php ├── BasePoolResource.php ├── BaseSyncPool.php ├── Event │ └── CheckPoolResourceEvent.php ├── Interfaces │ ├── IPool.php │ ├── IPoolConfig.php │ └── IPoolResource.php ├── Listener │ ├── ClearListener.php │ ├── RequestContextDestroy.php │ └── WorkerStart.php ├── PoolConfig.php ├── PoolItem.php ├── PoolManager.php ├── ResourceConfigMode.php └── TUriResourceConfig.php ├── Process ├── AutoRunProcessManager.php └── Event │ ├── ProcessBeginEvent.php │ ├── ProcessEndEvent.php │ └── ProcessEvents.php ├── Redis ├── Annotation │ └── RedisInject.php ├── Enum │ └── RedisMode.php ├── Listener │ └── CheckPoolResource.php ├── Redis.php ├── RedisHandler.php ├── RedisManager.php ├── RedisResource.php ├── SyncRedisPool.php └── Traits │ └── TRedisPool.php ├── RequestContext.php ├── RequestContextProxy ├── Annotation │ └── RequestContextProxy.php ├── BaseRequestContextProxy.php └── Cli │ ├── RequestContextProxyGenerate.php │ └── template.tpl ├── Server ├── Annotation │ └── ServerInject.php ├── ConnectionContext │ ├── Event │ │ ├── ConnectionContextEvents.php │ │ ├── Listener │ │ │ └── IConnectionContextRestoreListener.php │ │ └── Param │ │ │ └── ConnectionContextRestoreParam.php │ ├── StoreHandler.php │ ├── StoreHandler │ │ ├── IHandler.php │ │ ├── Local.php │ │ └── Redis.php │ └── Traits │ │ └── TConnectionContextRelease.php ├── Contract │ ├── BaseServer.php │ ├── IServer.php │ └── IServerUtil.php ├── DataParser │ ├── DataParser.php │ ├── IParser.php │ ├── JsonArrayParser.php │ └── JsonObjectParser.php ├── Event │ ├── AfterCreateServerEvent.php │ ├── BeforeCreateServerEvent.php │ ├── PipeMessageEvent.php │ ├── ServerEvents.php │ ├── WorkerStartEvent.php │ └── WorkerStopEvent.php ├── Group │ ├── ClientIdMap.php │ ├── Contract │ │ └── IServerGroup.php │ ├── Event │ │ ├── JoinGroupEvent.php │ │ ├── LeaveGroupEvent.php │ │ └── ServerGroupEvents.php │ ├── Exception │ │ └── MethodNotFoundException.php │ ├── Group.php │ ├── Handler │ │ ├── IGroupHandler.php │ │ ├── Local.php │ │ └── Redis.php │ ├── Listener │ │ └── GroupRestore.php │ └── TServerGroup.php ├── Http │ ├── Annotation │ │ └── RequestParam.php │ ├── Cli │ │ ├── ControllerGenerate.php │ │ ├── restTemplate.tpl │ │ └── template.tpl │ ├── Controller │ │ └── HttpController.php │ ├── Dispatcher.php │ ├── Error │ │ ├── ErrorHandler.php │ │ ├── ExecuteTimeoutHandler.php │ │ ├── HttpNotFoundHandler.php │ │ ├── IErrorHandler.php │ │ ├── IExecuteTimeoutHandler.php │ │ ├── IHttpNotFoundHandler.php │ │ └── JsonErrorHandler.php │ ├── Listener │ │ └── HttpRouteInit.php │ ├── Message │ │ ├── Contract │ │ │ ├── IHttpRequest.php │ │ │ └── IHttpResponse.php │ │ ├── Emitter │ │ │ ├── Contract │ │ │ │ ├── BaseEmitter.php │ │ │ │ └── IResponseBodyEmitter.php │ │ │ ├── Handler │ │ │ │ └── IEmitHandler.php │ │ │ ├── SseEmitter.php │ │ │ └── SseMessageEvent.php │ │ ├── Proxy │ │ │ ├── RequestProxy.php │ │ │ ├── RequestProxyObject.php │ │ │ ├── ResponseProxy.php │ │ │ └── ResponseProxyObject.php │ │ ├── Request.php │ │ ├── Response.php │ │ └── UploadedFile.php │ ├── Middleware │ │ ├── ActionMiddleware.php │ │ ├── ActionWrapMiddleware.php │ │ ├── OptionsMiddleware.php │ │ └── RouteMiddleware.php │ ├── Parser │ │ └── ControllerParser.php │ ├── RequestHandler.php │ ├── Route │ │ ├── Annotation │ │ │ ├── Action.php │ │ │ ├── Controller.php │ │ │ ├── Middleware.php │ │ │ └── Route.php │ │ ├── HttpRoute.php │ │ ├── RouteItem.php │ │ ├── RouteResult.php │ │ └── Router.php │ ├── Struct │ │ └── ActionMethodItem.php │ └── SuperGlobals │ │ ├── Cookie.php │ │ ├── Files.php │ │ ├── Get.php │ │ ├── Listener │ │ └── SuperGlobals.php │ │ ├── Post.php │ │ ├── Request.php │ │ ├── Server.php │ │ └── Session.php ├── Protocol.php ├── Route │ └── TMiddleware.php ├── Server.php ├── ServerManager.php ├── Session │ ├── Handler │ │ ├── Base.php │ │ ├── File.php │ │ ├── ISessionHandler.php │ │ └── Redis.php │ ├── Middleware │ │ └── HttpSessionMiddleware.php │ ├── Session.php │ ├── SessionConfig.php │ ├── SessionCookie.php │ └── SessionManager.php ├── TcpServer │ ├── Contract │ │ └── ITcpServer.php │ ├── Controller │ │ └── TcpController.php │ ├── Dispatcher.php │ ├── Error │ │ ├── ErrorHandler.php │ │ ├── IErrorHandler.php │ │ ├── ITcpRouteNotFoundHandler.php │ │ └── TcpRouteNotFoundHandler.php │ ├── IReceiveHandler.php │ ├── Listener │ │ └── TcpRouteInit.php │ ├── Message │ │ ├── IReceiveData.php │ │ ├── Proxy │ │ │ └── ReceiveDataProxy.php │ │ └── ReceiveData.php │ ├── Middleware │ │ ├── ActionMiddleware.php │ │ ├── ActionWrapMiddleware.php │ │ ├── IMiddleware.php │ │ └── RouteMiddleware.php │ ├── Parser │ │ └── TcpControllerParser.php │ ├── ReceiveHandler.php │ └── Route │ │ ├── Annotation │ │ ├── TcpAction.php │ │ ├── TcpController.php │ │ ├── TcpMiddleware.php │ │ └── TcpRoute.php │ │ ├── IRoute.php │ │ ├── RouteItem.php │ │ ├── RouteResult.php │ │ └── TcpRoute.php ├── UdpServer │ ├── Contract │ │ └── IUdpServer.php │ ├── Controller │ │ └── UdpController.php │ ├── Dispatcher.php │ ├── Error │ │ ├── ErrorHandler.php │ │ ├── IErrorHandler.php │ │ ├── IUdpRouteNotFoundHandler.php │ │ └── UdpRouteNotFoundHandler.php │ ├── IPacketHandler.php │ ├── Listener │ │ └── UdpRouteInit.php │ ├── Message │ │ ├── IPacketData.php │ │ ├── PacketData.php │ │ └── Proxy │ │ │ └── PacketDataProxy.php │ ├── Middleware │ │ ├── ActionMiddleware.php │ │ ├── ActionWrapMiddleware.php │ │ ├── IMiddleware.php │ │ └── RouteMiddleware.php │ ├── PacketHandler.php │ ├── Parser │ │ └── UdpControllerParser.php │ └── Route │ │ ├── Annotation │ │ ├── UdpAction.php │ │ ├── UdpController.php │ │ ├── UdpMiddleware.php │ │ └── UdpRoute.php │ │ ├── IRoute.php │ │ ├── RouteItem.php │ │ ├── RouteResult.php │ │ └── UdpRoute.php ├── View │ ├── Annotation │ │ ├── BaseViewOption.php │ │ ├── HtmlView.php │ │ ├── JsonView.php │ │ ├── View.php │ │ └── XmlView.php │ ├── Engine │ │ ├── IEngine.php │ │ └── Php.php │ ├── Handler │ │ ├── Html.php │ │ ├── IHandler.php │ │ ├── Json.php │ │ └── Xml.php │ ├── Parser │ │ └── ViewParser.php │ └── View.php └── WebSocket │ ├── Contract │ └── IWebSocketServer.php │ ├── Controller │ └── WebSocketController.php │ ├── Dispatcher.php │ ├── Enum │ └── NonControlFrameType.php │ ├── Error │ ├── ErrorHandler.php │ ├── IErrorHandler.php │ ├── IWSRouteNotFoundHandler.php │ └── WSRouteNotFoundHandler.php │ ├── IMessageHandler.php │ ├── Listener │ └── WSRouteInit.php │ ├── Message │ ├── Frame.php │ ├── IFrame.php │ └── Proxy │ │ └── FrameProxy.php │ ├── MessageHandler.php │ ├── Middleware │ ├── ActionMiddleware.php │ ├── ActionWrapMiddleware.php │ ├── IMiddleware.php │ └── RouteMiddleware.php │ ├── Parser │ └── WSControllerParser.php │ └── Route │ ├── Annotation │ ├── WSAction.php │ ├── WSConfig.php │ ├── WSController.php │ ├── WSMiddleware.php │ └── WSRoute.php │ ├── IRoute.php │ ├── RouteItem.php │ ├── RouteResult.php │ └── WSRoute.php ├── Timer ├── Contract │ └── ITimer.php ├── Handler │ └── DefaultTimer.php └── Timer.php ├── Util ├── ArrayData.php ├── ArrayList.php ├── ArrayUtil.php ├── Bit.php ├── ClassObject.php ├── Composer.php ├── DateTime.php ├── DelayBeanCallable.php ├── DelayClassCallable.php ├── DelayServerBeanCallable.php ├── Digital.php ├── DocBlock.php ├── EnumUtil.php ├── ExpiredStorage.php ├── File.php ├── File │ └── FileEnumItem.php ├── FilterableList.php ├── Format │ ├── IFormat.php │ ├── Json.php │ ├── PhpSerialize.php │ └── PhpSession.php ├── Http │ ├── AbstractMessage.php │ ├── Consts │ │ ├── MediaType.php │ │ ├── RequestHeader.php │ │ ├── RequestMethod.php │ │ ├── ResponseHeader.php │ │ └── StatusCode.php │ ├── Contract │ │ ├── IMessage.php │ │ ├── IRequest.php │ │ ├── IResponse.php │ │ └── IServerRequest.php │ ├── MessageUtil.php │ ├── Request.php │ ├── Response.php │ └── ServerRequest.php ├── Imi.php ├── ImiPriority.php ├── Interfaces │ ├── IArrayable.php │ └── IHashCode.php ├── LazyArrayObject.php ├── MemoryTable │ └── IMemoryTableOption.php ├── ObjectArrayHelper.php ├── Pagination.php ├── Process.php ├── Process │ ├── ProcessAppContexts.php │ └── ProcessType.php ├── Random.php ├── Socket │ └── IPEndPoint.php ├── StaticValueStorage.php ├── Stream │ ├── FileStream.php │ ├── MemoryStream.php │ └── StreamMode.php ├── System.php ├── Text.php ├── Traits │ ├── TAnonymous.php │ ├── TBeanRealClass.php │ ├── TDataToProperty.php │ ├── THashCode.php │ ├── TNotRequiredDataToProperty.php │ ├── TServerAnnotationParser.php │ ├── TSingleton.php │ └── TStaticClass.php └── Uri.php ├── Validate ├── Annotation │ ├── AutoValidation.php │ ├── Compare.php │ ├── Condition.php │ ├── Decimal.php │ ├── InEnum.php │ ├── InList.php │ ├── Integer.php │ ├── Number.php │ ├── Regex.php │ ├── Required.php │ ├── Scene.php │ ├── Text.php │ └── ValidateValue.php ├── Aop │ └── AutoValidationAop.php ├── IValidator.php ├── Validator.php └── ValidatorHelper.php ├── Worker.php └── functions.php /config/config.php: -------------------------------------------------------------------------------- 1 | [ 7 | 'Imi\Components\*', 8 | ], 9 | ]; 10 | -------------------------------------------------------------------------------- /src/Aop/AfterReturningJoinPoint.php: -------------------------------------------------------------------------------- 1 | returnValue = $value; 20 | } 21 | 22 | /** 23 | * 获取返回值 24 | */ 25 | public function getReturnValue(): mixed 26 | { 27 | return $this->returnValue; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Aop/AfterThrowingJoinPoint.php: -------------------------------------------------------------------------------- 1 | throwable; 29 | } 30 | 31 | /** 32 | * 取消抛出异常. 33 | * 34 | * @param bool $isCancelThrow 是否取消,默认为true 35 | */ 36 | public function cancelThrow(bool $isCancelThrow = true): void 37 | { 38 | $this->isCancelThrow = $isCancelThrow; 39 | } 40 | 41 | /** 42 | * 是否取消抛出异常. 43 | */ 44 | public function isCancelThrow(): bool 45 | { 46 | return $this->isCancelThrow; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Aop/Annotation/After.php: -------------------------------------------------------------------------------- 1 | callable)(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Aop/Annotation/ConstValue.php: -------------------------------------------------------------------------------- 1 | name) ? \constant($this->name) : $this->default; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Aop/Annotation/FilterArg.php: -------------------------------------------------------------------------------- 1 | name, ...$this->args); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Aop/Annotation/InjectArg.php: -------------------------------------------------------------------------------- 1 | name, ...$this->args); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Aop/Aop/FilterArgAop.php: -------------------------------------------------------------------------------- 1 | getTarget()); 27 | $method = $joinPoint->getMethod(); 28 | /** @var FilterArg[] $filterArgs */ 29 | $filterArgs = AnnotationManager::getMethodAnnotations($class, $method, FilterArg::class); 30 | $args = ClassObject::convertArgsToKV($class, $method, $joinPoint->getArgs()); 31 | 32 | foreach ($filterArgs as $filterArg) 33 | { 34 | $name = $filterArg->name; 35 | $args[$name] = ($filterArg->filter)($args[$name]); 36 | } 37 | 38 | $args = array_values($args); 39 | 40 | $joinPoint->setArgs($args); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Aop/AroundJoinPoint.php: -------------------------------------------------------------------------------- 1 | nextProceed = $nextProceed; 20 | } 21 | 22 | /** 23 | * 调用下一个方法. 24 | */ 25 | public function &proceed(?array $args = null, bool $returnsReference = false): mixed 26 | { 27 | if (null === $args) 28 | { 29 | $args = $this->getArgs(); 30 | } 31 | if ($returnsReference) 32 | { 33 | $result = &($this->nextProceed)($args, $returnsReference); 34 | } 35 | else 36 | { 37 | $result = ($this->nextProceed)($args, $returnsReference); 38 | } 39 | 40 | $this->args = $args; 41 | 42 | return $result; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Aop/Listener/BuildRuntimeListener.php: -------------------------------------------------------------------------------- 1 | data['aop'] = [ 23 | 'cache' => AopManager::getArrayCache(), 24 | 'dynamicRulesCache' => AopManager::getDynamicRulesCache(), 25 | ]; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Aop/Listener/LoadRuntimeListener.php: -------------------------------------------------------------------------------- 1 | data['aop'] ?? []; 23 | if ((bool) ($cache = ($data['cache'] ?? null)) | (bool) ($dynamicRulesCache = ($data['dynamicRulesCache'] ?? null))) 24 | { 25 | AopManager::clear(); 26 | if ($cache) 27 | { 28 | AopManager::setArrayCache($cache); 29 | } 30 | if ($dynamicRulesCache) 31 | { 32 | AopManager::setDynamicRulesCache($dynamicRulesCache); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Aop/Model/AopItem.php: -------------------------------------------------------------------------------- 1 | callback = $callback; 17 | } 18 | 19 | public function getClass(): string 20 | { 21 | return $this->class; 22 | } 23 | 24 | public function getMethodRule(): string 25 | { 26 | return $this->methodRule; 27 | } 28 | 29 | public function getCallback(): callable 30 | { 31 | return $this->callback; 32 | } 33 | 34 | public function getPriority(): int 35 | { 36 | return $this->priority; 37 | } 38 | 39 | public function getOptions(): array 40 | { 41 | return $this->options; 42 | } 43 | 44 | public function getClassMethodRule(): string 45 | { 46 | return $this->class . '::' . $this->methodRule; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Aop/PointCutType.php: -------------------------------------------------------------------------------- 1 | isGeted && $this->isException) 21 | { 22 | Log::error($this->result); 23 | } 24 | } 25 | 26 | /** 27 | * {@inheritDoc} 28 | */ 29 | public function get(?float $timeout = null): mixed 30 | { 31 | $this->isGeted = true; 32 | $result = $this->result; 33 | if ($this->isException) 34 | { 35 | throw $result; 36 | } 37 | if ($result instanceof IAsyncResult) 38 | { 39 | return $result->get($timeout); 40 | } 41 | 42 | return $result; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Async/Contract/IAsyncHandler.php: -------------------------------------------------------------------------------- 1 | __alias; 27 | } 28 | 29 | /** 30 | * {@inheritDoc} 31 | */ 32 | public function jsonSerialize(): mixed 33 | { 34 | return $this; 35 | } 36 | 37 | /** 38 | * 将当前对象作为数组返回. 39 | */ 40 | public function toArray(): array 41 | { 42 | return ClassObject::getPublicProperties($this); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Bean/Annotation/Bean.php: -------------------------------------------------------------------------------- 1 | class, $this->method]; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Bean/Annotation/ClassEventListener.php: -------------------------------------------------------------------------------- 1 | class; 29 | } 30 | 31 | /** 32 | * {@inheritDoc} 33 | */ 34 | public function getAnnotation(): Base 35 | { 36 | return $this->annotation; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Bean/Annotation/Model/ConstantAnnotationRelation.php: -------------------------------------------------------------------------------- 1 | class; 33 | } 34 | 35 | /** 36 | * {@inheritDoc} 37 | */ 38 | public function getAnnotation(): Base 39 | { 40 | return $this->annotation; 41 | } 42 | 43 | /** 44 | * Get 常量名. 45 | */ 46 | public function getConstant(): string 47 | { 48 | return $this->constant; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Bean/Annotation/Model/IAnnotationRelation.php: -------------------------------------------------------------------------------- 1 | class; 33 | } 34 | 35 | /** 36 | * {@inheritDoc} 37 | */ 38 | public function getAnnotation(): Base 39 | { 40 | return $this->annotation; 41 | } 42 | 43 | /** 44 | * Get 方法名. 45 | */ 46 | public function getMethod(): string 47 | { 48 | return $this->method; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Bean/Annotation/Model/PropertyAnnotationRelation.php: -------------------------------------------------------------------------------- 1 | class; 33 | } 34 | 35 | /** 36 | * {@inheritDoc} 37 | */ 38 | public function getAnnotation(): Base 39 | { 40 | return $this->annotation; 41 | } 42 | 43 | /** 44 | * Get 属性名. 45 | */ 46 | public function getProperty(): string 47 | { 48 | return $this->property; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Bean/Annotation/Parser.php: -------------------------------------------------------------------------------- 1 | className, $annotation->eventName, $className, $annotation->priority); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Bean/Parser/IParser.php: -------------------------------------------------------------------------------- 1 | eventName; 22 | $priority = $annotation->priority; 23 | $one = $annotation->one; 24 | EventManager::add($eventName, $className, $priority, $one); 25 | if ($one) 26 | { 27 | Event::one($eventName, static fn (IEvent $e) => App::newInstance($className)->handle($e), $priority); 28 | } 29 | else 30 | { 31 | Event::on($eventName, static fn (IEvent $e) => App::newInstance($className)->handle($e), $priority); 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Bean/Parser/NullParser.php: -------------------------------------------------------------------------------- 1 | class); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Bean/Traits/TAutoInject.php: -------------------------------------------------------------------------------- 1 | __autoInject(); 18 | } 19 | 20 | /** 21 | * 自动注入属性. 22 | */ 23 | protected function __autoInject(): void 24 | { 25 | BeanProxy::injectProps($this, BeanFactory::getObjectClass($this)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Cache/Annotation/CacheEvict.php: -------------------------------------------------------------------------------- 1 | a->b下的值 28 | */ 29 | public ?string $value = null, 30 | /** 31 | * 缓存超时时间,单位:秒. 32 | */ 33 | public ?int $ttl = null, 34 | /** 35 | * 可以指定 hash 方法,默认为:md5. 36 | */ 37 | public string $hashMethod = 'md5' 38 | ) { 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Cache/Annotation/Cacheable.php: -------------------------------------------------------------------------------- 1 | data['cli'] = $data; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Cli/Listener/LoadRuntimeListener.php: -------------------------------------------------------------------------------- 1 | data['cli'] ?? []; 24 | CliManager::setMap($data['cli'] ?? []); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Cli/bin/imi-cli: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | name, $this->default); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Config/Annotation/EnvValue.php: -------------------------------------------------------------------------------- 1 | name, $this->default); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Contract/IWorker.php: -------------------------------------------------------------------------------- 1 | $namespace) 30 | { 31 | Helper::getMain($namespace, $name); 32 | } 33 | } 34 | 35 | public static function has(string $name): bool 36 | { 37 | return isset(self::$components[$name]); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Core/Component/Listener/BuildRuntimeListener.php: -------------------------------------------------------------------------------- 1 | data['component'] = [ 23 | 'components' => ComponentManager::getComponents(), 24 | ]; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Core/Component/Listener/LoadRuntimeListener.php: -------------------------------------------------------------------------------- 1 | data['component']['components'] ?? []); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Core/Context/ContextData.php: -------------------------------------------------------------------------------- 1 | deferCallbacks = new \SplStack(); 15 | } 16 | 17 | /** 18 | * 推迟执行,当协程释放时触发,先进后出. 19 | */ 20 | public function defer(callable $callback): void 21 | { 22 | $this->deferCallbacks[] = $callback; 23 | } 24 | 25 | /** 26 | * 获取推迟执行任务栈. 27 | */ 28 | public function getDeferCallbacks(): \SplStack 29 | { 30 | return $this->deferCallbacks; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Core/Context/Contract/IContextManager.php: -------------------------------------------------------------------------------- 1 | __eventName = CoreEvents::BUILD_RUNTIME; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Core/Runtime/Event/LoadRuntimeInfoEvent.php: -------------------------------------------------------------------------------- 1 | __eventName = CoreEvents::LOAD_RUNTIME_INFO; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Core/Runtime/Handler/DefaultRuntimeModeHandler.php: -------------------------------------------------------------------------------- 1 | App::newInstance(\Imi\Cli\Listener\LoadRuntimeListener::class)->handle($e), 19940200); 24 | Event::on(CoreEvents::BUILD_RUNTIME, static fn (BuildRuntimeInfoEvent $e) => App::newInstance(\Imi\Cli\Listener\BuildRuntimeListener::class)->handle($e), 19940200); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Core/Runtime/Runtime.php: -------------------------------------------------------------------------------- 1 | response = $response; 26 | 27 | return $this; 28 | } 29 | 30 | /** 31 | * 获取返回信息. 32 | */ 33 | public function getResponse(): mixed 34 | { 35 | return $this->response; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Cron/Message/GetRealTasks.php: -------------------------------------------------------------------------------- 1 | __eventName; 28 | } 29 | 30 | public function getTarget(): ?object 31 | { 32 | return $this->__target; 33 | } 34 | 35 | public function stopPropagation(bool $isStop = true): void 36 | { 37 | $this->__stopPropagation = $isStop; 38 | } 39 | 40 | public function isPropagationStopped(): bool 41 | { 42 | return $this->__stopPropagation; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Event/Contract/IEvent.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | public function getListenersForEvent(IEvent $event): iterable; 15 | 16 | /** 17 | * @return iterable 18 | */ 19 | public function getListeners(): iterable; 20 | 21 | public function addListener(string|array $eventNames, callable $listener, int $priority = 0, bool $once = false): void; 22 | 23 | public function removeListener(string|array $eventNames, ?callable $listener = null): void; 24 | 25 | public function clearListeners(): void; 26 | } 27 | -------------------------------------------------------------------------------- /src/Event/EventDispatcher.php: -------------------------------------------------------------------------------- 1 | listenerProvider; 20 | } 21 | 22 | public function dispatch(IEvent $event): IEvent 23 | { 24 | foreach ($this->listenerProvider->getListenersForEvent($event) as $listener) 25 | { 26 | /** @var IEvent $event */ 27 | ($listener->listener)($event); 28 | if ($listener->once) 29 | { 30 | $this->listenerProvider->removeListener($eventName ??= $event->getEventName(), $listener->listener); 31 | } 32 | if ($event->isPropagationStopped()) 33 | { 34 | break; 35 | } 36 | } 37 | 38 | return $event; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Event/IEventListener.php: -------------------------------------------------------------------------------- 1 | data['event'] = $data; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Event/Listener/LoadRuntimeListener.php: -------------------------------------------------------------------------------- 1 | data['event'] ?? []; 25 | EventManager::setMap($data['event'] ?? []); 26 | ClassEventManager::setMap($data['classEvent'] ?? []); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Event/RegisteredListener.php: -------------------------------------------------------------------------------- 1 | listener = $listener; 28 | $this->createTime = microtime(true); 29 | } 30 | 31 | public function __invoke(object $event): void 32 | { 33 | ($this->listener)($event); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Facade/Annotation/Facade.php: -------------------------------------------------------------------------------- 1 | 3 | 4 | declare(strict_types=1); 5 | 6 | namespace ; 7 | 8 | use Imi\Facade\BaseFacade; 9 | 10 | /** 11 | 13 | 14 | * 15 | 16 | 17 | */ 18 | 19 | 20 | class extends BaseFacade 21 | { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/HotUpdate/Event/HotUpdateBeginBuildEvent.php: -------------------------------------------------------------------------------- 1 | init(); 18 | } 19 | 20 | /** 21 | * 初始化. 22 | */ 23 | abstract protected function init(): void; 24 | } 25 | -------------------------------------------------------------------------------- /src/HotUpdate/Monitor/IMonitor.php: -------------------------------------------------------------------------------- 1 | getTarget(); 28 | $method = $joinPoint->getMethod(); 29 | $class = BeanFactory::getObjectClass($target); 30 | /** @var Lockable|null $lockable */ 31 | $lockable = AnnotationManager::getMethodAnnotations($class, $method, Lockable::class, true, true); 32 | 33 | return $this->parseLockable($target, $method, $joinPoint->getArgs(), $lockable, static fn () => $joinPoint->proceed()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Lock/Exception/LockFailException.php: -------------------------------------------------------------------------------- 1 | stopPropagation; 17 | } 18 | 19 | /** 20 | * 取消系统内部的错误域异常处理并停止后续处理器执行. 21 | */ 22 | public function stopPropagation(bool $stop = true): void 23 | { 24 | $this->stopPropagation = $stop; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Log/Handler/ConsoleHandler.php: -------------------------------------------------------------------------------- 1 | output = $output ?? ImiCommand::getOutput(); 26 | parent::__construct($level, $bubble); 27 | } 28 | 29 | /** 30 | * {@inheritdoc} 31 | */ 32 | protected function write(LogRecord $record): void 33 | { 34 | $this->output->write((string) $record->formatted); 35 | } 36 | 37 | public function getOutput(): OutputInterface 38 | { 39 | return $this->output; 40 | } 41 | 42 | public function setOutput(OutputInterface $output): self 43 | { 44 | $this->output = $output; 45 | 46 | return $this; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Log/IErrorEventHandler.php: -------------------------------------------------------------------------------- 1 | useLoggingLoopDetection(false); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Main/AppBaseMain.php: -------------------------------------------------------------------------------- 1 | config) 20 | { 21 | return $this->config = Config::get('@app'); 22 | } 23 | 24 | return $this->config; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Main/IMain.php: -------------------------------------------------------------------------------- 1 | name); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Pool/BasePoolResource.php: -------------------------------------------------------------------------------- 1 | pool; 29 | } 30 | 31 | /** 32 | * {@inheritDoc} 33 | */ 34 | public function isOpened(): bool 35 | { 36 | return true; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Pool/Event/CheckPoolResourceEvent.php: -------------------------------------------------------------------------------- 1 | resourceConfig as &$config) 14 | { 15 | if (\is_array($config)) 16 | { 17 | continue; 18 | } 19 | $list = explode(';', (string) $config); 20 | $config = []; 21 | foreach ($list as $uri) 22 | { 23 | $uriObj = new Uri($uri); 24 | parse_str($uriObj->getQuery(), $config); 25 | $config['host'] ??= $uriObj->getHost(); 26 | $config['port'] ??= $uriObj->getPort(); 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Process/Event/ProcessBeginEvent.php: -------------------------------------------------------------------------------- 1 | name); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Redis/Enum/RedisMode.php: -------------------------------------------------------------------------------- 1 | initUriResourceConfig(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/RequestContextProxy/Annotation/RequestContextProxy.php: -------------------------------------------------------------------------------- 1 | 3 | 4 | namespace ; 5 | 6 | use Imi\RequestContextProxy\BaseRequestContextProxy; 7 | 8 | /** 9 | 11 | * 12 | 13 | 14 | */ 15 | 16 | 17 | class extends BaseRequestContextProxy implements \ 19 | 20 | { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/Server/Annotation/ServerInject.php: -------------------------------------------------------------------------------- 1 | getBean($this->name, ...$this->args); 40 | } 41 | 42 | return App::getBean($this->name, ...$this->args); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Server/ConnectionContext/Event/ConnectionContextEvents.php: -------------------------------------------------------------------------------- 1 | getBean('ClientIdMap')->leaveAll($clientId); 23 | 24 | ConnectionContext::set('__groups', $groups, $clientId); 25 | 26 | // 标记绑定连接释放 27 | if ($flag = ConnectionContext::getFlagByClientId($clientId)) 28 | { 29 | /** @var \Imi\Server\ConnectionContext\StoreHandler $store */ 30 | $store = $server->getBean('ConnectionContextStore'); 31 | ConnectionContext::unbind($flag, $clientId, $store->getTtl()); 32 | } 33 | 34 | ConnectionContext::destroy($clientId); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Server/DataParser/IParser.php: -------------------------------------------------------------------------------- 1 | options, $this->depth); 36 | } 37 | 38 | /** 39 | * {@inheritDoc} 40 | */ 41 | public function decode(string $data): mixed 42 | { 43 | return json_decode($data, true, $this->depth, $this->options); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Server/DataParser/JsonObjectParser.php: -------------------------------------------------------------------------------- 1 | options, $this->depth); 36 | } 37 | 38 | /** 39 | * {@inheritDoc} 40 | */ 41 | public function decode(string $data): mixed 42 | { 43 | return json_decode($data, false, $this->depth, $this->options); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Server/Event/AfterCreateServerEvent.php: -------------------------------------------------------------------------------- 1 | 3 | 4 | declare(strict_types=1); 5 | 6 | namespace ; 7 | 8 | use Imi\Server\Http\Controller\HttpController; 9 | use Imi\Server\View\Annotation\View; 10 | use Imi\Server\Http\Route\Annotation\Action; 11 | use Imi\Server\Http\Route\Annotation\Controller; 12 | 13 | 14 | 15 | class extends HttpController 16 | { 17 | /** 18 | * index 19 | */ 20 | #[Action] 21 | public function index(): array 22 | { 23 | return ['success'=>true]; 24 | } 25 | } -------------------------------------------------------------------------------- /src/Server/Http/Error/ErrorHandler.php: -------------------------------------------------------------------------------- 1 | handler)->handle($throwable); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Server/Http/Error/ExecuteTimeoutHandler.php: -------------------------------------------------------------------------------- 1 | setStatus(StatusCode::INTERNAL_SERVER_ERROR)->setBody(new MemoryStream('

Request execute timeout

'))->send(); 25 | 26 | return null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Server/Http/Error/HttpNotFoundHandler.php: -------------------------------------------------------------------------------- 1 | handler) 31 | { 32 | return $response->setStatus(StatusCode::NOT_FOUND); 33 | } 34 | else 35 | { 36 | return App::getBean($this->handler)->handle($requesthandler, $request, $response); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Server/Http/Error/IErrorHandler.php: -------------------------------------------------------------------------------- 1 | handler = $handler; 20 | $response->setHeader(ResponseHeader::CONTENT_TYPE, MediaType::TEXT_EVENT_STREAM) 21 | ->setHeader(ResponseHeader::CACHE_CONTROL, 'no-cache') 22 | ->setHeader(ResponseHeader::CONNECTION, 'Keep-Alive') 23 | ->setHeader('X-Accel-Buffering', 'no') // 禁用 Nginx 缓冲区 24 | ; 25 | } 26 | 27 | public function getHandler(): IEmitHandler 28 | { 29 | return $this->handler; 30 | } 31 | 32 | public function send(): void 33 | { 34 | $this->task(); 35 | } 36 | 37 | abstract protected function task(): void; 38 | } 39 | -------------------------------------------------------------------------------- /src/Server/Http/Message/Emitter/SseMessageEvent.php: -------------------------------------------------------------------------------- 1 | comment) 17 | { 18 | $buffer = ": {$this->comment}\n"; 19 | } 20 | if (null !== $this->event) 21 | { 22 | $buffer .= "event: {$this->event}\n"; 23 | } 24 | if (null !== $this->id) 25 | { 26 | $buffer .= "id: {$this->id}\n"; 27 | } 28 | if (null !== $this->retry) 29 | { 30 | $buffer .= "retry: {$this->retry}\n"; 31 | } 32 | if (null !== $this->data) 33 | { 34 | $buffer .= 'data: ' . str_replace("\n", "\ndata: ", $this->data) . "\n"; 35 | } 36 | if ('' === $buffer) 37 | { 38 | throw new \InvalidArgumentException('SSE message must not be empty'); 39 | } 40 | 41 | return $buffer . "\n"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Server/Http/Message/Request.php: -------------------------------------------------------------------------------- 1 | controllerAnnotationClass = Controller::class; 21 | } 22 | 23 | /** 24 | * {@inheritDoc} 25 | */ 26 | public function parse(\Imi\Bean\Annotation\Base $annotation, string $className, string $target, string $targetName): void 27 | { 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Server/Http/Route/Annotation/Action.php: -------------------------------------------------------------------------------- 1 | callable = $callable; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Server/Http/Route/RouteResult.php: -------------------------------------------------------------------------------- 1 | callable = $routeItem->callable; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Server/Http/SuperGlobals/Listener/SuperGlobals.php: -------------------------------------------------------------------------------- 1 | enable) 27 | { 28 | $_GET = new Get(); 29 | $_POST = new Post(); 30 | $_REQUEST = new Request(); 31 | $_SESSION = new Session(); 32 | $_COOKIE = new Cookie(); 33 | $_FILES = new Files(); 34 | $_SERVER = new Server($_SERVER); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Server/Http/SuperGlobals/Session.php: -------------------------------------------------------------------------------- 1 | jsonSerialize(); 34 | } 35 | 36 | /** 37 | * {@inheritDoc} 38 | */ 39 | public function jsonSerialize(): mixed 40 | { 41 | return ImiSession::get(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Server/Protocol.php: -------------------------------------------------------------------------------- 1 | cookie = $cookie; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Server/Session/SessionCookie.php: -------------------------------------------------------------------------------- 1 | server = RequestContext::getServer(); 30 | // @phpstan-ignore-next-line 31 | $this->data = $server->getBean('TcpReceiveDataProxy'); 32 | } 33 | 34 | /** 35 | * 编码消息,把数据编码为发送给客户端的格式. 36 | */ 37 | protected function encodeMessage(mixed $data): string 38 | { 39 | return RequestContext::getServerBean(\Imi\Server\DataParser\DataParser::class)->encode($data); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Server/TcpServer/Error/ErrorHandler.php: -------------------------------------------------------------------------------- 1 | handler) 21 | { 22 | return RequestContext::getServerBean($this->handler)->handle($throwable); 23 | } 24 | else 25 | { 26 | return false; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Server/TcpServer/Error/IErrorHandler.php: -------------------------------------------------------------------------------- 1 | handler) 29 | { 30 | return App::getBean($this->handler)->handle($data, $handler); 31 | } 32 | 33 | return null; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Server/TcpServer/IReceiveHandler.php: -------------------------------------------------------------------------------- 1 | controllerAnnotationClass = TcpController::class; 21 | } 22 | 23 | /** 24 | * {@inheritDoc} 25 | */ 26 | public function parse(\Imi\Bean\Annotation\Base $annotation, string $className, string $target, string $targetName): void 27 | { 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Server/TcpServer/Route/Annotation/TcpAction.php: -------------------------------------------------------------------------------- 1 | toArray()); 20 | } 21 | 22 | public function __construct( 23 | /** 24 | * 条件. 25 | */ 26 | public array $condition = [] 27 | ) { 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Server/TcpServer/Route/IRoute.php: -------------------------------------------------------------------------------- 1 | callable = $callable; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Server/TcpServer/Route/RouteResult.php: -------------------------------------------------------------------------------- 1 | callable = $routeItem->callable; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Server/UdpServer/Contract/IUdpServer.php: -------------------------------------------------------------------------------- 1 | server = RequestContext::getServer(); 30 | // @phpstan-ignore-next-line 31 | $this->data = $server->getBean('UdpPacketDataProxy'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Server/UdpServer/Error/ErrorHandler.php: -------------------------------------------------------------------------------- 1 | handler) 21 | { 22 | return RequestContext::getServerBean($this->handler)->handle($throwable); 23 | } 24 | else 25 | { 26 | return false; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Server/UdpServer/Error/IErrorHandler.php: -------------------------------------------------------------------------------- 1 | handler) 29 | { 30 | return App::getBean($this->handler)->handle($data, $handler); 31 | } 32 | 33 | return null; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Server/UdpServer/IPacketHandler.php: -------------------------------------------------------------------------------- 1 | clientAddress = new IPEndPoint($remoteIp, $remotePort); 30 | $this->formatData = RequestContext::getServerBean(DataParser::class)->decode($data); 31 | } 32 | 33 | /** 34 | * {@inheritDoc} 35 | */ 36 | public function getData(): string 37 | { 38 | return $this->data; 39 | } 40 | 41 | /** 42 | * {@inheritDoc} 43 | */ 44 | public function getFormatData(): mixed 45 | { 46 | return $this->formatData; 47 | } 48 | 49 | /** 50 | * {@inheritDoc} 51 | */ 52 | public function getClientAddress(): IPEndPoint 53 | { 54 | return $this->clientAddress; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/Server/UdpServer/Middleware/IMiddleware.php: -------------------------------------------------------------------------------- 1 | controllerAnnotationClass = UdpController::class; 21 | } 22 | 23 | /** 24 | * {@inheritDoc} 25 | */ 26 | public function parse(\Imi\Bean\Annotation\Base $annotation, string $className, string $target, string $targetName): void 27 | { 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Server/UdpServer/Route/Annotation/UdpAction.php: -------------------------------------------------------------------------------- 1 | toArray()); 20 | } 21 | 22 | public function __construct( 23 | /** 24 | * 条件. 25 | */ 26 | public array $condition = [] 27 | ) { 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Server/UdpServer/Route/IRoute.php: -------------------------------------------------------------------------------- 1 | callable = $callable; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Server/UdpServer/Route/RouteResult.php: -------------------------------------------------------------------------------- 1 | callable = $routeItem->callable; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Server/View/Annotation/BaseViewOption.php: -------------------------------------------------------------------------------- 1 | getBody()->write(ob_get_clean()); 34 | 35 | return $response; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Server/View/Handler/IHandler.php: -------------------------------------------------------------------------------- 1 | setHeader(ResponseHeader::CONTENT_TYPE, MediaType::APPLICATION_XML); 26 | if ($data instanceof \DOMDocument) 27 | { 28 | $response->getBody()->write($data->saveXML()); 29 | } 30 | elseif ($data instanceof \SimpleXMLElement) 31 | { 32 | $response->getBody()->write($data->asXML()); 33 | } 34 | else 35 | { 36 | throw new \RuntimeException('Unsupport xml object type: ' . \gettype($data)); 37 | } 38 | 39 | return $response; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Server/WebSocket/Contract/IWebSocketServer.php: -------------------------------------------------------------------------------- 1 | server = RequestContext::getServer(); 30 | // @phpstan-ignore-next-line 31 | $this->frame = $server->getBean('WebSocketFrameProxy'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Server/WebSocket/Enum/NonControlFrameType.php: -------------------------------------------------------------------------------- 1 | handler) 21 | { 22 | return RequestContext::getServerBean($this->handler)->handle($throwable); 23 | } 24 | else 25 | { 26 | return false; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Server/WebSocket/Error/IErrorHandler.php: -------------------------------------------------------------------------------- 1 | handler) 29 | { 30 | return App::getBean($this->handler)->handle($frame, $handler); 31 | } 32 | 33 | return null; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Server/WebSocket/IMessageHandler.php: -------------------------------------------------------------------------------- 1 | controllerAnnotationClass = WSController::class; 21 | } 22 | 23 | /** 24 | * {@inheritDoc} 25 | */ 26 | public function parse(\Imi\Bean\Annotation\Base $annotation, string $className, string $target, string $targetName): void 27 | { 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Server/WebSocket/Route/Annotation/WSAction.php: -------------------------------------------------------------------------------- 1 | toArray()); 20 | } 21 | 22 | public function __construct( 23 | /** 24 | * 条件. 25 | */ 26 | public array $condition = [], 27 | /** 28 | * http 路由;如果设置,则只有握手指定 http 路由,才可以触发该 WebSocket 路由. 29 | */ 30 | public ?string $route = null 31 | ) { 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Server/WebSocket/Route/IRoute.php: -------------------------------------------------------------------------------- 1 | callable = $callable; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Server/WebSocket/Route/RouteResult.php: -------------------------------------------------------------------------------- 1 | callable = $routeItem->callable; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Timer/Contract/ITimer.php: -------------------------------------------------------------------------------- 1 | create($docblock, $context, $location); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Util/EnumUtil.php: -------------------------------------------------------------------------------- 1 | name === $case) 28 | { 29 | return $c; 30 | } 31 | } 32 | 33 | return null; 34 | } 35 | 36 | public static function in(string $enum, mixed $value): bool 37 | { 38 | foreach ($enum::cases() as $case) 39 | { 40 | if ($case === $value || ($case->value ?? $case->name) === $value) 41 | { 42 | return true; 43 | } 44 | } 45 | 46 | return false; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Util/Format/IFormat.php: -------------------------------------------------------------------------------- 1 | $v) 16 | { 17 | $result .= $k . '|' . serialize($v); 18 | } 19 | 20 | return $result; 21 | } 22 | 23 | /** 24 | * {@inheritDoc} 25 | */ 26 | public function decode(string $data): mixed 27 | { 28 | $result = []; 29 | $offset = 0; 30 | $length = \strlen($data); 31 | while ($offset < $length) 32 | { 33 | if (!strstr(substr($data, $offset), '|')) 34 | { 35 | return []; 36 | } 37 | $pos = strpos($data, '|', $offset); 38 | $num = $pos - $offset; 39 | $varname = substr($data, $offset, $num); 40 | $offset += $num + 1; 41 | $dataItem = unserialize(substr($data, $offset)); 42 | $result[$varname] = $dataItem; 43 | $offset += \strlen(serialize($dataItem)); 44 | } 45 | 46 | return $result; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Util/Http/Consts/RequestMethod.php: -------------------------------------------------------------------------------- 1 | $values) 17 | { 18 | $result[$name] = implode(', ', $values); 19 | } 20 | 21 | return $result; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Util/ImiPriority.php: -------------------------------------------------------------------------------- 1 | getArrayCopy(); 23 | } 24 | 25 | /** 26 | * 将当前对象作为数组返回. 27 | */ 28 | public function toArray(): array 29 | { 30 | return $this->getArrayCopy(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Util/MemoryTable/IMemoryTableOption.php: -------------------------------------------------------------------------------- 1 | address . ':' . $this->port; 27 | } 28 | 29 | /** 30 | * 获取地址 31 | */ 32 | public function getAddress(): string 33 | { 34 | return $this->address; 35 | } 36 | 37 | /** 38 | * 获取端口. 39 | */ 40 | public function getPort(): int 41 | { 42 | return $this->port; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Util/StaticValueStorage.php: -------------------------------------------------------------------------------- 1 | $v) 17 | { 18 | $this->{$k} = $v; 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Util/Traits/THashCode.php: -------------------------------------------------------------------------------- 1 | __hashCode; 17 | if (null === $hashCode) 18 | { 19 | $hashCode = spl_object_hash($this); 20 | } 21 | 22 | return $hashCode; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Util/Traits/TNotRequiredDataToProperty.php: -------------------------------------------------------------------------------- 1 | $v) 17 | { 18 | $this->{$k} = $v; 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Util/Traits/TStaticClass.php: -------------------------------------------------------------------------------- 1 | 比较符->被比较值;允许使用:==、!=、===、!==、<、<=、>、>=. 32 | */ 33 | public string $operation = '==' 34 | ) { 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Validate/Annotation/Decimal.php: -------------------------------------------------------------------------------- 1 |