public final function __construct(Argv $argv = null) { // 绑定当前的默认的上下文环境实例 if (!isset(self::$context)) { self::$context = $this; } $this->app = App::getApp(); if (!$this->app->isInit()) { $this->app->init(); } $this->app->getLoader()->loadHelper('string'); $this->writer = new Writer(); $this->cwd = real_path(getcwd()); // 将错误和异常处理,从App中接管过来。 register_shutdown_function(function () { $this->onExiting(); }); set_error_handler([$this, 'errorHandle']); set_exception_handler([$this, 'exceptionHandle']); if (isset($argv)) { $this->setArgv($argv); } }
public function loadHelper(...$helpers) { $this->app->getLoader()->loadHelper(...$helpers); return $this; }