处理注解路由
@return void
543296
private function parseAnnotations(EventParam $e)
    {
        $controllerParser = UdpControllerParser::getInstance();
        foreach(ServerManage::getServers() as $name => $server)
        {
            if(!$server instanceof \Imi\Server\UdpServer\Server)
            {
                continue;
            }
            RequestContext::create();
            RequestContext::set('server', $server);
            $route = $server->getBean('UdpRoute');
            foreach($controllerParser->getByServer($name) as $className => $classItem)
            {
                $classAnnotation = $classItem['annotation'];
                // 类中间件
                $classMiddlewares = [];
                foreach(AnnotationManager::getClassAnnotations($className, UdpMiddleware::class) ?? [] as $middleware)
                {
                    if(is_array($middleware->middlewares))
                    {
                        $classMiddlewares = array_merge($classMiddlewares, $middleware->middlewares);
                    }
                    else
                    {
                        $classMiddlewares[] = $middleware->middlewares;
                    }
                }
                foreach(AnnotationManager::getMethodsAnnotations($className, UdpAction::class) as $methodName => $methodItem)
                {
                    $routes = AnnotationManager::getMethodAnnotations($className, $methodName, UdpRoute::class);
                    if(!isset($routes[0]))
                    {
                        throw new \RuntimeException(sprintf('%s->%s method has no route', $className, $methodName));
                    }
                    // 方法中间件
                    $methodMiddlewares = [];
                    foreach(AnnotationManager::getMethodAnnotations($className, $methodName, UdpMiddleware::class) ?? [] as $middleware)
                    {
                        if(is_array($middleware->middlewares))
                        {
                            $methodMiddlewares = array_merge($methodMiddlewares, $middleware->middlewares);
                        }
                        else
                        {
                            $methodMiddlewares[] = $middleware->middlewares;
                        }
                    }
                    // 最终中间件
                    $middlewares = array_values(array_unique(array_merge($classMiddlewares, $methodMiddlewares)));
                    
                    foreach($routes as $routeItem)
                    {
                        $route->addRuleAnnotation($routeItem, new RouteCallable($className, $methodName), [
                            'middlewares' => $middlewares,
                        ]);
                    }
                }
            }
            RequestContext::destroy();
        }
    }
673124
public function run()
    {
        // 初始化
        reset($this->queue);
        for ($i = 0; $i < $this->max; $i++) {
            if ($this->makeTask() == -1) {
                break;
            }
        }
        // 处理任务队列
        reset($this->tasks);
        while (count($this->tasks) > 0) {
            $task = current($this->tasks);
            $this->processTask($task);
            if ($task['status'] == -1 || $task['status'] == 2) {
                if ($this->saveSuccess) {
                    $this->success[] = $task;
                }
                unset($this->tasks[key($this->tasks)]);
                $this->makeTask();
            } else {
                $this->tasks[key($this->tasks)] = $task;
            }
            if (!next($this->tasks)) {
                reset($this->tasks);
            }
        }
        return $this->getSuccessInfo();
    }
757931
public function handle()
    {
        $name = $this->argument('module');

        if ($name) {
            $this->updateModule($name);

            return;
        }

        /** @var \Nwidart\Modules\Module $module */
        foreach ($this->laravel['modules']->getOrdered() as $module) {
            $this->updateModule($module->getName());
        }
    }
755843
public function handle(): void
    {
        $this->dbMigrate();
        $this->populateReactionTypes();
        $this->populateReacters();
        $this->populateReactants();
        $this->populateReactions();
        $this->dbCleanup();
        $this->filesystemCleanup();
    }
