diff --git a/Api/Admin.php b/Api/Admin.php index 6976d73..24bf5e6 100644 --- a/Api/Admin.php +++ b/Api/Admin.php @@ -29,7 +29,7 @@ class Admin extends \Api_Abstract * * @return string[] */ - public function get_something($data) + public function get_something($data): array { $result = [ 'apple', diff --git a/Api/Client.php b/Api/Client.php index 9c244a7..ee6262f 100644 --- a/Api/Client.php +++ b/Api/Client.php @@ -31,7 +31,7 @@ class Client extends \Api_Abstract * * Be careful not to expose sensitive data from the Admin API. */ - public function get_info($data) + public function get_info($data): array { // call custom event hook. All active modules will be notified $this->di['events_manager']->fire(['event' => 'onAfterClientCalledExampleModule', 'params' => ['key' => 'value']]); diff --git a/Api/Guest.php b/Api/Guest.php index c58cb94..fc74d18 100644 --- a/Api/Guest.php +++ b/Api/Guest.php @@ -33,15 +33,13 @@ class Guest extends \Api_Abstract * * @return string */ - public function readme($data) + public function readme(): string { // We'll be using the file_get_contents to fetch the full content of the README file // Our example admin and client area pages will use this function to fetch the README data // Then, we'll tell Twig to parse and display the markdown output - $readme = file_get_contents(PATH_MODS . '/Example/README.md'); - - return $readme; + return file_get_contents(PATH_MODS . '/Example/README.md'); } /** @@ -49,7 +47,7 @@ public function readme($data) * * @return int */ - public function random_number() + public function random_number(): int { return random_int(1, 100); } diff --git a/Controller/Admin.php b/Controller/Admin.php index 5a2a242..fe76d9d 100644 --- a/Controller/Admin.php +++ b/Controller/Admin.php @@ -48,7 +48,7 @@ public function getDi() * * @return array */ - public function fetchNavigation() + public function fetchNavigation(): array { return [ 'group' => [ @@ -77,7 +77,7 @@ public function fetchNavigation() * @example $app->get('/example/test', 'get_test', null, get_class($this)); // calls get_test method on this class * @example $app->get('/example/:id', 'get_index', array('id'=>'[0-9]+'), get_class($this)); */ - public function register(\Box_App &$app) + public function register(\Box_App &$app): void { $app->get('/example', 'get_index', [], static::class); $app->get('/example/test', 'get_test', [], static::class); diff --git a/Controller/Client.php b/Controller/Client.php index d0260e3..843a66f 100644 --- a/Controller/Client.php +++ b/Controller/Client.php @@ -48,7 +48,7 @@ public function getDi() * * @param \Box_App $app - returned by reference */ - public function register(\Box_App &$app) + public function register(\Box_App &$app): void { $app->get('/example', 'get_index', [], static::class); $app->get('/example/protected', 'get_protected', [], static::class); diff --git a/README.md b/README.md index a97efcd..cbbf977 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ - # Example module README file This module provides a starting point for the developers on creating their FOSSBilling module. diff --git a/Service.php b/Service.php index 7cf9056..6f11dbd 100644 --- a/Service.php +++ b/Service.php @@ -43,7 +43,7 @@ public function setDi(mixed $di) * * @throws \Box_Exception */ - public function install() + public function install(): bool { // Execute SQL script if needed $db = $this->di['db']; @@ -56,7 +56,7 @@ public function install() /** * Method to uninstall module. In most cases you will use this * to remove database tables for your module. - * + * * You also can opt to keep the data in the database if you want * to keep the data for future use. * @@ -64,7 +64,7 @@ public function install() * * @throws \Box_Exception */ - public function uninstall() + public function uninstall(): bool { // throw new \Box_Exception("Throw exception to terminate module uninstallation process with a message", array(), 124); return true; @@ -81,7 +81,7 @@ public function uninstall() * * @throws \Box_Exception */ - public function update($manifest) + public function update(array $manifest): bool { // throw new \Box_Exception("Throw exception to terminate module update process with a message", array(), 125); return true; @@ -95,12 +95,12 @@ public function update($manifest) * * @return array() = list of 2 parameters: array($sql, $params) */ - public function getSearchQuery($data) + public function getSearchQuery(array $data): array { $params = []; $sql = "SELECT meta_key, meta_value FROM extension_meta - WHERE extension = 'example' "; + WHERE extension = 'example'"; $client_id = $data['client_id'] ?? null; @@ -117,13 +117,13 @@ public function getSearchQuery($data) /** * Methods is a delegate for one database row. * - * @param array $row - array representing one database row + * @param array $row - array representing one database row * @param string $role - guest|client|admin who is calling this method - * @param bool $deep - true|false deep or light version of result to return to API + * @param bool $deep - true|false deep or light version of result to return to API * * @return array */ - public function toApiArray($row, $role = 'guest', $deep = true) + public function toApiArray(array $row, string $role = 'guest', bool $deep = true): array { return $row; } @@ -144,7 +144,7 @@ public function toApiArray($row, $role = 'guest', $deep = true) * * @throws \Box_Exception */ - public static function onEventClientLoginFailed(\Box_Event $event) + public static function onEventClientLoginFailed(\Box_Event $event): void { // getting Dependency Injector $di = $event->getDi(); @@ -199,7 +199,7 @@ public static function onEventClientLoginFailed(\Box_Event $event) /** * This event hook is registered in example module client API call. */ - public static function onAfterClientCalledExampleModule(\Box_Event $event) + public static function onAfterClientCalledExampleModule(\Box_Event $event): void { // error_log('Called event from example module');