diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index ed27b4333..efd3196fa 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -98,7 +98,6 @@ return (new PhpCsFixer\Config()) 'php_unit_test_case_static_method_calls' => false, 'random_api_migration' => false, 'self_accessor' => false, - 'static_lambda' => false, 'strict_param' => false, ]) ->setFinder($finder) diff --git a/plugins/archive/tests/Browser/MailTest.php b/plugins/archive/tests/Browser/MailTest.php index a93f5a740..556a272c3 100644 --- a/plugins/archive/tests/Browser/MailTest.php +++ b/plugins/archive/tests/Browser/MailTest.php @@ -21,7 +21,7 @@ class MailTest extends \Tests\Browser\TestCase public function testMailUI() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('mail'); if (!$browser->isDesktop()) { @@ -29,7 +29,7 @@ class MailTest extends \Tests\Browser\TestCase } // Folders list - $browser->whenAvailable('#mailboxlist', function ($browser) { + $browser->whenAvailable('#mailboxlist', static function ($browser) { $browser->assertVisible('li.mailbox.archive') ->assertMissing('li.mailbox.archive .unreadcount'); }); @@ -41,7 +41,7 @@ class MailTest extends \Tests\Browser\TestCase // Toolbar menu (Archive button inactive) $browser->assertToolbarMenu([], ['archive']); - $browser->whenAvailable('#messagelist tbody', function ($browser) { + $browser->whenAvailable('#messagelist tbody', static function ($browser) { $browser->ctrlClick('tr:last-child'); }); @@ -54,7 +54,7 @@ class MailTest extends \Tests\Browser\TestCase } // Folders list - $browser->whenAvailable('#mailboxlist', function ($browser) { + $browser->whenAvailable('#mailboxlist', static function ($browser) { $browser->assertSeeIn('li.mailbox.archive .unreadcount', '1') ->click('li.mailbox.archive') ->waitUntilNotBusy(); @@ -69,10 +69,10 @@ class MailTest extends \Tests\Browser\TestCase // Test archive class on folder in folder selector $browser->ctrlClick('#messagelist tbody tr') ->clickToolbarMenuItem('more', null, false) - ->with(new Popupmenu('message-menu'), function ($browser) { + ->with(new Popupmenu('message-menu'), static function ($browser) { $browser->clickMenuItem('move'); }) - ->with(new Popupmenu('folder-selector'), function ($browser) { + ->with(new Popupmenu('folder-selector'), static function ($browser) { $browser->assertVisible('li.archive') ->assertSeeIn('li.archive', 'Archive'); }) diff --git a/plugins/archive/tests/Browser/SettingsTest.php b/plugins/archive/tests/Browser/SettingsTest.php index 6e5fa14d4..30f03a6a9 100644 --- a/plugins/archive/tests/Browser/SettingsTest.php +++ b/plugins/archive/tests/Browser/SettingsTest.php @@ -14,11 +14,11 @@ class SettingsTest extends \Tests\Browser\TestCase */ public function testFolders() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('settings', 'folders'); // Folders list - $browser->with('#subscription-table', function ($browser) { + $browser->with('#subscription-table', static function ($browser) { $browser->assertHasClass('li:nth-child(7)', 'archive') ->assertSeeIn('li:nth-child(7)', 'Archive') ->assertPresent('li:nth-child(7) [type=checkbox][disabled]'); @@ -31,7 +31,7 @@ class SettingsTest extends \Tests\Browser\TestCase */ public function testPreferences() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('settings'); if (!$browser->isDesktop()) { @@ -45,13 +45,13 @@ class SettingsTest extends \Tests\Browser\TestCase $browser->waitFor('#layout-content .footer a.button.submit:not(.disabled)'); } - $browser->withinFrame('#preferences-frame', function ($browser) { + $browser->withinFrame('#preferences-frame', static function ($browser) { if (!$browser->isPhone()) { $browser->waitFor('.formbuttons button.submit'); } // Main Options fieldset - $browser->with('form.propform fieldset.main', function ($browser) { + $browser->with('form.propform fieldset.main', static function ($browser) { $browser->assertSeeIn('legend', 'Main Options'); $browser->assertSeeIn('label[for=_archive_mbox]', 'Archive') @@ -62,13 +62,13 @@ class SettingsTest extends \Tests\Browser\TestCase }); // Archive fieldset - $browser->with('form.propform fieldset.archive', function ($browser) { + $browser->with('form.propform fieldset.archive', static function ($browser) { $browser->assertSeeIn('legend', 'Archive'); $browser->assertSeeIn('label[for=ff_archive_type]', 'Divide archive by') ->assertVisible('select[name=_archive_type]') ->assertSelected('select[name=_archive_type]', '') - ->with('select[name=_archive_type]', function ($browser) { + ->with('select[name=_archive_type]', static function ($browser) { $browser->assertValue('option:nth-child(1)', '') ->assertSeeIn('option:nth-child(1)', 'None') ->assertValue('option:nth-child(2)', 'year') @@ -99,7 +99,7 @@ class SettingsTest extends \Tests\Browser\TestCase $browser->waitForMessage('confirmation', 'Successfully saved'); // Verify if every option has been updated - $browser->withinFrame('#preferences-frame', function ($browser) { + $browser->withinFrame('#preferences-frame', static function ($browser) { $browser->assertSelected('_archive_mbox', 'Drafts'); $browser->assertSelected('_archive_type', 'year'); }); @@ -111,18 +111,18 @@ class SettingsTest extends \Tests\Browser\TestCase */ public function testServerSettings() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('settings', 'preferences'); $browser->click('#sections-table tr.server'); - $browser->withinFrame('#preferences-frame', function ($browser) { + $browser->withinFrame('#preferences-frame', static function ($browser) { if (!$browser->isPhone()) { $browser->waitFor('.formbuttons button.submit'); } // Main Options fieldset - $browser->with('form.propform fieldset.main', function ($browser) { + $browser->with('form.propform fieldset.main', static function ($browser) { $browser->assertSeeIn('label[for=ff_read_on_archive]', 'Mark the message as read on archive') ->assertCheckboxState('_read_on_archive', false) ->setCheckboxState('_read_on_archive', true); @@ -141,7 +141,7 @@ class SettingsTest extends \Tests\Browser\TestCase $browser->waitForMessage('confirmation', 'Successfully saved'); // Verify if every option has been updated - $browser->withinFrame('#preferences-frame', function ($browser) { + $browser->withinFrame('#preferences-frame', static function ($browser) { $browser->assertCheckboxState('_read_on_archive', true); }); }); diff --git a/plugins/attachment_reminder/tests/Browser/PluginTest.php b/plugins/attachment_reminder/tests/Browser/PluginTest.php index 13c6901c4..ebe40385e 100644 --- a/plugins/attachment_reminder/tests/Browser/PluginTest.php +++ b/plugins/attachment_reminder/tests/Browser/PluginTest.php @@ -16,18 +16,18 @@ class PluginTest extends \Tests\Browser\TestCase */ public function testPreferences() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('settings', 'preferences'); $browser->click('#sections-table tr.compose'); - $browser->withinFrame('#preferences-frame', function ($browser) { + $browser->withinFrame('#preferences-frame', static function ($browser) { if (!$browser->isPhone()) { $browser->waitFor('.formbuttons button.submit'); } // Main Options fieldset - $browser->with('form.propform fieldset.main', function ($browser) { + $browser->with('form.propform fieldset.main', static function ($browser) { $browser->assertSeeIn('label[for=rcmfd_attachment_reminder]', 'Remind about forgotten attachments') ->assertCheckboxState('_attachment_reminder', false) ->setCheckboxState('_attachment_reminder', true); @@ -46,7 +46,7 @@ class PluginTest extends \Tests\Browser\TestCase $browser->waitForMessage('confirmation', 'Successfully saved'); // Verify if every option has been updated - $browser->withinFrame('#preferences-frame', function ($browser) { + $browser->withinFrame('#preferences-frame', static function ($browser) { $browser->assertCheckboxState('_attachment_reminder', true); }); }); @@ -59,7 +59,7 @@ class PluginTest extends \Tests\Browser\TestCase */ public function testMailCompose() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $send_btn = $browser->isPhone() ? '.buttons a.send' : '.formbuttons button.send'; $browser->go('mail', 'compose'); @@ -71,7 +71,7 @@ class PluginTest extends \Tests\Browser\TestCase ->click($send_btn); // Expect a dialog, Click "Attach a file" button - $browser->with(new Dialog(), function ($browser) { + $browser->with(new Dialog(), static function ($browser) { $browser->assertDialogTitle('Missing attachment?') ->assertDialogContent('Did you forget to attach a file?') ->assertButton('mainaction.attach', 'Attach a file') @@ -83,7 +83,7 @@ class PluginTest extends \Tests\Browser\TestCase $browser->click($send_btn); // Expect the dialog again, click Send button (in the dialog) - $browser->with(new Dialog(), function ($browser) { + $browser->with(new Dialog(), static function ($browser) { $browser->assertDialogTitle('Missing attachment?') ->clickButton('send'); }); diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php index 76b90660c..0bfe29cf6 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php @@ -2488,7 +2488,7 @@ class rcube_sieve_engine $is_flag_action = preg_match('/^(set|add|remove)flag$/', (string) $action['type']); if ($is_flag_action) { - $custom_flags = array_filter($flags_target, function ($v) use ($flags) { + $custom_flags = array_filter($flags_target, static function ($v) use ($flags) { return !in_array_nocase($v, $flags); }); } diff --git a/plugins/markasjunk/drivers/email_learn.php b/plugins/markasjunk/drivers/email_learn.php index e4ad7c78b..532f7fcc5 100644 --- a/plugins/markasjunk/drivers/email_learn.php +++ b/plugins/markasjunk/drivers/email_learn.php @@ -75,7 +75,7 @@ class markasjunk_email_learn 'mailto' => $mailto, 'dsn_enabled' => false, 'charset' => 'UTF-8', - 'error_handler' => function (...$args) use ($OUTPUT) { + 'error_handler' => static function (...$args) use ($OUTPUT) { call_user_func_array([$OUTPUT, 'show_message'], $args); $OUTPUT->send(); }, diff --git a/plugins/markasjunk/tests/Browser/MailTest.php b/plugins/markasjunk/tests/Browser/MailTest.php index 0f7c053dd..a80b331ec 100644 --- a/plugins/markasjunk/tests/Browser/MailTest.php +++ b/plugins/markasjunk/tests/Browser/MailTest.php @@ -20,13 +20,13 @@ class MailTest extends \Tests\Browser\TestCase */ public function testMailUI() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('mail'); // Toolbar menu (Spam button inactive) $browser->assertToolbarMenu([], ['junk']); - $browser->whenAvailable('#messagelist tbody', function ($browser) { + $browser->whenAvailable('#messagelist tbody', static function ($browser) { $browser->ctrlClick('tr:last-child'); }); @@ -42,7 +42,7 @@ class MailTest extends \Tests\Browser\TestCase } // Folders list - $browser->whenAvailable('#mailboxlist', function ($browser) { + $browser->whenAvailable('#mailboxlist', static function ($browser) { $browser->assertSeeIn('li.mailbox.junk .unreadcount', '1') ->assertMissing('li.mailbox.inbox .unreadcount') ->click('li.mailbox.junk') @@ -53,7 +53,7 @@ class MailTest extends \Tests\Browser\TestCase $browser->assertToolbarMenu([], ['notjunk']); // Messages list contains the moved message - $browser->whenAvailable('#messagelist tbody', function ($browser) { + $browser->whenAvailable('#messagelist tbody', static function ($browser) { $browser->assertElementsCount('tr', 1) ->ctrlClick('tr:last-child'); }); @@ -70,7 +70,7 @@ class MailTest extends \Tests\Browser\TestCase } // Folders list, the message is back in INBOX - $browser->whenAvailable('#mailboxlist', function ($browser) { + $browser->whenAvailable('#mailboxlist', static function ($browser) { $browser->assertMissing('li.mailbox.junk .unreadcount') ->assertSeeIn('li.mailbox.inbox .unreadcount', '1') ->click('li.mailbox.inbox') @@ -78,7 +78,7 @@ class MailTest extends \Tests\Browser\TestCase }); // Messages list contains the moved message - $browser->whenAvailable('#messagelist tbody', function ($browser) { + $browser->whenAvailable('#messagelist tbody', static function ($browser) { $browser->assertElementsCount('tr', 1); }); }); @@ -91,10 +91,10 @@ class MailTest extends \Tests\Browser\TestCase */ public function testMailView() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('mail'); - $browser->whenAvailable('#messagelist tbody', function ($browser) { + $browser->whenAvailable('#messagelist tbody', static function ($browser) { $browser->click('tr:last-child'); }); @@ -112,12 +112,12 @@ class MailTest extends \Tests\Browser\TestCase } // Folders list - $browser->whenAvailable('#mailboxlist', function ($browser) { + $browser->whenAvailable('#mailboxlist', static function ($browser) { $browser->click('li.mailbox.junk') ->waitUntilNotBusy(); }); - $browser->whenAvailable('#messagelist tbody', function ($browser) { + $browser->whenAvailable('#messagelist tbody', static function ($browser) { $browser->click('tr:last-child'); }); diff --git a/plugins/subscriptions_option/subscriptions_option.php b/plugins/subscriptions_option/subscriptions_option.php index b3fb9f076..538504795 100644 --- a/plugins/subscriptions_option/subscriptions_option.php +++ b/plugins/subscriptions_option/subscriptions_option.php @@ -102,7 +102,7 @@ class subscriptions_option extends rcube_plugin $storage = $rcmail->get_storage(); if ($folders = $storage->list_folders_direct($args['root'], $args['name'])) { - $folders = array_filter($folders, function ($folder) use ($storage) { + $folders = array_filter($folders, static function ($folder) use ($storage) { $attrs = $storage->folder_attributes($folder); return !in_array_nocase('\\Noselect', $attrs); }); diff --git a/plugins/zipdownload/tests/Browser/MailTest.php b/plugins/zipdownload/tests/Browser/MailTest.php index 6e37ec189..df217cdab 100644 --- a/plugins/zipdownload/tests/Browser/MailTest.php +++ b/plugins/zipdownload/tests/Browser/MailTest.php @@ -22,13 +22,13 @@ class MailTest extends \Tests\Browser\TestCase $this->browse(function ($browser) { $browser->go('mail'); - $browser->whenAvailable('#messagelist tbody', function ($browser) { + $browser->whenAvailable('#messagelist tbody', static function ($browser) { $browser->ctrlClick('tr:first-child'); }); // Test More > Download > Source (single message selected) $browser->clickToolbarMenuItem('more', null, false) - ->with(new Popupmenu('message-menu'), function ($browser) { + ->with(new Popupmenu('message-menu'), static function ($browser) { $browser->clickMenuItem('download', null, false); }) ->with(new Popupmenu('zipdownload-menu'), function ($browser) { @@ -49,7 +49,7 @@ class MailTest extends \Tests\Browser\TestCase // Test More > Download > Mailbox format (two messages selected) $browser->ctrlClick('#messagelist tbody tr:nth-of-type(2)') ->clickToolbarMenuItem('more', null, false) - ->with(new Popupmenu('message-menu'), function ($browser) { + ->with(new Popupmenu('message-menu'), static function ($browser) { $browser->clickMenuItem('download', null, false); }) ->with(new Popupmenu('zipdownload-menu'), function ($browser) { @@ -67,7 +67,7 @@ class MailTest extends \Tests\Browser\TestCase // Test More > Download > Maildir format (two messages selected) $browser->clickToolbarMenuItem('more', null, false) - ->with(new Popupmenu('message-menu'), function ($browser) { + ->with(new Popupmenu('message-menu'), static function ($browser) { $browser->clickMenuItem('download', null, false); }) ->with(new Popupmenu('zipdownload-menu'), function ($browser) { @@ -84,7 +84,7 @@ class MailTest extends \Tests\Browser\TestCase ->waitForMessage('loading', 'Loading...') ->waitFor('#messagecontframe') ->waitUntilMissing('#messagestack') - ->withinFrame('#messagecontframe', function ($browser) { + ->withinFrame('#messagecontframe', static function ($browser) { $browser->waitFor('.header-links a.zipdownload') ->click('.header-links a.zipdownload'); }); diff --git a/program/actions/contacts/index.php b/program/actions/contacts/index.php index 338b6e1be..6d420d1ca 100644 --- a/program/actions/contacts/index.php +++ b/program/actions/contacts/index.php @@ -832,7 +832,7 @@ class rcmail_action_contacts_index extends rcmail_action if (!empty($prop['subtypes'])) { // re-order subtypes, so 'work' is before 'home' if ($business_mode) { - $work_opts = array_filter($prop['subtypes'], function ($var) { return strpos($var, 'work') !== false; }); + $work_opts = array_filter($prop['subtypes'], static function ($var) { return strpos($var, 'work') !== false; }); if (!empty($work_opts)) { $coltypes[$col]['subtypes'] = $prop['subtypes'] = array_merge( $work_opts, diff --git a/program/actions/mail/bounce.php b/program/actions/mail/bounce.php index ed0def245..1bf4acbbc 100644 --- a/program/actions/mail/bounce.php +++ b/program/actions/mail/bounce.php @@ -64,7 +64,7 @@ class rcmail_action_mail_bounce extends rcmail_action ['mode' => rcmail_sendmail::MODE_FORWARD], [ 'sendmail' => true, - 'error_handler' => function (...$args) use ($rcmail) { + 'error_handler' => static function (...$args) use ($rcmail) { call_user_func_array([$rcmail->output, 'show_message'], $args); $rcmail->output->send('iframe'); }, diff --git a/program/actions/mail/search.php b/program/actions/mail/search.php index 851586566..629fac13d 100644 --- a/program/actions/mail/search.php +++ b/program/actions/mail/search.php @@ -225,7 +225,7 @@ class rcmail_action_mail_search extends rcmail_action_mail_index $result .= ' ' . $search_interval; } - $value_function = function ($value) { + $value_function = static function ($value) { $value = trim($value); $value = preg_replace('/(^"|"$)/', '', $value); $value = str_replace('\\"', '"', $value); diff --git a/program/actions/mail/send.php b/program/actions/mail/send.php index 45ffbeaf2..68167e6a9 100644 --- a/program/actions/mail/send.php +++ b/program/actions/mail/send.php @@ -56,7 +56,7 @@ class rcmail_action_mail_send extends rcmail_action 'sendmail' => true, 'saveonly' => $saveonly, 'savedraft' => $savedraft, - 'error_handler' => function (...$args) use ($rcmail) { + 'error_handler' => static function (...$args) use ($rcmail) { call_user_func_array([$rcmail->output, 'show_message'], $args); $rcmail->output->send('iframe'); }, diff --git a/program/actions/settings/about.php b/program/actions/settings/about.php index 8f952ef61..808e054d9 100644 --- a/program/actions/settings/about.php +++ b/program/actions/settings/about.php @@ -36,10 +36,10 @@ class rcmail_action_settings_about extends rcmail_action $rcmail->output->add_handlers([ 'supportlink' => [$this, 'supportlink'], 'pluginlist' => [$this, 'plugins_list'], - 'copyright' => function () { + 'copyright' => static function () { return 'Copyright © 2005-2023, The Roundcube Dev Team'; }, - 'license' => function () { + 'license' => static function () { return 'This program is free software; you can redistribute it and/or modify it under the terms ' . 'of the GNU General Public License ' . 'as published by the Free Software Foundation, either version 3 of the License, ' diff --git a/program/include/rcmail.php b/program/include/rcmail.php index ff74be68a..907ee4da9 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -1031,7 +1031,7 @@ class rcmail extends rcube $trash_mbox = $this->config->get('trash_mbox'); if ($logout_purge && !empty($trash_mbox)) { - $getMessages = function ($folder) use ($logout_purge, $storage) { + $getMessages = static function ($folder) use ($logout_purge, $storage) { if (is_numeric($logout_purge)) { $now = new DateTime('now'); $interval = new DateInterval('P' . intval($logout_purge) . 'D'); diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php index d74967fdb..4776081ed 100644 --- a/program/include/rcmail_output_html.php +++ b/program/include/rcmail_output_html.php @@ -2024,11 +2024,11 @@ class rcmail_output_html extends rcmail_output $is_empty = true; } - $merge_script_files = function ($output, $script) { + $merge_script_files = static function ($output, $script) { return $output . html::script($script); }; - $merge_scripts = function ($output, $script) { + $merge_scripts = static function ($output, $script) { return $output . html::script([], $script); }; diff --git a/program/include/rcmail_sendmail.php b/program/include/rcmail_sendmail.php index 0c97fdad2..d4c6031be 100644 --- a/program/include/rcmail_sendmail.php +++ b/program/include/rcmail_sendmail.php @@ -62,7 +62,7 @@ class rcmail_sendmail $this->options['sendmail_delay'] = (int) $this->rcmail->config->get('sendmail_delay'); if (empty($options['error_handler'])) { - $this->options['error_handler'] = function () { return false; }; + $this->options['error_handler'] = static function () { return false; }; } if (empty($this->data['mode'])) { diff --git a/program/lib/Roundcube/bootstrap.php b/program/lib/Roundcube/bootstrap.php index 6512a42e2..8cd5f977c 100644 --- a/program/lib/Roundcube/bootstrap.php +++ b/program/lib/Roundcube/bootstrap.php @@ -106,7 +106,7 @@ spl_autoload_register('rcube_autoload'); // set PEAR error handling (will also load the PEAR main class) if (class_exists('PEAR')) { - PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, function ($err) { rcube::raise_error($err, true); }); + PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, static function ($err) { rcube::raise_error($err, true); }); } /** diff --git a/program/lib/Roundcube/cache/memcache.php b/program/lib/Roundcube/cache/memcache.php index 94ed8ad9d..7306a9471 100644 --- a/program/lib/Roundcube/cache/memcache.php +++ b/program/lib/Roundcube/cache/memcache.php @@ -75,7 +75,7 @@ class rcube_cache_memcache extends rcube_cache $available = 0; // Callback for memcache failure - $error_callback = function ($host, $port) use ($seen, $available) { + $error_callback = static function ($host, $port) use ($seen, $available) { // only report once if (!$seen["$host:$port"]++) { $available--; diff --git a/program/lib/Roundcube/db/mysql.php b/program/lib/Roundcube/db/mysql.php index 56ceba03a..a1e409c8f 100644 --- a/program/lib/Roundcube/db/mysql.php +++ b/program/lib/Roundcube/db/mysql.php @@ -232,12 +232,12 @@ class rcube_db_mysql extends rcube_db */ public function insert_or_update($table, $keys, $columns, $values) { - $columns = array_map(function ($i) { return "`$i`"; }, $columns); - $cols = implode(', ', array_map(function ($i) { return "`$i`"; }, array_keys($keys))); + $columns = array_map(static function ($i) { return "`$i`"; }, $columns); + $cols = implode(', ', array_map(static function ($i) { return "`$i`"; }, array_keys($keys))); $cols .= ', ' . implode(', ', $columns); $vals = implode(', ', array_map(function ($i) { return $this->quote($i); }, $keys)); $vals .= ', ' . rtrim(str_repeat('?, ', count($columns)), ', '); - $update = implode(', ', array_map(function ($i) { return "$i = VALUES($i)"; }, $columns)); + $update = implode(', ', array_map(static function ($i) { return "$i = VALUES($i)"; }, $columns)); return $this->query("INSERT INTO $table ($cols) VALUES ($vals)" . " ON DUPLICATE KEY UPDATE $update", $values); diff --git a/program/lib/Roundcube/db/pgsql.php b/program/lib/Roundcube/db/pgsql.php index 2a3ba9fce..8705f9c89 100644 --- a/program/lib/Roundcube/db/pgsql.php +++ b/program/lib/Roundcube/db/pgsql.php @@ -208,7 +208,7 @@ class rcube_db_pgsql extends rcube_db $cols = $target . ', ' . implode(', ', $columns); $vals = implode(', ', array_map(function ($i) { return $this->quote($i); }, $keys)); $vals .= ', ' . rtrim(str_repeat('?, ', count($columns)), ', '); - $update = implode(', ', array_map(function ($i) { return "$i = EXCLUDED.$i"; }, $columns)); + $update = implode(', ', array_map(static function ($i) { return "$i = EXCLUDED.$i"; }, $columns)); return $this->query("INSERT INTO $table ($cols) VALUES ($vals)" . " ON CONFLICT ($target) DO UPDATE SET $update", $values); diff --git a/program/lib/Roundcube/rcube_addressbook.php b/program/lib/Roundcube/rcube_addressbook.php index de487dec0..b5f5cf27b 100644 --- a/program/lib/Roundcube/rcube_addressbook.php +++ b/program/lib/Roundcube/rcube_addressbook.php @@ -689,7 +689,7 @@ abstract class rcube_addressbook $compose_mode = (int) rcube::get_instance()->config->get('addressbook_name_listing', 0); } - $get_names = function ($contact, $fields) { + $get_names = static function ($contact, $fields) { $result = []; foreach ($fields as $field) { if (!empty($contact[$field])) { diff --git a/program/lib/Roundcube/rcube_cache.php b/program/lib/Roundcube/rcube_cache.php index 7b94c9550..b04d31d03 100644 --- a/program/lib/Roundcube/rcube_cache.php +++ b/program/lib/Roundcube/rcube_cache.php @@ -201,7 +201,7 @@ class rcube_cache $cache_key = $prefix; if (!empty($params)) { - $func = function ($v) { + $func = static function ($v) { if (is_array($v)) { sort($v); } diff --git a/program/lib/Roundcube/rcube_charset.php b/program/lib/Roundcube/rcube_charset.php index 944f86391..19a79f7e7 100644 --- a/program/lib/Roundcube/rcube_charset.php +++ b/program/lib/Roundcube/rcube_charset.php @@ -291,7 +291,7 @@ class rcube_charset } $out = false; - $error_handler = function () { throw new \Exception(); }; + $error_handler = static function () { throw new \Exception(); }; // Ignore invalid characters $mbstring_sc = mb_substitute_character(); diff --git a/program/lib/Roundcube/rcube_db.php b/program/lib/Roundcube/rcube_db.php index d33234cc5..14d113c47 100644 --- a/program/lib/Roundcube/rcube_db.php +++ b/program/lib/Roundcube/rcube_db.php @@ -588,8 +588,8 @@ class rcube_db */ public function insert_or_update($table, $keys, $columns, $values) { - $columns = array_map(function ($i) { return "`$i`"; }, $columns); - $sets = array_map(function ($i) { return "$i = ?"; }, $columns); + $columns = array_map(static function ($i) { return "`$i`"; }, $columns); + $sets = array_map(static function ($i) { return "$i = ?"; }, $columns); $where = $keys; array_walk($where, function (&$val, $key) { @@ -602,7 +602,7 @@ class rcube_db // if UPDATE fails use INSERT if ($result && !$this->affected_rows($result)) { - $cols = implode(', ', array_map(function ($i) { return "`$i`"; }, array_keys($keys))); + $cols = implode(', ', array_map(static function ($i) { return "`$i`"; }, array_keys($keys))); $cols .= ', ' . implode(', ', $columns); $vals = implode(', ', array_map(function ($i) { return $this->quote($i); }, $keys)); $vals .= ', ' . rtrim(str_repeat('?, ', count($columns)), ', '); diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php index 0987d18dd..d398acc6d 100644 --- a/program/lib/Roundcube/rcube_imap.php +++ b/program/lib/Roundcube/rcube_imap.php @@ -1140,7 +1140,7 @@ class rcube_imap extends rcube_storage } // Re-sort the result according to the original search set order - usort($a_msg_headers, function ($a, $b) use ($index) { + usort($a_msg_headers, static function ($a, $b) use ($index) { return array_search($a->uid . '-' . $a->folder, $index) - array_search($b->uid . '-' . $b->folder, $index); }); } @@ -3142,7 +3142,7 @@ class rcube_imap extends rcube_storage // Remove hidden folders if ($config->get('imap_skip_hidden_folders')) { - $result = array_filter($result, function ($v) { return $v[0] != '.'; }); + $result = array_filter($result, static function ($v) { return $v[0] != '.'; }); } // Remove folders in shared namespaces (if configured, see self::set_env()) @@ -3498,7 +3498,7 @@ class rcube_imap extends rcube_storage return $result; } - $types = array_map(function ($value) { return "\\" . ucfirst($value); }, rcube_storage::$folder_types); + $types = array_map(static function ($value) { return '\\' . ucfirst($value); }, rcube_storage::$folder_types); $special = []; // request \Subscribed flag in LIST response as performance improvement for folder_exists() diff --git a/program/lib/Roundcube/rcube_imap_generic.php b/program/lib/Roundcube/rcube_imap_generic.php index fc5803890..3a149e2b3 100644 --- a/program/lib/Roundcube/rcube_imap_generic.php +++ b/program/lib/Roundcube/rcube_imap_generic.php @@ -583,7 +583,7 @@ class rcube_imap_generic // RFC2195: CRAM-MD5 $ipad = ''; $opad = ''; - $xor = function ($str1, $str2) { + $xor = static function ($str1, $str2) { $result = ''; $size = strlen($str1); for ($i = 0; $i < $size; $i++) { @@ -3367,7 +3367,7 @@ class rcube_imap_generic */ public function setQuota($root, $quota) { - $fn = function ($key, $value) { + $fn = static function ($key, $value) { return strtoupper($key) . ' ' . $value; }; diff --git a/program/lib/Roundcube/rcube_result_multifolder.php b/program/lib/Roundcube/rcube_result_multifolder.php index 8eebcb48b..da13f94f4 100644 --- a/program/lib/Roundcube/rcube_result_multifolder.php +++ b/program/lib/Roundcube/rcube_result_multifolder.php @@ -76,7 +76,7 @@ class rcube_result_multifolder // append UIDs to global index $folder = $result->get_parameters('MAILBOX'); - $index = array_map(function ($uid) use ($folder) { return $uid . '-' . $folder; }, $result->get()); + $index = array_map(static function ($uid) use ($folder) { return $uid . '-' . $folder; }, $result->get()); $this->index = array_merge($this->index, $index); } diff --git a/program/lib/Roundcube/rcube_spellchecker.php b/program/lib/Roundcube/rcube_spellchecker.php index c70e8a3fb..0c58fcce6 100644 --- a/program/lib/Roundcube/rcube_spellchecker.php +++ b/program/lib/Roundcube/rcube_spellchecker.php @@ -139,7 +139,7 @@ class rcube_spellchecker } // ignore links (#8527) - $callback = function ($matches) { + $callback = static function ($matches) { // replace the link with a dummy string that has the same length // we can't just remove the link return str_repeat(' ', strlen($matches[0])); diff --git a/program/lib/Roundcube/rcube_uploads.php b/program/lib/Roundcube/rcube_uploads.php index 3150694e9..00c1dd7e8 100644 --- a/program/lib/Roundcube/rcube_uploads.php +++ b/program/lib/Roundcube/rcube_uploads.php @@ -272,7 +272,7 @@ trait rcube_uploads $data = array_diff_key($data, array_fill_keys(['id', 'group', 'status', 'abort', 'error', 'data', 'created'], 1)); // Remove null values - $data = array_filter($data, function ($v) { return $v !== null; }); + $data = array_filter($data, static function ($v) { return $v !== null; }); // Convert to string $data = json_encode($data, JSON_INVALID_UTF8_IGNORE); diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php index aa410c7d0..9e2b0ca1b 100644 --- a/program/lib/Roundcube/rcube_utils.php +++ b/program/lib/Roundcube/rcube_utils.php @@ -480,7 +480,7 @@ class rcube_utils // for cases like @media { body { position: fixed; } } (#5811) $excl = '(?!' . substr($replacements->pattern, 1, -1) . ')'; $regexp = '/(^\s*|,\s*|\}\s*|\{\s*)(' . $excl . ':?[a-z0-9\._#\*\[][a-z0-9\._:\(\)#=~ \[\]"\|\>\+\$\^-]*)/im'; - $callback = function ($matches) use ($container_id, $prefix) { + $callback = static function ($matches) use ($container_id, $prefix) { $replace = $matches[2]; if (stripos($replace, ':root') === 0) { @@ -628,7 +628,7 @@ class rcube_utils */ public static function xss_entity_decode($content) { - $callback = function ($matches) { return chr(hexdec($matches[1])); }; + $callback = static function ($matches) { return chr(hexdec($matches[1])); }; $out = html_entity_decode(html_entity_decode($content)); $out = trim(preg_replace('/(^$)/', '', trim($out))); @@ -1681,7 +1681,7 @@ class rcube_utils } // replace Re:, Re[x]:, Re-x (#1490497) - $pieces = array_map(function ($prefix) { + $pieces = array_map(static function ($prefix) { $prefix = strtolower(str_replace(':', '', $prefix)); return "$prefix:|$prefix\[\d\]:|$prefix-\d:"; }, $prefixes); diff --git a/tests/ActionTestCase.php b/tests/ActionTestCase.php index 064a105bb..3a997ec86 100644 --- a/tests/ActionTestCase.php +++ b/tests/ActionTestCase.php @@ -185,7 +185,7 @@ class ActionTestCase extends PHPUnit\Framework\TestCase // Attachments handling plugins use move_uploaded_file() which does not work // here. We'll add a fake hook handler for our purposes. $rcmail = rcmail::get_instance(); - $rcmail->plugins->register_hook('attachment_upload', function ($att) use ($file) { + $rcmail->plugins->register_hook('attachment_upload', static function ($att) use ($file) { $att['status'] = true; $att['id'] = $file['id']; return $att; @@ -227,7 +227,7 @@ class ActionTestCase extends PHPUnit\Framework\TestCase // Attachments handling plugins use move_uploaded_file() which does not work // here. We'll add a fake hook handler for our purposes. $rcmail = rcmail::get_instance(); - $rcmail->plugins->register_hook('attachment_upload', function ($att) use ($file) { + $rcmail->plugins->register_hook('attachment_upload', static function ($att) use ($file) { $att['status'] = true; $att['id'] = $file['id']; return $att; diff --git a/tests/Actions/Mail/AttachmentDelete.php b/tests/Actions/Mail/AttachmentDelete.php index 2fdcf5312..bfd790f52 100644 --- a/tests/Actions/Mail/AttachmentDelete.php +++ b/tests/Actions/Mail/AttachmentDelete.php @@ -28,7 +28,7 @@ class Actions_Mail_AttachmentDelete extends ActionTestCase // This is needed so upload deletion works $rcmail = rcmail::get_instance(); unset($rcmail->plugins->handlers['attachment_delete']); - $rcmail->plugins->register_hook('attachment_delete', function ($att) { + $rcmail->plugins->register_hook('attachment_delete', static function ($att) { $att['status'] = true; $att['break'] = true; return $att; diff --git a/tests/Browser/Browser.php b/tests/Browser/Browser.php index d007bb260..1e568d2a8 100644 --- a/tests/Browser/Browser.php +++ b/tests/Browser/Browser.php @@ -75,7 +75,7 @@ class Browser extends \Laravel\Dusk\Browser */ public function assertTaskMenu($selected) { - $this->with(new Components\Taskmenu(), function ($browser) use ($selected) { + $this->with(new Components\Taskmenu(), static function ($browser) use ($selected) { $browser->assertMenuState($selected); }); @@ -87,7 +87,7 @@ class Browser extends \Laravel\Dusk\Browser */ public function assertToolbarMenu($active, $disabled = [], $missing = []) { - $this->with(new Components\Toolbarmenu(), function ($browser) use ($active, $disabled, $missing) { + $this->with(new Components\Toolbarmenu(), static function ($browser) use ($active, $disabled, $missing) { $browser->assertMenuState($active, $disabled, $missing); }); @@ -99,7 +99,7 @@ class Browser extends \Laravel\Dusk\Browser */ public function closeToolbarMenu() { - $this->with(new Components\Toolbarmenu(), function ($browser) { + $this->with(new Components\Toolbarmenu(), static function ($browser) { $browser->closeMenu(); }); @@ -111,7 +111,7 @@ class Browser extends \Laravel\Dusk\Browser */ public function clickTaskMenuItem($name) { - $this->with(new Components\Taskmenu(), function ($browser) use ($name) { + $this->with(new Components\Taskmenu(), static function ($browser) use ($name) { $browser->clickMenuItem($name); }); @@ -123,7 +123,7 @@ class Browser extends \Laravel\Dusk\Browser */ public function clickToolbarMenuItem($name, $dropdown_action = null, $close = true) { - $this->with(new Components\Toolbarmenu(), function ($browser) use ($name, $dropdown_action, $close) { + $this->with(new Components\Toolbarmenu(), static function ($browser) use ($name, $dropdown_action, $close) { $browser->clickMenuItem($name, $dropdown_action, $close); }); @@ -147,7 +147,7 @@ class Browser extends \Laravel\Dusk\Browser */ public function go($task = 'mail', $action = null, $login = true) { - $this->with(new Components\App(), function ($browser) use ($task, $action, $login) { + $this->with(new Components\App(), static function ($browser) use ($task, $action, $login) { $browser->gotoAction($task, $action, $login); }); diff --git a/tests/Browser/Components/Dialog.php b/tests/Browser/Components/Dialog.php index cc91f8ab1..ff6f508b3 100644 --- a/tests/Browser/Components/Dialog.php +++ b/tests/Browser/Components/Dialog.php @@ -116,8 +116,8 @@ class Dialog extends Component */ public function withinDialogFrame($browser, $callback) { - $browser->withinFrame('@content iframe', function ($browser) use ($callback) { - $browser->withinBody(function ($browser) use ($callback) { + $browser->withinFrame('@content iframe', static function ($browser) use ($callback) { + $browser->withinBody(static function ($browser) use ($callback) { $callback($browser); }); }); diff --git a/tests/Browser/Components/Popupmenu.php b/tests/Browser/Components/Popupmenu.php index f86d2f967..088c86d04 100644 --- a/tests/Browser/Components/Popupmenu.php +++ b/tests/Browser/Components/Popupmenu.php @@ -106,7 +106,7 @@ class Popupmenu extends Component if ($dropdown_action) { $popup_id = $browser->attribute($selector, 'data-popup'); - $browser->withinBody(function ($browser) use ($popup_id, $dropdown_action) { + $browser->withinBody(static function ($browser) use ($popup_id, $dropdown_action) { $browser->click("#{$popup_id} li a.{$dropdown_action}"); }); } diff --git a/tests/Browser/Components/Taskmenu.php b/tests/Browser/Components/Taskmenu.php index ca19f64c1..1cb338a10 100644 --- a/tests/Browser/Components/Taskmenu.php +++ b/tests/Browser/Components/Taskmenu.php @@ -79,7 +79,7 @@ class Taskmenu extends Component public function clickMenuItem(Browser $browser, $name) { if ($browser->isPhone()) { - $browser->withinBody(function ($browser) { + $browser->withinBody(static function ($browser) { $browser->click('.task-menu-button'); }); } diff --git a/tests/Browser/Components/Toolbarmenu.php b/tests/Browser/Components/Toolbarmenu.php index 09562ac27..7186d47a8 100644 --- a/tests/Browser/Components/Toolbarmenu.php +++ b/tests/Browser/Components/Toolbarmenu.php @@ -110,7 +110,7 @@ class Toolbarmenu extends Component if ($dropdown_action) { $popup_id = $browser->attribute($selector, 'data-popup'); - $browser->withinBody(function ($browser) use ($popup_id, $dropdown_action) { + $browser->withinBody(static function ($browser) use ($popup_id, $dropdown_action) { $browser->click("#{$popup_id} li a.{$dropdown_action}"); }); } diff --git a/tests/Browser/Contacts/ContactsTest.php b/tests/Browser/Contacts/ContactsTest.php index 089e49bbb..7628af379 100644 --- a/tests/Browser/Contacts/ContactsTest.php +++ b/tests/Browser/Contacts/ContactsTest.php @@ -16,10 +16,10 @@ class ContactsTest extends \Tests\Browser\TestCase */ public function testContactsUI() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('addressbook'); - $browser->with(new App(), function ($browser) { + $browser->with(new App(), static function ($browser) { // check task $browser->assertEnv('task', 'addressbook'); diff --git a/tests/Browser/Contacts/GroupsTest.php b/tests/Browser/Contacts/GroupsTest.php index f47f47448..5ca960ca6 100644 --- a/tests/Browser/Contacts/GroupsTest.php +++ b/tests/Browser/Contacts/GroupsTest.php @@ -17,7 +17,7 @@ class GroupsTest extends \Tests\Browser\TestCase */ public function testGroups() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('addressbook'); if (!$browser->isDesktop()) { @@ -33,7 +33,7 @@ class GroupsTest extends \Tests\Browser\TestCase $browser->click('#layout-sidebar .header .sidebar-menu'); - $browser->with(new Popupmenu('groupoptions-menu'), function ($browser) { + $browser->with(new Popupmenu('groupoptions-menu'), static function ($browser) { // Note: These are button class names, not action names $active = ['create']; $disabled = ['group.rename', 'group.delete', 'search', 'search.delete']; @@ -49,7 +49,7 @@ class GroupsTest extends \Tests\Browser\TestCase */ public function testGroupCreate() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('addressbook'); if (!$browser->isDesktop()) { @@ -58,11 +58,11 @@ class GroupsTest extends \Tests\Browser\TestCase $browser->click('#layout-sidebar .header .sidebar-menu'); - $browser->with(new Popupmenu('groupoptions-menu'), function ($browser) { + $browser->with(new Popupmenu('groupoptions-menu'), static function ($browser) { $browser->clickMenuItem('create'); }); - $browser->with(new Dialog(), function ($browser) { + $browser->with(new Dialog(), static function ($browser) { $browser->assertDialogTitle('Create new group') ->assertButton('save.mainaction', 'Save') ->assertButton('cancel', 'Cancel') @@ -71,7 +71,7 @@ class GroupsTest extends \Tests\Browser\TestCase ->clickButton('save'); }); - $browser->with('#directorylist', function ($browser) { + $browser->with('#directorylist', static function ($browser) { $browser->waitFor('li:first-child ul.groups') ->assertVisible('.treetoggle.expanded') ->assertElementsCount('ul.groups > li.contactgroup', 1) @@ -93,7 +93,7 @@ class GroupsTest extends \Tests\Browser\TestCase */ public function testGroupRename() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('addressbook'); if (!$browser->isDesktop()) { @@ -108,11 +108,11 @@ class GroupsTest extends \Tests\Browser\TestCase $browser->click('#layout-sidebar .header .sidebar-menu'); - $browser->with(new Popupmenu('groupoptions-menu'), function ($browser) { + $browser->with(new Popupmenu('groupoptions-menu'), static function ($browser) { $browser->clickMenuItem('group.rename'); }); - $browser->with(new Dialog(), function ($browser) { + $browser->with(new Dialog(), static function ($browser) { $browser ->assertDialogTitle('Rename group') ->assertButton('save.mainaction', 'Save') @@ -123,7 +123,7 @@ class GroupsTest extends \Tests\Browser\TestCase ->clickButton('save'); }); - $browser->with('#directorylist', function ($browser) { + $browser->with('#directorylist', static function ($browser) { $browser->waitFor('li:first-child ul.groups') ->assertVisible('.treetoggle.expanded') ->assertElementsCount('ul.groups > li.contactgroup', 1) @@ -145,7 +145,7 @@ class GroupsTest extends \Tests\Browser\TestCase */ public function testGroupDelete() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('addressbook'); if (!$browser->isDesktop()) { @@ -160,11 +160,11 @@ class GroupsTest extends \Tests\Browser\TestCase $browser->click('#layout-sidebar .header .sidebar-menu'); - $browser->with(new Popupmenu('groupoptions-menu'), function ($browser) { + $browser->with(new Popupmenu('groupoptions-menu'), static function ($browser) { $browser->clickMenuItem('group.delete'); }); - $browser->with(new Dialog(), function ($browser) { + $browser->with(new Dialog(), static function ($browser) { $browser ->assertDialogTitle('Are you sure...') ->assertDialogContent('Do you really want to delete selected group?') @@ -173,7 +173,7 @@ class GroupsTest extends \Tests\Browser\TestCase ->clickButton('delete'); }); - $browser->with('#directorylist', function ($browser) { + $browser->with('#directorylist', static function ($browser) { $browser->assertMissing('.treetoggle.expanded') ->assertMissing('ul.groups'); }); diff --git a/tests/Browser/Contacts/ImportTest.php b/tests/Browser/Contacts/ImportTest.php index 6a553e2df..7d4876452 100644 --- a/tests/Browser/Contacts/ImportTest.php +++ b/tests/Browser/Contacts/ImportTest.php @@ -17,20 +17,20 @@ class ImportTest extends \Tests\Browser\TestCase */ public function testImportUI() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('addressbook'); $browser->clickToolbarMenuItem('import'); - $browser->with(new Dialog(), function ($browser) { + $browser->with(new Dialog(), static function ($browser) { $browser->assertDialogTitle('Import contacts') ->assertButton('mainaction.import', 'Import') ->assertButton('cancel', 'Cancel'); }); - $browser->withinFrame('.ui-dialog iframe', function ($browser) { + $browser->withinFrame('.ui-dialog iframe', static function ($browser) { // check task and action - $browser->with(new App(), function ($browser) { + $browser->with(new App(), static function ($browser) { $browser->assertEnv('task', 'addressbook'); $browser->assertEnv('action', 'import'); // these objects should be there always @@ -47,7 +47,7 @@ class ImportTest extends \Tests\Browser\TestCase }); // Close the dialog - $browser->with(new Dialog(), function ($browser) { + $browser->with(new Dialog(), static function ($browser) { $browser->clickButton('cancel'); }); }); @@ -60,29 +60,29 @@ class ImportTest extends \Tests\Browser\TestCase */ public function testImportProcess() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { // Open the dialog again $browser->clickToolbarMenuItem('import'); - $browser->with(new Dialog(), function ($browser) { + $browser->with(new Dialog(), static function ($browser) { $browser->assertDialogTitle('Import contacts') ->clickButton('import'); }); // Submit the form with no file attached - $browser->with(new Dialog(2), function ($browser) { + $browser->with(new Dialog(2), static function ($browser) { $browser->assertDialogTitle('Attention') ->assertDialogContent('Please select a file') ->assertButton('save.mainaction', 'OK') ->pressESC(); }); - $browser->with(new Dialog(), function ($browser) { - $browser->withinDialogFrame(function ($browser) { + $browser->with(new Dialog(), static function ($browser) { + $browser->withinDialogFrame(static function ($browser) { $browser->attach('.custom-file input', TESTS_DIR . 'data/contacts.vcf'); }) ->clickButton('import') - ->withinDialogFrame(function ($browser) { + ->withinDialogFrame(static function ($browser) { $browser->waitForText('Successfully imported 2 contacts:'); }) ->closeDialog(); @@ -102,11 +102,11 @@ class ImportTest extends \Tests\Browser\TestCase */ public function testImportResult() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { // Open the dialog again $browser->click('#contacts-table tr:last-child'); - $browser->withinFrame('#contact-frame', function ($browser) { + $browser->withinFrame('#contact-frame', static function ($browser) { $browser->waitFor('a.email'); // wait for iframe to load $browser->assertSeeIn('.names', 'Sylvester Stalone'); $browser->assertSeeIn('a.email', 's.stalone@rambo.tv'); diff --git a/tests/Browser/Contacts/PrintTest.php b/tests/Browser/Contacts/PrintTest.php index bf612654e..74b35bfdc 100644 --- a/tests/Browser/Contacts/PrintTest.php +++ b/tests/Browser/Contacts/PrintTest.php @@ -32,7 +32,7 @@ class PrintTest extends \Tests\Browser\TestCase $browser->driver->switchTo()->window($new_window); - $browser->with(new App(), function ($browser) { + $browser->with(new App(), static function ($browser) { $browser->assertEnv([ 'task' => 'addressbook', 'action' => 'print', diff --git a/tests/Browser/Logon/LoginTest.php b/tests/Browser/Logon/LoginTest.php index e7446394f..b6328e27f 100644 --- a/tests/Browser/Logon/LoginTest.php +++ b/tests/Browser/Logon/LoginTest.php @@ -23,7 +23,7 @@ class LoginTest extends TestCase $browser->assertTitleContains($this->app->config->get('product_name')); // task should be set to 'login' - $browser->with(new App(), function ($browser) { + $browser->with(new App(), static function ($browser) { $browser->assertEnv('task', 'login'); }); @@ -45,7 +45,7 @@ class LoginTest extends TestCase $browser->go('mail'); // task should be set to 'mail' now - $browser->with(new App(), function ($browser) { + $browser->with(new App(), static function ($browser) { $browser->assertEnv('task', 'mail'); }); }); diff --git a/tests/Browser/Logon/LogoutTest.php b/tests/Browser/Logon/LogoutTest.php index ec2b811fd..60003e1b7 100644 --- a/tests/Browser/Logon/LogoutTest.php +++ b/tests/Browser/Logon/LogoutTest.php @@ -8,14 +8,14 @@ class LogoutTest extends TestCase { public function testLogout() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('settings'); // click the Logout button in taskmenu $browser->clickTaskMenuItem('logout'); // task should be set to 'login' - $browser->with(new App(), function ($browser) { + $browser->with(new App(), static function ($browser) { $browser->assertEnv('task', 'login'); }); diff --git a/tests/Browser/Mail/ComposeTest.php b/tests/Browser/Mail/ComposeTest.php index 7e8ba4f4b..1d47bb71d 100644 --- a/tests/Browser/Mail/ComposeTest.php +++ b/tests/Browser/Mail/ComposeTest.php @@ -16,13 +16,13 @@ class ComposeTest extends \Tests\Browser\TestCase public function testCompose() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('mail'); $browser->clickTaskMenuItem('compose'); // check task and action - $browser->with(new App(), function ($browser) { + $browser->with(new App(), static function ($browser) { $browser->assertEnv('task', 'mail'); $browser->assertEnv('action', 'compose'); @@ -85,8 +85,8 @@ class ComposeTest extends \Tests\Browser\TestCase { // Test for #7230: Shift+PageUp text selection // and copy-pasting with keyboard - $this->browse(function ($browser) { - $browser->with(new HtmlEditor('composebodycontainer'), function ($browser) { + $this->browse(static function ($browser) { + $browser->with(new HtmlEditor('composebodycontainer'), static function ($browser) { $browser->assertMode(HtmlEditor::MODE_PLAIN) ->type('@plain-body', "line1\nline2\n") ->keys('@plain-body', [WebDriverKeys::SHIFT, WebDriverKeys::PAGE_UP]) @@ -99,8 +99,8 @@ class ComposeTest extends \Tests\Browser\TestCase }); // Test switching to HTML and back - $this->browse(function ($browser) { - $browser->with(new HtmlEditor('composebodycontainer'), function ($browser) { + $this->browse(static function ($browser) { + $browser->with(new HtmlEditor('composebodycontainer'), static function ($browser) { $browser->switchMode(HtmlEditor::MODE_HTML, true) ->switchMode(HtmlEditor::MODE_PLAIN) ->assertValue('@plain-body', "line1\nline2\nline1\nline2") @@ -116,11 +116,11 @@ class ComposeTest extends \Tests\Browser\TestCase { // Test for #7231: Recipient input bug when using click // to select a contact from autocomplete list - $this->browse(function ($browser) { - $browser->with(new RecipientInput('#compose_to'), function ($browser) { + $this->browse(static function ($browser) { + $browser->with(new RecipientInput('#compose_to'), static function ($browser) { $browser->type('@input', 'johndoe@e') - ->withinBody(function ($browser) { - $browser->whenAvailable('#rcmKSearchpane', function ($browser) { + ->withinBody(static function ($browser) { + $browser->whenAvailable('#rcmKSearchpane', static function ($browser) { $browser->click('li:first-child'); }); }) diff --git a/tests/Browser/Mail/ListTest.php b/tests/Browser/Mail/ListTest.php index d07dd49df..177ab75f1 100644 --- a/tests/Browser/Mail/ListTest.php +++ b/tests/Browser/Mail/ListTest.php @@ -41,7 +41,7 @@ class ListTest extends \Tests\Browser\TestCase $browser->assertVisible('#layout-list .header a.toolbar-button.refresh:not(.disabled)'); if ($browser->isDesktop()) { - $browser->with('#toolbar-list-menu', function ($browser) { + $browser->with('#toolbar-list-menu', static function ($browser) { $browser->assertVisible('a.select:not(.disabled)'); $browser->assertVisible('a.options:not(.disabled)'); @@ -58,7 +58,7 @@ class ListTest extends \Tests\Browser\TestCase $browser->click('.toolbar-list-button') ->waitFor('#toolbar-list-menu'); - $browser->with('#toolbar-list-menu', function ($browser) { + $browser->with('#toolbar-list-menu', static function ($browser) { $browser->assertVisible('a.select:not(.disabled)'); $browser->assertVisible('a.options:not(.disabled)'); @@ -75,7 +75,7 @@ class ListTest extends \Tests\Browser\TestCase } else { // phone // On phones list options are in the toolbar menu - $browser->with(new Toolbarmenu(), function ($browser) { + $browser->with(new Toolbarmenu(), static function ($browser) { $active = ['select', 'options']; $missing = []; $imap = \bootstrap::get_storage(); @@ -98,9 +98,9 @@ class ListTest extends \Tests\Browser\TestCase */ public function testListSelection() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { if ($browser->isPhone()) { - $browser->with(new Toolbarmenu(), function ($browser) { + $browser->with(new Toolbarmenu(), static function ($browser) { $browser->clickMenuItem('select', null, false); }); } @@ -115,7 +115,7 @@ class ListTest extends \Tests\Browser\TestCase // Popup menu content $browser->waitFor('#listselect-menu'); - $browser->with('#listselect-menu', function ($browser) { + $browser->with('#listselect-menu', static function ($browser) { $browser->assertVisible('a.selection:not(.disabled)'); $browser->assertVisible('a.select.all:not(.disabled)'); $browser->assertVisible('a.select.page:not(.disabled)'); diff --git a/tests/Browser/Mail/MailTest.php b/tests/Browser/Mail/MailTest.php index 3605c3198..7a9c0bab5 100644 --- a/tests/Browser/Mail/MailTest.php +++ b/tests/Browser/Mail/MailTest.php @@ -9,11 +9,11 @@ class MailTest extends \Tests\Browser\TestCase { public function testMailUI() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('mail'); // check task - $browser->with(new App(), function ($browser) { + $browser->with(new App(), static function ($browser) { $browser->assertEnv('task', 'mail'); // these objects should be there always $browser->assertObjects([ @@ -60,12 +60,12 @@ class MailTest extends \Tests\Browser\TestCase */ public function testMessageMenu() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('mail'); $browser->clickToolbarMenuItem('more', null, false); - $browser->with(new Popupmenu('message-menu'), function ($browser) { + $browser->with(new Popupmenu('message-menu'), static function ($browser) { // Note: These are button class names, not action names $active = ['import']; $disabled = ['print', 'download', 'edit.asnew', 'source', 'move', 'copy', 'extwin']; diff --git a/tests/Browser/Mail/OpenTest.php b/tests/Browser/Mail/OpenTest.php index 7312b4dee..2f1c6baed 100644 --- a/tests/Browser/Mail/OpenTest.php +++ b/tests/Browser/Mail/OpenTest.php @@ -43,13 +43,13 @@ class OpenTest extends \Tests\Browser\TestCase $uid = $uids[0]; - [$current_window, $new_window] = $browser->openWindow(function ($browser) { + [$current_window, $new_window] = $browser->openWindow(static function ($browser) { $browser->clickMenuItem('extwin'); }); $browser->driver->switchTo()->window($new_window); - $browser->with(new App(), function ($browser) use ($uid) { + $browser->with(new App(), static function ($browser) use ($uid) { $browser->assertEnv([ 'task' => 'mail', 'action' => 'show', diff --git a/tests/Browser/Mail/PreviewTest.php b/tests/Browser/Mail/PreviewTest.php index 2234e3b9e..1366846ca 100644 --- a/tests/Browser/Mail/PreviewTest.php +++ b/tests/Browser/Mail/PreviewTest.php @@ -33,7 +33,7 @@ class PreviewTest extends \Tests\Browser\TestCase // On phone check frame controls if ($browser->isPhone()) { - $browser->with('#layout-content .footer', function ($browser) { + $browser->with('#layout-content .footer', static function ($browser) { $browser->assertVisible('a.button.prev.disabled') ->assertVisible('a.button.next:not(.disabled)') ->assertVisible('a.button.reply:not(.disabled)') @@ -71,19 +71,19 @@ class PreviewTest extends \Tests\Browser\TestCase // On phone check frame controls if ($browser->isPhone()) { - $browser->with('#layout-content .footer', function ($browser) { + $browser->with('#layout-content .footer', static function ($browser) { $browser->assertVisible('a.button.prev:not(.disabled)') ->assertVisible('a.button.next.disabled') ->assertVisible('a.button.reply:not(.disabled)'); }); } - $browser->withinFrame('#messagecontframe', function ($browser) { + $browser->withinFrame('#messagecontframe', static function ($browser) { $browser->waitFor('img.contactphoto') ->assertMissing('#remote-objects-message'); // Attachments list - $browser->with('#attachment-list', function ($browser) { + $browser->with('#attachment-list', static function ($browser) { $browser->assertVisible('li:nth-child(1).text.plain') ->assertSeeIn('li:nth-child(1) .attachment-name', 'lines.txt') ->assertSeeIn('li:nth-child(1) .attachment-size', '(~13 B)') @@ -95,7 +95,7 @@ class PreviewTest extends \Tests\Browser\TestCase if (!$browser->isPhone()) { $browser->waitFor('#attachmentmenu') - ->with('#attachmentmenu', function ($browser) { + ->with('#attachmentmenu', static function ($browser) { $browser->assertVisible('a.extwin:not(.disabled)') ->assertVisible('a.download:not(.disabled)') ->click('a.download'); @@ -105,7 +105,7 @@ class PreviewTest extends \Tests\Browser\TestCase if ($browser->isPhone()) { $browser->waitFor('#attachmentmenu-clone') - ->with('#attachmentmenu-clone', function ($browser) { + ->with('#attachmentmenu-clone', static function ($browser) { $browser->assertVisible('a.extwin:not(.disabled)') ->assertVisible('a.download:not(.disabled)') ->click('a.download'); @@ -134,7 +134,7 @@ class PreviewTest extends \Tests\Browser\TestCase */ public function testPreviewMorelink() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('mail'); $browser->waitFor('#messagelist tbody tr:last-child') @@ -143,7 +143,7 @@ class PreviewTest extends \Tests\Browser\TestCase ->waitFor('#messagecontframe') ->waitUntilMissing('#messagestack'); - $browser->withinFrame('#messagecontframe', function ($browser) { + $browser->withinFrame('#messagecontframe', static function ($browser) { $browser->waitFor('img.contactphoto'); $browser->assertSeeIn('.subject', 'Lines') @@ -160,7 +160,7 @@ class PreviewTest extends \Tests\Browser\TestCase ->click('.header.cc a.morelink'); }); - $browser->with(new Dialog(), function ($browser) { + $browser->with(new Dialog(), static function ($browser) { $browser->assertDialogTitle('Cc') ->assertDialogContent('test1@domain.tld') ->assertDialogContent('test12@domain.tld') diff --git a/tests/Browser/Mail/PrintTest.php b/tests/Browser/Mail/PrintTest.php index d84bd9efc..863146f0f 100644 --- a/tests/Browser/Mail/PrintTest.php +++ b/tests/Browser/Mail/PrintTest.php @@ -37,14 +37,14 @@ class PrintTest extends \Tests\Browser\TestCase $this->markTestSkipped(); } - [$current_window, $new_window] = $browser->openWindow(function ($browser) { + [$current_window, $new_window] = $browser->openWindow(static function ($browser) { $browser->clickMenuItem('print'); }); }); $browser->driver->switchTo()->window($new_window); - $browser->with(new App(), function ($browser) { + $browser->with(new App(), static function ($browser) { $browser->assertEnv([ 'task' => 'mail', 'action' => 'print', @@ -56,7 +56,7 @@ class PrintTest extends \Tests\Browser\TestCase ->assertSeeIn('.message-part div.pre', 'Plain text message body.') ->assertVisible('.message-part div.pre .sig') // Tests "more recipients" link - ->with('.header-headers .header.cc', function ($browser) { + ->with('.header-headers .header.cc', static function ($browser) { $browser->assertSee('test10@domain.tld') ->assertDontSee('test11@domain.tld') ->assertSeeIn('a.morelink', '2 more...') diff --git a/tests/Browser/Settings/AboutTest.php b/tests/Browser/Settings/AboutTest.php index 00c3eb561..a15be3b5d 100644 --- a/tests/Browser/Settings/AboutTest.php +++ b/tests/Browser/Settings/AboutTest.php @@ -14,7 +14,7 @@ class AboutTest extends \Tests\Browser\TestCase $browser->clickTaskMenuItem('about'); - $browser->with(new Dialog(), function ($browser) { + $browser->with(new Dialog(), static function ($browser) { $browser->assertDialogTitle('About') ->assertButton('cancel', 'Close') ->assertVisible('@content #aboutframe'); @@ -26,7 +26,7 @@ class AboutTest extends \Tests\Browser\TestCase $browser->withinFrame('#aboutframe', function ($browser) { // check task and action - $browser->with(new App(), function ($browser) { + $browser->with(new App(), static function ($browser) { $browser->assertEnv('task', 'settings'); $browser->assertEnv('action', 'about'); }); @@ -35,7 +35,7 @@ class AboutTest extends \Tests\Browser\TestCase $browser->assertVisible('#pluginlist'); }); - $browser->with(new Dialog(), function ($browser) { + $browser->with(new Dialog(), static function ($browser) { $browser->closeDialog(); }); }); diff --git a/tests/Browser/Settings/FoldersTest.php b/tests/Browser/Settings/FoldersTest.php index af34aa290..7ac1455c6 100644 --- a/tests/Browser/Settings/FoldersTest.php +++ b/tests/Browser/Settings/FoldersTest.php @@ -17,11 +17,11 @@ class FoldersTest extends \Tests\Browser\TestCase */ public function testFolders() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('settings', 'folders'); // task should be set to 'settings' and action to 'folders' - $browser->with(new App(), function ($browser) { + $browser->with(new App(), static function ($browser) { $browser->assertEnv('task', 'settings'); $browser->assertEnv('action', 'folders'); @@ -44,7 +44,7 @@ class FoldersTest extends \Tests\Browser\TestCase $browser->assertToolbarMenu(['create'], ['delete', 'purge']); // Folders list - $browser->with('#subscription-table', function ($browser) { + $browser->with('#subscription-table', static function ($browser) { // Note: first li element is root which is hidden in Elastic $browser->assertHasClass('li:nth-child(2)', 'inbox') ->assertSeeIn('li:nth-child(2)', 'Inbox') @@ -73,7 +73,7 @@ class FoldersTest extends \Tests\Browser\TestCase */ public function testFolderCreate() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('settings', 'folders'); $num = count($browser->elements('#subscription-table li')); @@ -87,9 +87,9 @@ class FoldersTest extends \Tests\Browser\TestCase $browser->clickToolbarMenuItem('create'); } - $browser->withinFrame('#preferences-frame', function ($browser) { + $browser->withinFrame('#preferences-frame', static function ($browser) { $browser->waitFor('form') - ->with('form fieldset', function ($browser) { + ->with('form fieldset', static function ($browser) { $browser->assertVisible('input[name=_name]') ->assertValue('input[name=_name]', '') ->assertVisible('select[name=_parent]') @@ -124,7 +124,7 @@ class FoldersTest extends \Tests\Browser\TestCase $num++; // Folders list - $browser->with('#subscription-table', function ($browser) use ($num) { + $browser->with('#subscription-table', static function ($browser) use ($num) { // Note: li.root is hidden in Elastic $browser->waitFor("li.mailbox:nth-child({$num})") ->assertElementsCount('li', $num - 1) @@ -136,7 +136,7 @@ class FoldersTest extends \Tests\Browser\TestCase $browser->waitFor('#preferences-frame'); } - $browser->withinFrame('#preferences-frame', function ($browser) { + $browser->withinFrame('#preferences-frame', static function ($browser) { $browser->waitFor('form'); // TODO }); diff --git a/tests/Browser/Settings/IdentitiesTest.php b/tests/Browser/Settings/IdentitiesTest.php index a0c0b95ac..dfa975f64 100644 --- a/tests/Browser/Settings/IdentitiesTest.php +++ b/tests/Browser/Settings/IdentitiesTest.php @@ -14,11 +14,11 @@ class IdentitiesTest extends \Tests\Browser\TestCase public function testIdentities() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('settings', 'identities'); // check task and action - $browser->with(new App(), function ($browser) { + $browser->with(new App(), static function ($browser) { $browser->assertEnv('task', 'settings'); $browser->assertEnv('action', 'identities'); @@ -47,7 +47,7 @@ class IdentitiesTest extends \Tests\Browser\TestCase */ public function testIdentityCreate() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('settings', 'identities'); if ($browser->isPhone()) { @@ -59,9 +59,9 @@ class IdentitiesTest extends \Tests\Browser\TestCase $browser->clickToolbarMenuItem('create'); } - $browser->withinFrame('#preferences-frame', function ($browser) { + $browser->withinFrame('#preferences-frame', static function ($browser) { $browser->waitFor('form') - ->with('form fieldset:nth-of-type(1)', function ($browser) { + ->with('form fieldset:nth-of-type(1)', static function ($browser) { $browser->assertSeeIn('legend', 'Settings') ->assertVisible('input[name=_name]') ->assertValue('input[name=_name]', '') @@ -81,7 +81,7 @@ class IdentitiesTest extends \Tests\Browser\TestCase ->assertCheckboxState('input[name=_standard]', false) ->assertSeeIn('label[for=rcmfd_standard]', 'Set default'); }) - ->with('form fieldset:nth-of-type(2)', function ($browser) { + ->with('form fieldset:nth-of-type(2)', static function ($browser) { $browser->assertSeeIn('legend', 'Signature') ->assertVisible('textarea[name=_signature]') ->assertValue('textarea[name=_signature]', ''); @@ -101,7 +101,7 @@ class IdentitiesTest extends \Tests\Browser\TestCase if ($browser->isPhone()) { $browser->assertVisible('#layout-content .header a.back-list-button') - ->whenAvailable('#layout-content .footer .buttons', function ($browser) { + ->whenAvailable('#layout-content .footer .buttons', static function ($browser) { $browser->click('a.button.submit'); }); } @@ -110,8 +110,8 @@ class IdentitiesTest extends \Tests\Browser\TestCase ->closeMessage('confirmation') ->waitFor('#preferences-frame'); - $browser->withinFrame('#preferences-frame', function ($browser) { - $browser->whenAvailable('form', function ($browser) { + $browser->withinFrame('#preferences-frame', static function ($browser) { + $browser->whenAvailable('form', static function ($browser) { $browser->assertValue('input[name=_name]', 'My Test') ->assertValue('input[name=_email]', 'mynew@identity.com') ->assertValue('input[name=_organization]', 'My Organization') @@ -131,7 +131,7 @@ class IdentitiesTest extends \Tests\Browser\TestCase } // Identities list - $browser->with('#identities-table', function ($browser) { + $browser->with('#identities-table', static function ($browser) { $browser->assertElementsCount('tbody tr', 2) ->assertSeeIn('tbody tr:nth-child(2)', 'My Test'); }); @@ -148,12 +148,12 @@ class IdentitiesTest extends \Tests\Browser\TestCase */ public function testIdentityDelete() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->click('#identities-table tbody tr:first-child') ->waitFor('#preferences-frame') ->clickToolbarMenuItem('delete'); - $browser->with(new Dialog(), function ($browser) { + $browser->with(new Dialog(), static function ($browser) { $browser->assertDialogTitle('Are you sure...') ->assertDialogContent('Do you really want to delete this identity?') ->assertButton('mainaction.delete', 'Delete') @@ -165,7 +165,7 @@ class IdentitiesTest extends \Tests\Browser\TestCase ->closeMessage('confirmation'); // Preview frame should reset to the watermark page - $browser->withinFrame('#preferences-frame', function ($browser) { + $browser->withinFrame('#preferences-frame', static function ($browser) { $browser->waitUntilMissing('> div'); }); @@ -187,13 +187,13 @@ class IdentitiesTest extends \Tests\Browser\TestCase */ public function testIdentityUpdate() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->click('#identities-table tbody tr:last-child') ->waitFor('#preferences-frame') ->waitUntilMissing('#messagestack div.loading'); - $browser->withinFrame('#preferences-frame', function ($browser) { - $browser->whenAvailable('form', function ($browser) { + $browser->withinFrame('#preferences-frame', static function ($browser) { + $browser->whenAvailable('form', static function ($browser) { $browser->type('[name=_name]', 'Default') ->type('[name=_organization]', 'Default Org'); }); @@ -204,7 +204,7 @@ class IdentitiesTest extends \Tests\Browser\TestCase }); if ($browser->isPhone()) { - $browser->whenAvailable('#layout-content .footer', function ($browser) { + $browser->whenAvailable('#layout-content .footer', static function ($browser) { $browser->assertVisible('a.button.prev.disabled') ->assertVisible('a.button.next.disabled') ->click('a.button.submit'); @@ -219,7 +219,7 @@ class IdentitiesTest extends \Tests\Browser\TestCase $browser->click('#layout-content .header a.back-list-button'); } - $browser->whenAvailable('#identities-table', function ($browser) { + $browser->whenAvailable('#identities-table', static function ($browser) { $browser->assertSeeIn('tbody tr:last-child', 'Default '); }); }); @@ -260,7 +260,7 @@ class IdentitiesTest extends \Tests\Browser\TestCase // Test "unsaved changes" dialog $browser->type('#compose-subject', 'subject') ->click('#compose_from a.edit') - ->with(new Dialog(), function ($browser) { + ->with(new Dialog(), static function ($browser) { $browser->assertDialogTitle('Are you sure...') ->assertDialogContent('The message has not been sent and has unsaved changes. Do you want to discard your changes?') ->assertButton('mainaction.discard', 'Discard') diff --git a/tests/Browser/Settings/Preferences/GeneralTest.php b/tests/Browser/Settings/Preferences/GeneralTest.php index 9e01ca25f..dff0ffcfb 100644 --- a/tests/Browser/Settings/Preferences/GeneralTest.php +++ b/tests/Browser/Settings/Preferences/GeneralTest.php @@ -39,7 +39,7 @@ class GeneralTest extends \Tests\Browser\TestCase } // check task and action - $browser->with(new App(), function ($browser) { + $browser->with(new App(), static function ($browser) { $browser->assertEnv('task', 'settings'); $browser->assertEnv('action', 'edit-prefs'); }); diff --git a/tests/Browser/Settings/Preferences/ServerTest.php b/tests/Browser/Settings/Preferences/ServerTest.php index 94eac04f6..d865c996f 100644 --- a/tests/Browser/Settings/Preferences/ServerTest.php +++ b/tests/Browser/Settings/Preferences/ServerTest.php @@ -30,7 +30,7 @@ class ServerTest extends \Tests\Browser\TestCase $browser->click('#sections-table tr.server'); if ($browser->isPhone()) { - $browser->whenAvailable('#layout-content .footer', function ($browser) { + $browser->whenAvailable('#layout-content .footer', static function ($browser) { $browser->assertVisible('a.button.submit:not(.disabled)') ->assertVisible('a.button.prev:not(.disabled)') ->assertVisible('a.button.next'); @@ -43,7 +43,7 @@ class ServerTest extends \Tests\Browser\TestCase } // check task and action - $browser->with(new App(), function ($browser) { + $browser->with(new App(), static function ($browser) { $browser->assertEnv('task', 'settings'); $browser->assertEnv('action', 'edit-prefs'); }); diff --git a/tests/Browser/Settings/PreferencesTest.php b/tests/Browser/Settings/PreferencesTest.php index 424e911bf..cb9a1272c 100644 --- a/tests/Browser/Settings/PreferencesTest.php +++ b/tests/Browser/Settings/PreferencesTest.php @@ -8,10 +8,10 @@ class PreferencesTest extends \Tests\Browser\TestCase { public function testPreferences() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('settings'); - $browser->with(new App(), function ($browser) { + $browser->with(new App(), static function ($browser) { $browser->assertObjects(['sectionslist']); }); @@ -24,7 +24,7 @@ class PreferencesTest extends \Tests\Browser\TestCase ->waitFor('#sections-table'); } // Preferences actions - $browser->with('#sections-table', function ($browser) { + $browser->with('#sections-table', static function ($browser) { $browser->assertSeeIn('tr.general', 'User Interface') ->assertSeeIn('tr.mailbox', 'Mailbox View') ->assertSeeIn('tr.mailview', 'Displaying Messages') diff --git a/tests/Browser/Settings/ResponsesTest.php b/tests/Browser/Settings/ResponsesTest.php index 15c460059..8f4b896dc 100644 --- a/tests/Browser/Settings/ResponsesTest.php +++ b/tests/Browser/Settings/ResponsesTest.php @@ -15,10 +15,10 @@ class ResponsesTest extends \Tests\Browser\TestCase public function testResponses() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('settings', 'responses'); - $browser->with(new App(), function ($browser) { + $browser->with(new App(), static function ($browser) { // check task and action $browser->assertEnv('task', 'settings'); $browser->assertEnv('action', 'responses'); @@ -54,7 +54,7 @@ class ResponsesTest extends \Tests\Browser\TestCase INSERT INTO responses (user_id, name, data, is_html) VALUES (1, 'response 2', '