839926
public function process()
	{
		$view = $this->getView();
		$context = $this->_getContext();

		try
		{
			parent::process();
		}
		catch( Client_Html_Exception $e )
		{
			$error = array( $this->_getContext()->getI18n()->dt( 'client/html', $e->getMessage() ) );
			$view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error;
		}
		catch( Controller_Frontend_Exception $e )
		{
			$error = array( $this->_getContext()->getI18n()->dt( 'controller/frontend', $e->getMessage() ) );
			$view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error;
		}
		catch( MShop_Plugin_Provider_Exception $e )
		{
			$errors = array( $this->_getContext()->getI18n()->dt( 'mshop', $e->getMessage() ) );
			$errors = array_merge( $errors, $this->_translatePluginErrorCodes( $e->getErrorCodes() ) );

			$view->summaryErrorCodes = $e->getErrorCodes();
			$view->standardErrorList = $view->get( 'standardErrorList', array() ) + $errors;
		}
		catch( MShop_Exception $e )
		{
			$error = array( $this->_getContext()->getI18n()->dt( 'mshop', $e->getMessage() ) );
			$view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error;
		}
		catch( Exception $e )
		{
			$context->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() );

			$error = array( $context->getI18n()->dt( 'client/html', 'A non-recoverable error occured' ) );
			$view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error;
		}
	}
379750
public function register()
    {
        $this->container['cache.manager'] = function ($container) {
            $config = $container['config']->get('cache');

            $manager = new Manager($config->drivers->toArray());

            // 设置默认缓存驱动
            $manager->setDefault($config->default);

            // 设置日志处理器
            $logger = value($config->logger);
            if ($logger instanceof LoggerInterface) {
                $manager->setLogger($logger);
            }

            return $manager;
        };

        $this->container['cache'] = function ($container) {
            return $container['cache.manager']->getDefaultCache();
        };

        $this->container['cache.simple'] = function ($container) {
            return $container['cache.manager']->getDefaultSimpleCache();
        };
    }
257891
public function reload()
    {
        $rpcServer = $this->getRpcServer();

        // 是否已启动
        if (! $rpcServer->isRunning()) {
            output()->writeln('<error>The server is not running! cannot reload</error>', true, true);
        }

        // 打印信息
        output()->writeln(sprintf('<info>Server %s is reloading ...</info>', input()->getFullScript()));

        // 重载
        $reloadTask = input()->hasOpt('t');
        $rpcServer->reload($reloadTask);
        output()->writeln(sprintf('<success>Server %s is reload success</success>', input()->getFullScript()));
    }
804877
public function handle()
    {
        $this->comment('                                   ');
        $this->comment('    ...........................    ');
        $this->comment('   .yyyyyyyyyyyyyyyyyyyyyyyyyyy.   ');
        $this->comment('   .yyyyyyyyysssyyyyyyyyyyyyyyy.   ');
        $this->comment('   .yyyyyyyy/...oyyyyyyyyyyyyyy.     _                     _                 ');
        $this->comment('   .yyyyyyyy:   oyyyyyyyyyyyyyy.    | |                   | |                ');
        $this->comment('   .yyyyyyyy:   oyyyyyyyyyyyyyy.    | |     __ _ _ __ __ _| |_   _ _ __ ___  ');
        $this->comment("   .yyyyyyyy:   oyyyyyyyyyyyyyy.    | |    / _` | '__/ _` | | | | | '_ ` _ \ ");
        $this->comment('   .yyyyyyyy:   oyyyyyyyyyyyyyy.    | |___| (_| | | | (_| | | |_| | | | | | |');
        $this->comment("   .yyyyyyyy:   oyyyyyyyyyyyyyy.    |______\__,_|_|  \__,_|_|\__,_|_| |_| |_|");
        $this->comment('   .yyyyyyyy:   -:::::::syyyyyy.                                             ');
        $this->comment('   .yyyyyyyy+`          syyyyyy.    Laralum Administration Panel - laralum.com');
        $this->comment('   .yyyyyyyyys++++++++++yyyyyyy.   ');
        $this->comment('   .yyyyyyyyyyyyyyyyyyyyyyyyyyy.   ');
        $this->comment('   .yyyyyyyyyyyyyyyyyyyyyyyyyyy.   ');
        $this->comment('    ...........................    ');
        $this->comment('                                   ');
        $this->line(' ');
    }
821954
private function init()
    {
        // 创建项目缓存目录
        if (!is_dir($this->options['path'])) {
            if (mkdir($this->options['path'], 0755, true)) {
                return true;
            }
        }
        return false;
    }
