From 26bc324abf81f0717fd6ebe99dd406c607cbe3ef Mon Sep 17 00:00:00 2001 From: Sergey Surkov Date: Sat, 28 Aug 2021 14:15:43 +0300 Subject: [PATCH] fix --- src/Apps/Application.php | 12 ++++++------ src/Apps/ApplicationInterface.php | 6 +++--- src/Apps/Bootstrap.php | 5 ++++- src/Container/ItemsContainerTrait.php | 10 +++++----- src/Core/View/View.php | 3 +-- src/Http/Kernel/HttpRunner.php | 2 +- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/Apps/Application.php b/src/Apps/Application.php index 56f1ec3..e8063e9 100644 --- a/src/Apps/Application.php +++ b/src/Apps/Application.php @@ -54,7 +54,7 @@ public function getAppTitle(): string return $this['config']->getAppName(); } - public function getRoutingProvider(): string + public function getRoutingProvider(): ?string { return $this['config']->getRoutingProvider(); } @@ -64,7 +64,7 @@ public function hasParentApp(): bool return $this['config']->hasParentApp(); } - public function getParentAppId(): string + public function getParentAppId(): ?string { return $this['config']->getParentAppId(); } @@ -117,7 +117,7 @@ protected function registerProviders() * @param string|null $path * @return string|null */ - public function getBasePath(string $path = null) + public function getBasePath(string $path = null): ?string { $base = $this('config::base_path'); return $base ? ($path ? $base . \_DS\DS . ltrim($path) : $base) : null; @@ -127,7 +127,7 @@ public function getBasePath(string $path = null) * @return string|null * @deprecated */ - public function getAssetsPath() + public function getAssetsPath(): ?string { return $this->getBasePath('assets'); } @@ -136,7 +136,7 @@ public function getAssetsPath() * @return string|null * @deprecated */ - public function getResourcesPath() + public function getResourcesPath(): ?string { return $this->getBasePath('resources'); } @@ -144,7 +144,7 @@ public function getResourcesPath() /** * @return ApplicationInterface|null */ - protected function getParentApp() + protected function getParentApp(): ?ApplicationInterface { return $this->hasParentApp() ? $this[AppsRepositoryInterface::class]->get($this->getParentAppId()) : null; } diff --git a/src/Apps/ApplicationInterface.php b/src/Apps/ApplicationInterface.php index 48f0042..3f762cc 100644 --- a/src/Apps/ApplicationInterface.php +++ b/src/Apps/ApplicationInterface.php @@ -16,19 +16,19 @@ interface ApplicationInterface extends AppConfigInterface, DIContainerInterface, ServiceContainerInterface { - public function getBasePath(string $path = null); + public function getBasePath(string $path = null): ?string; /** * @return string|null * @deprecated */ - public function getAssetsPath(); + public function getAssetsPath(): ?string; /** * @return string|null * @deprecated */ - public function getResourcesPath(); + public function getResourcesPath(): ?string; /** * @param array|\Closure[]|null $bootstraps diff --git a/src/Apps/Bootstrap.php b/src/Apps/Bootstrap.php index e1a96b2..854f14a 100644 --- a/src/Apps/Bootstrap.php +++ b/src/Apps/Bootstrap.php @@ -34,7 +34,10 @@ public function bootstrap(CoreInterface $app): void $app['listeners']->add(AppsRoutesRepository::class, function (AppsRoutesRepository $event, AppsRepositoryInterface $appsRepository) { foreach ($appsRepository->enabled() as $v) { $provider = $v['routing'] ?? null; - if ($provider && class_exists($provider)) { + if ($provider) { + if(!class_exists($provider)) { + throw new \Exception('Provider ['.$provider.'] class not found!'); + } $event->append(new $provider($v['id'], $v['controllers_namespace'])); } } diff --git a/src/Container/ItemsContainerTrait.php b/src/Container/ItemsContainerTrait.php index ae0b3b6..d3c6463 100644 --- a/src/Container/ItemsContainerTrait.php +++ b/src/Container/ItemsContainerTrait.php @@ -23,7 +23,7 @@ trait ItemsContainerTrait /*implements \Dissonance\Container\BaseContainerInterf * * @return mixed|null */ - public function get(string|int $key) + public function get($key) { $items = &$this->items; return $this->hasBy($key,$items) ? $items[$key] : @@ -38,7 +38,7 @@ public function get(string|int $key) * @info * @return bool */ - public function has(string|int $key): bool + public function has($key): bool { return $this->hasBy($key,$this->items); } @@ -49,7 +49,7 @@ public function has(string|int $key): bool * @return bool * @info */ - private function hasBy(string|int $key, array &$items): bool + private function hasBy($key, &$items): bool { return isset($items[$key]) // isset в 4 раза быстрее array_key_exists || (is_array($items) && array_key_exists($key, $items)) @@ -60,7 +60,7 @@ private function hasBy(string|int $key, array &$items): bool * @param int|string $key * @param $value */ - public function set(string|int $key, $value): void + public function set($key, $value): void { $this->items[$key] = $value; } @@ -70,7 +70,7 @@ public function set(string|int $key, $value): void * @param int|string $key * @return bool */ - public function delete(string|int $key): bool + public function delete($key): bool { unset($this->items[$key]); diff --git a/src/Core/View/View.php b/src/Core/View/View.php index cc0b664..fbf756a 100644 --- a/src/Core/View/View.php +++ b/src/Core/View/View.php @@ -363,7 +363,6 @@ public function layout(string $template, $content_template, $vars = [], $before return $view; } - /** * @param CoreInterface $app * @uses View::$core @@ -457,7 +456,7 @@ public function fetch($content) protected function getTemplate() { - return 'use function ' . __NAMESPACE__ . '\\app,asset,route,css,js,adminRoute,apiRoute;'.PHP_EOL.' ?>' . $this->template; + return 'use function ' . __NAMESPACE__ . '\\{app,asset,route,css,js,adminRoute,apiRoute};'.PHP_EOL.' ?>' . $this->template; } public function __toString() diff --git a/src/Http/Kernel/HttpRunner.php b/src/Http/Kernel/HttpRunner.php index 12f74ff..a0dfdb1 100644 --- a/src/Http/Kernel/HttpRunner.php +++ b/src/Http/Kernel/HttpRunner.php @@ -132,7 +132,7 @@ public function sendResponse(ResponseInterface $response) $sender = new ResponseSender($response); $sender->render(); if (\function_exists('fastcgi_finish_request')) { - fastcgi_finish_request(); + \fastcgi_finish_request(); } elseif (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) { static::closeOutputBuffers(0, true); }