diff --git a/app/Controllers/ControllerAbstract.php b/app/Controllers/ControllerAbstract.php index ff7689a4..039b9b7f 100644 --- a/app/Controllers/ControllerAbstract.php +++ b/app/Controllers/ControllerAbstract.php @@ -13,7 +13,7 @@ abstract class ControllerAbstract * * @var ContainerInterface */ - protected $container; + protected ContainerInterface $container; protected Twig $view; @@ -33,70 +33,6 @@ public function __construct(ContainerInterface $container) unset($container); } - - /** - * Get Slim Container - * - * @return ContainerInterface - */ - protected function getContainer() - { - return $this->container; - } - - /** - * Get Service From Container - * - * @param string $service - * @return mixed - */ - protected function getService($service) - { - return $this->container->get($service); - } - - /** - * Get Request - * - * @return Request - */ - protected function getRequest() - { - return $this->container->request; - } - - /** - * Get Response - * - * @return Response - */ - protected function getResponse() - { - return $this->container->get('response'); - } - - /** - * Get Twig Engine - * - * @return Twig - */ - /*protected function getView() - { - return $this->container->get(Twig::class); - }*/ - - /** - * Render view - * - * @param string $template - * @param array $data - * @return string - */ - /*protected function render($template, $data = []) - { - return $this->getView()->render($this->getResponse(), $template, $data); - }*/ - /** * Get a JSON response * diff --git a/app/Controllers/Reference.php b/app/Controllers/Reference.php index 1179e748..34d9f682 100644 --- a/app/Controllers/Reference.php +++ b/app/Controllers/Reference.php @@ -9,7 +9,7 @@ class Reference extends ControllerAbstract { - public function view(Request $request, Response $response) + public function view(Request $request, Response $response): Response { $get = $request->getQueryParams(); // default session param for this controller @@ -124,7 +124,7 @@ function ($key) use ($join_table) { return $response; } - public function register(Request $request, Response $response) + public function register(Request $request, Response $response): Response { $post = $request->getParsedBody(); @@ -203,7 +203,7 @@ public function register(Request $request, Response $response) ); } - public function filter(Request $request, Response $response) + public function filter(Request $request, Response $response): Response { $post = $request->getParsedBody(); if (isset($post['reset_filters'])) { @@ -223,7 +223,7 @@ public function filter(Request $request, Response $response) ); } - public function order(Request $request, Response $response, string $field) + public function order(Request $request, Response $response, string $field): Response { if ($_SESSION['reference']['orderby'] == $field) { // toggle sort if orderby requested on the same column @@ -240,5 +240,4 @@ public function order(Request $request, Response $response, string $field) $this->routeparser->urlFor('reference') ); } - } diff --git a/app/Controllers/Telemetry.php b/app/Controllers/Telemetry.php index 6cbd2065..52ab120a 100644 --- a/app/Controllers/Telemetry.php +++ b/app/Controllers/Telemetry.php @@ -16,7 +16,7 @@ class Telemetry extends ControllerAbstract { - public function view(Request $request, Response $response) + public function view(Request $request, Response $response): Response { $get = $request->getQueryParams(); $years = 99; @@ -231,7 +231,7 @@ public function view(Request $request, Response $response) return $response; } - public function send(Request $request, Response $response) + public function send(Request $request, Response $response): Response { $response = $response->withHeader('Content-Type', 'application/json'); @@ -304,7 +304,7 @@ public function send(Request $request, Response $response) return $this->withJson($response, ['message' => 'OK']); } - public function geojson(Request $request, Response $response) + public function geojson(Request $request, Response $response): Response { $countries = null; @@ -353,7 +353,7 @@ public function geojson(Request $request, Response $response) return $this->withJson($response, (array)json_decode($countries)); } - public function schema(Request $request, Response $response) + public function schema(Request $request, Response $response): Response { //$cache = $this->container->settings->get('debug') == true ? null : $this->container->cache; $cache = $this->container->get('cache'); @@ -361,7 +361,7 @@ public function schema(Request $request, Response $response) return $this->withJson($response, $schema); } - public function allPlugins(Request $request, Response $response) + public function allPlugins(Request $request, Response $response): Response { $years = 99; $get = $request->getQueryParams(); diff --git a/app/Project.php b/app/Project.php index 17b3a111..ee956705 100644 --- a/app/Project.php +++ b/app/Project.php @@ -48,7 +48,7 @@ public function __construct($logger = null) * * @return Project */ - public function setConfig($config) + public function setConfig(array $config): self { $this->checkConfig($config); @@ -152,13 +152,13 @@ private function setSchemaConfig($config) } /** - * Generate or retrieve project's schema + * Generate or retrieve project's schema as JSON * * @param Laminas\Cache\Storage\Adapter\AbstractAdapter|null $cache Cache instance * - * @return json + * @return string */ - public function getSchema($cache) + public function getSchema($cache): string { if (null != $cache && $cache->hasItem('schema')) { $schema = $cache->getItem($this->getSlug() . '_schema.json'); @@ -241,7 +241,7 @@ public function getSchema($cache) * * @return array */ - public function mapModel($json) + public function mapModel(array $json): array { $slug = $this->getSlug(); @@ -306,7 +306,7 @@ public function mapModel($json) * * @return string */ - public function truncate($string, $length) + public function truncate(string $string, int $length): string { if (mb_strlen($string) > $length) { if ($this->logger !== null) { @@ -325,7 +325,7 @@ public function truncate($string, $length) * * @return string */ - public function getSlug() + public function getSlug(): string { return $this->slug; } @@ -335,7 +335,7 @@ public function getSlug() * * @return string */ - public function getURL() + public function getURL(): string { return $this->url; } @@ -345,7 +345,7 @@ public function getURL() * * @return array */ - public function getFooterLinks() + public function getFooterLinks(): array { return $this->footer_links; } @@ -355,7 +355,7 @@ public function getFooterLinks() * * @return array */ - public function getSocialLinks() + public function getSocialLinks(): array { return $this->social_links; } @@ -363,9 +363,9 @@ public function getSocialLinks() /** * Get dynamic references * - * @return array|false + * @return array */ - public function getDynamicReferences() + public function getDynamicReferences(): array { return $this->dyn_references; } diff --git a/app/init.php b/app/init.php index 6bcc267f..f7bc8036 100644 --- a/app/init.php +++ b/app/init.php @@ -67,10 +67,6 @@ $app->addRoutingMiddleware(); -// init slim -/*$app = new \Slim\App(["settings" => $config]); -$container = $app->getContainer();*/ - $container->set('mail_from', $config['mail_from']); $container->set('mail_admin', $config['mail_admin']); $container->set('is_debug', $config['debug']);