974237
public function run()
    {
        Model::unguard();

        DB::table('user__users')->delete();
        DB::table('user__roles')->delete();
        DB::table('user__password_resets')->delete();
        DB::table('user__role_user')->delete();
        DB::table('user__permissions')->delete();
        DB::table('user__permission_role')->delete();

        $this->createAdmin();
        $this->createDemo();

        $this->createUsers();
    }
15582
public function handle()
    {
        $contents = $this->getKeyFile();

        $dbName = $this->argument('database');

        $dbAddress = $this->ask('What is your MySQL address?', '127.0.0.1');

        $dbPort = $this->ask('What is your MySQL port?', '3306');

        $dbUserName = $this->ask('What is your MySQL username?', 'root');

        $question = new Question('What is your MySQL password?', '<none>');
        $question->setHidden(true)->setHiddenFallback(true);
        $dbPassword = (new SymfonyQuestionHelper())->ask($this->input, $this->output, $question);
        if ($dbPassword === '<none>') {
            $dbPassword = '';
        }

        // Update DB credentials in .env file.
        $search = [
            '/('.preg_quote('DB_HOST=').')(.*)/',
            '/('.preg_quote('DB_PORT=').')(.*)/',
            '/('.preg_quote('DB_DATABASE=').')(.*)/',
            '/('.preg_quote('DB_USERNAME=').')(.*)/',
            '/('.preg_quote('DB_PASSWORD=').')(.*)/',
        ];
        $replace = [
            '${1}'.$dbAddress,
            '${1}'.$dbPort,
            '${1}'.$dbName,
            '${1}'.$dbUserName,
            '${1}'.$dbPassword,
        ];
        $contents = preg_replace($search, $replace, $contents);

        if (!$contents) {
            throw new Exception('Error while writing credentials to .env file.');
        }

        // Set DB username and password in config
        $this->laravel['config']['database.connections.mysql.host'] = $dbAddress;
        $this->laravel['config']['database.connections.mysql.port'] = $dbPort;
        $this->laravel['config']['database.connections.mysql.username'] = $dbUserName;
        $this->laravel['config']['database.connections.mysql.password'] = $dbPassword;

        // Clear DB name in config
        unset($this->laravel['config']['database.connections.mysql.database']);

        // Force the new login to be used
        DB::purge();

        // Create database if not exists
        DB::unprepared('CREATE DATABASE IF NOT EXISTS `'.$dbName.'`');
        DB::unprepared('USE `'.$dbName.'`');
        DB::connection()->setDatabaseName($dbName);

        // Migrate DB
        if (Schema::hasTable('migrations')) {
            $this->error('A migrations table was found in database ['.$dbName.'], no migration and seed were done.');
        } else {
            $this->call('migrate');
            $this->call('db:seed');
        }

        // Write to .env
        $this->files->put('.env', $contents);
    }
559251
public function ping()
    {
        $ping_data = $this->pingData ? (string)$this->pingData : null;
        $raw = false;
        if ($this->protocolAccelerate && $ping_data && $this->protocol) {
            $ping_data = $this->preEncodeForClient($ping_data);
            $raw = true;
        }
        // 遍历所有客户端连接
        foreach ($this->_clientConnections as $connection) {
            // 上次发送的心跳还没有回复次数大于限定值就断开
            if ($this->pingNotResponseLimit > 0 &&
                $connection->pingNotResponseCount >= $this->pingNotResponseLimit * 2
            ) {
                $connection->destroy();
                continue;
            }
            // $connection->pingNotResponseCount 为 -1 说明最近客户端有发来消息，则不给客户端发送心跳
            $connection->pingNotResponseCount++;
            if ($ping_data) {
                if ($connection->pingNotResponseCount === 0 ||
                    ($this->pingNotResponseLimit > 0 && $connection->pingNotResponseCount % 2 === 1)
                ) {
                    continue;
                }
                $connection->send($ping_data, $raw);
            }
        }
    }
