From 3a5c0e2a1cc43da2de72c98086638e6913835756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Thu, 4 Jan 2024 15:01:01 +0100 Subject: [PATCH 1/5] replace void with never return type --- program/include/rcmail_output.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/program/include/rcmail_output.php b/program/include/rcmail_output.php index e6390ecf049..68eb21c7272 100644 --- a/program/include/rcmail_output.php +++ b/program/include/rcmail_output.php @@ -133,7 +133,7 @@ public function header($header, $replace = true) * @param string $body The output body * @param array $headers Headers * - * @return void + * @return never */ public function sendExit($body = '', $headers = []) { @@ -151,7 +151,7 @@ public function sendExit($body = '', $headers = []) * @param int $code The HTTP error code * @param string $message The HTTP error message * - * @return void + * @return never */ public function sendExitError($code, $message = '') { From fca1d4929f7e1ec19681bce6dde9609203b3ce18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Thu, 4 Jan 2024 15:04:42 +0100 Subject: [PATCH 2/5] replace "return void" phpdoc with native type in tests --- tests/Browser/Components/App.php | 4 +--- tests/Browser/Components/Dialog.php | 4 +--- tests/Browser/Components/HtmlEditor.php | 4 +--- tests/Browser/Components/Popupmenu.php | 4 +--- tests/Browser/Components/RecipientInput.php | 4 +--- tests/Browser/Components/Taskmenu.php | 4 +--- tests/Browser/Components/Toolbarmenu.php | 4 +--- tests/Browser/TestCase.php | 4 +--- tests/Browser/install.php | 4 +--- tests/bootstrap.php | 4 +--- 10 files changed, 10 insertions(+), 30 deletions(-) diff --git a/tests/Browser/Components/App.php b/tests/Browser/Components/App.php index d780de8b4e4..48d5290e242 100644 --- a/tests/Browser/Components/App.php +++ b/tests/Browser/Components/App.php @@ -22,10 +22,8 @@ public function selector() * Assert that the browser page contains the component. * * @param Browser $browser - * - * @return void */ - public function assert($browser) + public function assert($browser): void { // Assume the app (window.rcmail) is always available // we can't assert that before we visit the page diff --git a/tests/Browser/Components/Dialog.php b/tests/Browser/Components/Dialog.php index ff6f508b38f..2b2d80fe277 100644 --- a/tests/Browser/Components/Dialog.php +++ b/tests/Browser/Components/Dialog.php @@ -33,10 +33,8 @@ public function selector() * Assert that the browser page contains the component. * * @param Browser $browser - * - * @return void */ - public function assert($browser) + public function assert($browser): void { $browser->waitFor($this->selector()); } diff --git a/tests/Browser/Components/HtmlEditor.php b/tests/Browser/Components/HtmlEditor.php index f44302f609d..28035341b36 100644 --- a/tests/Browser/Components/HtmlEditor.php +++ b/tests/Browser/Components/HtmlEditor.php @@ -34,10 +34,8 @@ public function selector() * Assert that the browser page contains the component. * * @param Browser $browser - * - * @return void */ - public function assert($browser) + public function assert($browser): void { $browser->waitFor($this->selector() . '.html-editor'); } diff --git a/tests/Browser/Components/Popupmenu.php b/tests/Browser/Components/Popupmenu.php index 4c1e87b6766..85865d49bf7 100644 --- a/tests/Browser/Components/Popupmenu.php +++ b/tests/Browser/Components/Popupmenu.php @@ -31,10 +31,8 @@ public function selector() * Assert that the browser page contains the component. * * @param Browser $browser - * - * @return void */ - public function assert($browser) + public function assert($browser): void { $browser->waitFor($this->selector()); } diff --git a/tests/Browser/Components/RecipientInput.php b/tests/Browser/Components/RecipientInput.php index 18b2cead89d..7e13f9ce9b9 100644 --- a/tests/Browser/Components/RecipientInput.php +++ b/tests/Browser/Components/RecipientInput.php @@ -32,10 +32,8 @@ public function selector() * Assert that the browser page contains the component. * * @param Browser $browser - * - * @return void */ - public function assert($browser) + public function assert($browser): void { $browser->waitFor($this->selector() . ' @input'); } diff --git a/tests/Browser/Components/Taskmenu.php b/tests/Browser/Components/Taskmenu.php index b8c7a8234d5..a0289e14ac4 100644 --- a/tests/Browser/Components/Taskmenu.php +++ b/tests/Browser/Components/Taskmenu.php @@ -23,10 +23,8 @@ public function selector() * Assert that the browser page contains the component. * * @param Browser $browser - * - * @return void */ - public function assert($browser) + public function assert($browser): void { if ($browser->isPhone()) { $browser->assertPresent($this->selector()); diff --git a/tests/Browser/Components/Toolbarmenu.php b/tests/Browser/Components/Toolbarmenu.php index d0fea285f56..7ac5e8bd718 100644 --- a/tests/Browser/Components/Toolbarmenu.php +++ b/tests/Browser/Components/Toolbarmenu.php @@ -21,10 +21,8 @@ public function selector() * Assert that the browser page contains the component. * * @param Browser $browser - * - * @return void */ - public function assert($browser) + public function assert($browser): void { if ($browser->isPhone()) { $browser->assertPresent($this->selector()); diff --git a/tests/Browser/TestCase.php b/tests/Browser/TestCase.php index 62ddae6ad18..60ffeacdce2 100644 --- a/tests/Browser/TestCase.php +++ b/tests/Browser/TestCase.php @@ -32,10 +32,8 @@ protected function newBrowser($driver) * Prepare for Dusk test execution. * * @beforeClass - * - * @return void */ - public static function prepare() + public static function prepare(): void { static::startWebServer(); static::startChromeDriver(); diff --git a/tests/Browser/install.php b/tests/Browser/install.php index 3a7fd950f22..8d5714311ed 100644 --- a/tests/Browser/install.php +++ b/tests/Browser/install.php @@ -33,10 +33,8 @@ class Installer extends Laravel\Dusk\Console\ChromeDriverCommand * Execute the console command. * * @param string $version - * - * @return void */ - public function install($version = '') + public function install($version = ''): void { $os = Laravel\Dusk\OperatingSystem::id(); $version = trim($version); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 87a374f1a44..09438565636 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -106,10 +106,8 @@ function getProperty($object, $name, $class = null) * @param string $name Property name * @param mixed $value Property value * @param string $class Object class - * - * @return void */ -function setProperty($object, $name, $value, $class = null) +function setProperty($object, $name, $value, $class = null): void { $reflection = new ReflectionClass($class ?: get_class($object)); From f1801769e24cd18f18f6d6737c306a1a6790144d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Thu, 4 Jan 2024 15:06:59 +0100 Subject: [PATCH 3/5] replace "return void" phpdoc with native type in rcube_addressbook --- .../example_addressbook/example_addressbook_backend.php | 4 ++-- program/lib/Roundcube/rcube_addressbook.php | 8 ++------ program/lib/Roundcube/rcube_contacts.php | 4 ++-- program/lib/Roundcube/rcube_ldap.php | 4 ++-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/plugins/example_addressbook/example_addressbook_backend.php b/plugins/example_addressbook/example_addressbook_backend.php index f1ff027315c..228fdc1897f 100644 --- a/plugins/example_addressbook/example_addressbook_backend.php +++ b/plugins/example_addressbook/example_addressbook_backend.php @@ -74,7 +74,7 @@ public function get_name() return $this->name; } - public function set_search_set($filter) + public function set_search_set($filter): void { $this->filter = $filter; } @@ -84,7 +84,7 @@ public function get_search_set() return $this->filter; } - public function reset() + public function reset(): void { $this->result = null; $this->filter = null; diff --git a/program/lib/Roundcube/rcube_addressbook.php b/program/lib/Roundcube/rcube_addressbook.php index 4ae2943b780..e80e8075661 100644 --- a/program/lib/Roundcube/rcube_addressbook.php +++ b/program/lib/Roundcube/rcube_addressbook.php @@ -127,10 +127,8 @@ abstract public function get_name(); * operation. * * @param mixed $filter Search params to use in listing method, obtained by get_search_set() - * - * @return void */ - abstract public function set_search_set($filter); + abstract public function set_search_set($filter): void; /** * Getter for saved search properties. @@ -143,10 +141,8 @@ abstract public function get_search_set(); /** * Reset saved results and search parameters - * - * @return void */ - abstract public function reset(); + abstract public function reset(): void; /** * Refresh saved search set after data has changed diff --git a/program/lib/Roundcube/rcube_contacts.php b/program/lib/Roundcube/rcube_contacts.php index 7bbf6a6bc32..09a94a49889 100644 --- a/program/lib/Roundcube/rcube_contacts.php +++ b/program/lib/Roundcube/rcube_contacts.php @@ -90,7 +90,7 @@ public function get_name() * * @param string $filter SQL params to use in listing method */ - public function set_search_set($filter) + public function set_search_set($filter): void { $this->filter = $filter; $this->cache = null; @@ -119,7 +119,7 @@ public function set_group($gid) /** * Reset all saved results and search parameters */ - public function reset() + public function reset(): void { $this->result = null; $this->filter = null; diff --git a/program/lib/Roundcube/rcube_ldap.php b/program/lib/Roundcube/rcube_ldap.php index 99c9c8e45cd..bcf88e1cf23 100644 --- a/program/lib/Roundcube/rcube_ldap.php +++ b/program/lib/Roundcube/rcube_ldap.php @@ -566,7 +566,7 @@ public function set_sort_order($sort_col, $sort_order = null) * * @param string $filter Filter string */ - public function set_search_set($filter) + public function set_search_set($filter): void { $this->filter = $filter; } @@ -584,7 +584,7 @@ public function get_search_set() /** * Reset all saved results and search parameters */ - public function reset() + public function reset(): void { $this->result = null; $this->ldap_result = null; From c7959769f9dec5e50a6f95fdcd95f2e27f3e0809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Thu, 4 Jan 2024 15:17:50 +0100 Subject: [PATCH 4/5] replace "return void" phpdoc with native type in rcmail_oauth --- program/include/rcmail_oauth.php | 42 ++++++++------------------------ 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/program/include/rcmail_oauth.php b/program/include/rcmail_oauth.php index 952c3966743..e570c6165c7 100644 --- a/program/include/rcmail_oauth.php +++ b/program/include/rcmail_oauth.php @@ -109,10 +109,8 @@ public static function get_instance($options = []) /** * Helper to log oauth - * - * @return void */ - private function logger($level, $message) + private function logger($level, $message): void { $token = $this->login_phase['token'] ?? $_SESSION['oauth_token'] ?? []; $sub = $token['identity']['sub'] ?? '-'; @@ -124,10 +122,8 @@ private function logger($level, $message) * Helper to log oauth debug message (only if `oauth_debug`is true) * * XXX for debug only, please use rcube::raise_error to raise errors in a centralized place - * - * @return void */ - public function log_debug(...$args) + public function log_debug(...$args): void { if ($this->options['debug']) { $this->logger('DEBUG', sprintf(...$args)); @@ -215,11 +211,9 @@ public function __construct($options = []) * * use cache if defined * - * @return void - * * @see https://datatracker.ietf.org/doc/html/rfc8414 */ - protected function discover() + protected function discover(): void { $config_uri = $this->options['config_uri']; if (empty($config_uri)) { @@ -279,10 +273,8 @@ protected function discover() /** * Fetch JWKS certificates (use cache if active) - * - * @return void */ - protected function fetch_jwks() + protected function fetch_jwks(): void { if (!$this->options['jwks_uri']) { // not activated @@ -319,10 +311,8 @@ protected function fetch_jwks() /** * Initialize this instance - * - * @return void */ - public function init() + public function init(): void { // important must be called before is_enabled() $this->discover(); @@ -381,8 +371,6 @@ public function get_last_error() * * Append Oauth button on login page if defined (this is a hook) * can also hide default user/pass form if flag oauth_login_redirect is true - * - * @return void */ public function loginform_content(array $form_content) { @@ -506,10 +494,8 @@ public function get_redirect_uri() * Authorization Code Request * * @see https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.1 - * - * @return void */ - public function login_redirect() + public function login_redirect(): void { if (empty($this->options['auth_uri']) || empty($this->options['client_id'])) { // log error about missing config options @@ -809,10 +795,8 @@ public function refresh_access_token(array $token) * Warning: cache TTL should be at least > refresh_token frequency * * @param string $sub the sub of the identity - * - * @return void */ - public function schedule_token_revocation($sub) + public function schedule_token_revocation($sub): void { if ($this->cache === null) { rcube::raise_error(['message' => 'received a token revocation request, you must activate `oauth_cache` to enable this feature'], true, false); @@ -943,10 +927,8 @@ protected function parse_tokens($grant_type, &$data, $previous_data = null) * Modify some properties of the received auth response * * @param array $data - * - * @return void */ - protected function mask_auth_data(&$data) + protected function mask_auth_data(&$data): void { // remove by security access_token as it is crypted in $_SESSION['password'] unset($data['access_token']); @@ -1010,10 +992,8 @@ protected function check_token_validity($token) * Callback for 'refresh' hook * * @param array $options - * - * @return void */ - public function refresh($options) + public function refresh($options): void { if (!isset($_SESSION['oauth_token'])) { return; @@ -1271,11 +1251,9 @@ public function startup(array $args) * will generate during the logout task the RP-initiated Logout URL and * store it in `logout_redirect_url` * - * @return void - * * @see https://openid.net/specs/openid-connect-rpinitiated-1_0.html */ - public function handle_logout() + public function handle_logout(): void { // if no logout URI, or no refresh token, safe to give up if (!$this->options['logout_uri'] || !isset($_SESSION['oauth_token'])) { From 29d73a7231eb67800aa7c586419c47896f46b2ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Thu, 4 Jan 2024 15:18:19 +0100 Subject: [PATCH 5/5] fix remaining --- .php-cs-fixer.dist.php | 1 - plugins/password/drivers/plesk.php | 4 +--- program/include/rcmail_output.php | 6 ------ program/include/rcmail_output_html.php | 4 +--- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 9af5160864f..81aaaab23e2 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -81,7 +81,6 @@ 'style' => 'post', ], 'no_useless_else' => false, - 'phpdoc_no_empty_return' => false, 'psr_autoloading' => false, 'strict_comparison' => false, 'string_length_to_empty' => false, diff --git a/plugins/password/drivers/plesk.php b/plugins/password/drivers/plesk.php index 8a382614e94..4ea332aad39 100644 --- a/plugins/password/drivers/plesk.php +++ b/plugins/password/drivers/plesk.php @@ -103,10 +103,8 @@ class plesk_rpc * @param string $path plesk rpc path * @param string $user plesk user * @param string $user plesk password - * - * @return void */ - public function init($host, $port, $path, $user, $pass) + public function init($host, $port, $path, $user, $pass): void { $headers = [ sprintf('HTTP_AUTH_LOGIN: %s', $user), diff --git a/program/include/rcmail_output.php b/program/include/rcmail_output.php index 68eb21c7272..4fca37e7ac8 100644 --- a/program/include/rcmail_output.php +++ b/program/include/rcmail_output.php @@ -94,8 +94,6 @@ abstract public function add_label(...$args); * * @param string $name Object name * @param callable $func Function name to call - * - * @return void */ public function add_handler($name, $func) { @@ -106,8 +104,6 @@ public function add_handler($name, $func) * Register a list of template object handlers * * @param array $handlers Hash array with object=>handler pairs - * - * @return void */ public function add_handlers($handlers) { @@ -119,8 +115,6 @@ public function add_handlers($handlers) * * @param string $header The header string * @param bool $replace Replace previously set header? - * - * @return void */ public function header($header, $replace = true) { diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php index bb8482ab303..b111db19b2e 100644 --- a/program/include/rcmail_output_html.php +++ b/program/include/rcmail_output_html.php @@ -2407,10 +2407,8 @@ protected function login_form($attrib) * Loads javascript code for images preloading * * @param array $attrib Named parameters - * - * @return void */ - protected function preloader($attrib) + protected function preloader($attrib): void { $images = preg_split('/[\s\t\n,]+/', $attrib['images'], -1, \PREG_SPLIT_NO_EMPTY); $images = array_map([$this, 'abs_url'], $images);