test response 2

', '1'); "); - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('settings', 'responses'); if ($browser->isPhone()) { @@ -66,9 +66,9 @@ class ResponsesTest extends \Tests\Browser\TestCase $browser->clickToolbarMenuItem('create'); } - $browser->withinFrame('#preferences-frame', function ($browser) { + $browser->withinFrame('#preferences-frame', static function ($browser) { $browser->waitFor('form') - ->with('form', function ($browser) { + ->with('form', static function ($browser) { $browser->assertVisible('input[name=_name]') ->assertValue('input[name=_name]', '') ->assertSeeIn('label[for=ffname]', 'Name') @@ -93,9 +93,9 @@ class ResponsesTest extends \Tests\Browser\TestCase ->closeMessage('confirmation') ->waitFor('#preferences-frame'); - $browser->withinFrame('#preferences-frame', function ($browser) { + $browser->withinFrame('#preferences-frame', static function ($browser) { $browser->waitFor('form') - ->with('form', function ($browser) { + ->with('form', static function ($browser) { $browser->assertVisible('input[name=_name]') ->assertValue('input[name=_name]', 'Test') ->assertValue('textarea[name=_text]', 'Response Body'); @@ -108,7 +108,7 @@ class ResponsesTest extends \Tests\Browser\TestCase } // Responses list - $browser->with('#responses-table', function ($browser) { + $browser->with('#responses-table', static function ($browser) { $browser->assertElementsCount('tbody tr', 3) ->assertSeeIn('tbody tr:nth-child(3)', 'Test'); }); @@ -133,10 +133,10 @@ class ResponsesTest extends \Tests\Browser\TestCase */ public function testResponseDelete() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->clickToolbarMenuItem('delete'); - $browser->with(new Dialog(), function ($browser) { + $browser->with(new Dialog(), static function ($browser) { $browser->assertDialogTitle('Are you sure...') ->assertDialogContent('Do you really want to delete this response text?') ->assertButton('mainaction.delete', 'Delete') @@ -148,7 +148,7 @@ class ResponsesTest extends \Tests\Browser\TestCase ->closeMessage('confirmation'); // Preview frame should reset to the watermark page - $browser->withinFrame('#preferences-frame', function ($browser) { + $browser->withinFrame('#preferences-frame', static function ($browser) { $browser->waitUntilMissing('> div'); }); @@ -170,7 +170,7 @@ class ResponsesTest extends \Tests\Browser\TestCase */ public function testResponsesInComposer() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { if ($browser->isPhone()) { $browser->click('a.back-sidebar-button'); } @@ -179,9 +179,9 @@ class ResponsesTest extends \Tests\Browser\TestCase $browser->clickTaskMenuItem('compose') ->waitFor('#compose-content') ->clickToolbarMenuItem('responses', null, false) - ->with(new Popupmenu('responses-menu'), function ($browser) { + ->with(new Popupmenu('responses-menu'), static function ($browser) { $browser->assertMenuState(['edit.responses']) - ->with('#responseslist', function ($browser) { + ->with('#responseslist', static function ($browser) { $browser->assertElementsCount('li', 2) ->assertSeeIn('li:nth-child(1) a.insertresponse', 'response 1') ->assertSeeIn('li:nth-child(2) a.insertresponse', 'response 2'); @@ -216,12 +216,12 @@ class ResponsesTest extends \Tests\Browser\TestCase */ public function testResponseUpdate() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { // We're in mail compose, use responses menu to goto Settings > Responses $browser->clickToolbarMenuItem('responses', null, false) ->waitFor('#responses-menu') ->click('#responses-menu a.edit.responses') - ->with(new Dialog(), function ($browser) { + ->with(new Dialog(), static function ($browser) { $browser->assertDialogTitle('Are you sure...') ->assertDialogContent('The message has not been sent and has unsaved changes. Do you want to discard your changes?') ->assertButton('mainaction.discard', 'Discard') @@ -234,9 +234,9 @@ class ResponsesTest extends \Tests\Browser\TestCase ->click('#responses-table tbody tr:first-child') ->waitFor('#preferences-frame'); - $browser->withinFrame('#preferences-frame', function ($browser) { + $browser->withinFrame('#preferences-frame', static function ($browser) { $browser->waitFor('form') - ->with('form', function ($browser) { + ->with('form', static function ($browser) { $browser->assertValue('[name=_name]', 'response 1') ->assertValue('[name=_text]', 'test response 1') ->type('[name=_name]', 'Test 11') @@ -250,7 +250,7 @@ class ResponsesTest extends \Tests\Browser\TestCase if ($browser->isPhone()) { $browser->waitFor('#layout-content .footer') - ->with('#layout-content .footer', function ($browser) { + ->with('#layout-content .footer', static function ($browser) { $browser->assertVisible('a.button.prev.disabled') ->assertVisible('a.button.next:not(.disabled)') ->click('a.button.submit'); @@ -266,7 +266,7 @@ class ResponsesTest extends \Tests\Browser\TestCase } // Responses list - $browser->with('#responses-table', function ($browser) { + $browser->with('#responses-table', static function ($browser) { $browser->assertSeeIn('tbody tr:nth-child(1)', 'Test 11'); }); }); diff --git a/tests/Browser/Settings/SettingsTest.php b/tests/Browser/Settings/SettingsTest.php index 235389448..718e43e4e 100644 --- a/tests/Browser/Settings/SettingsTest.php +++ b/tests/Browser/Settings/SettingsTest.php @@ -8,18 +8,18 @@ class SettingsTest extends \Tests\Browser\TestCase { public function testSettings() { - $this->browse(function ($browser) { + $this->browse(static function ($browser) { $browser->go('settings'); // task should be set to 'settings' - $browser->with(new App(), function ($browser) { + $browser->with(new App(), static function ($browser) { $browser->assertEnv('task', 'settings'); }); $browser->assertSeeIn('#layout-sidebar .header', 'Settings'); // Sidebar menu - $browser->with('#settings-menu', function ($browser) { + $browser->with('#settings-menu', static function ($browser) { $browser->assertSeeIn('li.preferences', 'Preferences'); $browser->assertSeeIn('li.folders', 'Folders'); $browser->assertSeeIn('li.identities', 'Identities'); diff --git a/tests/Browser/TestCase.php b/tests/Browser/TestCase.php index 608c960dc..b12ca6a60 100644 --- a/tests/Browser/TestCase.php +++ b/tests/Browser/TestCase.php @@ -164,7 +164,7 @@ abstract class TestCase extends PHPUnitTestCase static::$phpProcess->setWorkingDirectory($path); static::$phpProcess->start(); - static::afterClass(function () { + static::afterClass(static function () { static::$phpProcess->stop(); }); } diff --git a/tests/Framework/PluginApi.php b/tests/Framework/PluginApi.php index 78603c55d..5170e7e81 100644 --- a/tests/Framework/PluginApi.php +++ b/tests/Framework/PluginApi.php @@ -28,7 +28,7 @@ class Framework_PluginApi extends PHPUnit\Framework\TestCase $api = rcube_plugin_api::get_instance(); $var = 0; - $hook_handler = function ($args) use (&$var) { $var++; }; + $hook_handler = static function ($args) use (&$var) { $var++; }; $api->register_hook('test', $hook_handler);