745037
public function run()
    {
        // todo: think of a better way of doing this.
        $script = "jQuery('{$this->selector}').attr('data-spy', 'scroll');";
        if (isset($this->target)) {
            $script .= "jQuery('{$this->selector}').attr('data-target', '{$this->target}');";
        }
        if (isset($this->offset)) {
            $script .= "jQuery('{$this->selector}').attr('data-offset', '{$this->offset}');";
        }
        Yii::app()->clientScript->registerScript($this->getId(), $script, CClientScript::POS_BEGIN);
        $this->registerEvents($this->selector, $this->events);
    }
1020686
private function startCommon(): void
    {
        if (self::$app !== null) {
            return;
        }
        self::$app = $this;
        // 加载框架配置文件
        $config = DataMap::loadFromPhpFile($this->mvcSourcePath . '/../config.inc.php');
        // 应用配置
        if ($this->config === null) {
            $appConfigFile = APP_CONFIG_PATH . '/./config.inc.php';
            if (is_file($appConfigFile)) {
                $appConfig = DataMap::loadFromPhpFile($appConfigFile);
                $config->mergeData($appConfig);
            }
        } else {
            $config->mergeData($this->config);
        }
        $this->config = $config;
        $this->loadContainer();
    }
476826
public function handle() {
        $actions = func_get_args();

        if ($actions === array('*') || empty($actions)) {
            $this->_handled = array('*');
        } else {
            $this->_handled = array_unique(array_intersect($actions, get_class_methods($this->controller)));
        }
    }
987183
public function handle()
    {
        $connection = $this->getConnection();
        $schema = $this->getSchema($connection);
        $table = $this->getTable();

        // Check whether we just need to generate one table
        if ($table) {
            $this->models->on($connection)->create($schema, $table);
            $this->info("Check out your models for $table");
        }

        // Otherwise map the whole database
        else {
            $this->models->on($connection)->map($schema);
            $this->info("Check out your models for $schema");
        }
    }
918006
public function handle()
    {
        /** @var Request $request */
        $request =& $this->flow->contexts['request'];

        // 如果当前请求是初始请求，那么对其进行额外处理
        // 如果当前请求是CLI，那么直接当做为初始化请求
        if (PHP_SAPI == 'cli' || $request->isInitial())
        {
            if (
                ( ! empty($_SERVER['HTTPS']) && filter_var($_SERVER['HTTPS'], FILTER_VALIDATE_BOOLEAN))
                || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && 'https' === $_SERVER['HTTP_X_FORWARDED_PROTO'])
                && in_array($_SERVER['REMOTE_ADDR'], Request::$trustedProxies)
            )
            {
                $request->secure = true;
            }

            if (isset($_SERVER['REQUEST_METHOD']))
            {
                $method = $_SERVER['REQUEST_METHOD'];
            }
            else
            {
                $method = Http::GET;
            }

            if (isset($_SERVER['HTTP_REFERER']))
            {
                $referrer = $_SERVER['HTTP_REFERER'];
            }

            if (isset($_SERVER['HTTP_USER_AGENT']))
            {
                Request::$userAgent = $_SERVER['HTTP_USER_AGENT'];
            }

            if (isset($_SERVER['HTTP_X_REQUESTED_WITH']))
            {
                $requestedWith = $_SERVER['HTTP_X_REQUESTED_WITH'];
            }

            Request::$clientIp = Request::getClientIP();

            if ($method !== Http::GET)
            {
                $body = file_get_contents('php://input');
            }

            $cookies = [];
            if (($cookieKeys = array_keys($_COOKIE)))
            {
                foreach ($cookieKeys as $key)
                {
                    $cookies[$key] = Cookie::get($key);
                }
            }

            if (isset($_SERVER['SERVER_PROTOCOL']))
            {
                $request->protocol = $_SERVER['SERVER_PROTOCOL'];
            }

            $request
                ->query($_GET)
                ->post($_POST);

            if (isset($method))
            {
                $request->method = $method;
            }
            if (isset($referrer))
            {
                $request->referrer = $referrer;
            }
            if (isset($requestedWith))
            {
                $request->requestedWith = $requestedWith;
            }
            if (isset($body))
            {
                $request->body = $body;
            }
            if (isset($cookies))
            {
                $request->cookie($cookies);
            }
        }
    }