Skip to content

Commit

Permalink
Modernize more basic CS II (#9254)
Browse files Browse the repository at this point in the history
* fix "integer_literal_case"

* fix "phpdoc_separation"

* fix "phpdoc_var_without_name"

* fix "operator_linebreak"

* fix "no_alias_language_construct_call"

* fix "list_syntax"

* fix "concat_space"

* fix "array_syntax"

* fix "binary_operator_spaces"

* fix "binary_operator_spaces" relaxed

* fix "phpdoc_types_order"

* fix "phpdoc_trim"

* fix "native_type_declaration_casing"

* fix "method_chaining_indentation"

* fix "phpdoc_no_package"

* fix "elseif"

* fix PHP CS Fixer config itself too

* fix "native_type_declaration_casing"
  • Loading branch information
mvorisek authored Dec 17, 2023
1 parent 77ae91f commit e7d7e62
Show file tree
Hide file tree
Showing 388 changed files with 2,024 additions and 2,471 deletions.
2 changes: 1 addition & 1 deletion .github/config-test.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
'archive',
'attachment_reminder',
'markasjunk',
'zipdownload'
'zipdownload',
];

$config['archive_mbox'] = 'Archive';
Expand Down
22 changes: 4 additions & 18 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

$finder = PhpCsFixer\Finder::create()
->in([__DIR__])
->exclude(['vendor'])
->ignoreDotFiles(false)
->name('*.php.dist')
->exclude(['vendor']);
->name('*.dist.php');

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
Expand Down Expand Up @@ -69,51 +71,35 @@
// TODO
'align_multiline_comment' => false,
'array_indentation' => false,
'array_syntax' => false,
'backtick_to_shell_exec' => false,
'binary_operator_spaces' => false,
'binary_operator_spaces' => ['default' => 'at_least_single_space'],
'blank_line_before_statement' => false,
'class_attributes_separation' => false,
'class_definition' => false,
'class_reference_name_casing' => false,
'class_reference_name_casing' => false,
'concat_space' => false,
'constant_case' => false,
'control_structure_continuation_position' => false,
'elseif' => false,
'empty_loop_condition' => false,
'explicit_indirect_variable' => false,
'explicit_string_variable' => false,
'function_declaration' => false,
'general_phpdoc_annotation_remove' => false,
'heredoc_indentation' => false,
'increment_style' => false,
'integer_literal_case' => false,
'list_syntax' => false,
'method_argument_space' => false,
'method_chaining_indentation' => false,
'modernize_types_casting' => false,
'native_constant_invocation' => false,
'native_type_declaration_casing' => false,
'new_with_parentheses' => false,
'no_alias_language_construct_call' => false,
'no_blank_lines_after_phpdoc' => false,
'no_break_comment' => false,
'no_empty_statement' => false,
'no_extra_blank_lines' => false,
'no_null_property_initialization' => false,
'no_unneeded_control_parentheses' => false,
'no_useless_concat_operator' => false,
'operator_linebreak' => false,
'php_unit_method_casing' => false,
'phpdoc_annotation_without_dot' => false,
'phpdoc_no_package' => false,
'phpdoc_separation' => false,
'phpdoc_summary' => false,
'phpdoc_to_comment' => false,
'phpdoc_trim' => false,
'phpdoc_types_order' => false,
'phpdoc_var_without_name' => false,
'single_line_comment_spacing' => false,
'single_quote' => false,
'single_trait_insert_per_statement' => false,
Expand Down
12 changes: 6 additions & 6 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
if (empty($_SESSION['user_id']) && ($force_https = $RCMAIL->config->get('force_https', false))) {
// force_https can be true, <hostname>, <hostname>:<port>, <port>
if (!is_bool($force_https)) {
list($host, $port) = explode(':', $force_https);
[$host, $port] = explode(':', $force_https);

if (is_numeric($host) && empty($port)) {
$port = $host;
Expand Down Expand Up @@ -194,14 +194,14 @@
}

// end session
else if ($RCMAIL->task == 'logout' && isset($_SESSION['user_id'])) {
elseif ($RCMAIL->task == 'logout' && isset($_SESSION['user_id'])) {
$RCMAIL->request_security_check(rcube_utils::INPUT_GET | rcube_utils::INPUT_POST);

$userdata = array(
$userdata = [
'user' => $_SESSION['username'],
'host' => $_SESSION['storage_host'],
'lang' => $RCMAIL->user->language,
);
];

$RCMAIL->output->show_message('loggedout');

Expand All @@ -211,7 +211,7 @@
}

// check session and auth cookie
else if ($RCMAIL->task != 'login' && $_SESSION['user_id']) {
elseif ($RCMAIL->task != 'login' && $_SESSION['user_id']) {
if (!$RCMAIL->session->check_auth()) {
$RCMAIL->kill_session();
$session_error = 'sessionerror';
Expand All @@ -236,7 +236,7 @@
// check if installer is still active
if ($RCMAIL->config->get('enable_installer') && is_readable('./installer/index.php')) {
$RCMAIL->output->add_footer(html::div(['id' => 'login-addon', 'style' => "background:#ef9398; border:2px solid #dc5757; padding:0.5em; margin:2em auto; width:50em"],
html::tag('h2', array('style' => "margin-top:0.2em"), "Installer script is still accessible") .
html::tag('h2', ['style' => "margin-top:0.2em"], "Installer script is still accessible") .
html::p(null, "The install script of your Roundcube installation is still stored in its default location!") .
html::p(null, "Please <b>remove</b> the whole <tt>installer</tt> folder from the Roundcube directory because
these files may expose sensitive configuration data like server passwords and encryption keys
Expand Down
6 changes: 3 additions & 3 deletions installer/check.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

if (!class_exists('rcmail_install', false) || !isset($RCI)) {
die("Not allowed! Please open installer/index.php instead.");
exit("Not allowed! Please open installer/index.php instead.");
}

$required_php_exts = [
Expand Down Expand Up @@ -220,7 +220,7 @@
$RCI->pass($var);
}
}
else if (filter_var($status, FILTER_VALIDATE_BOOLEAN) == $val) {
elseif (filter_var($status, FILTER_VALIDATE_BOOLEAN) == $val) {
$RCI->pass($var);
}
else {
Expand Down Expand Up @@ -260,7 +260,7 @@
$RCI->pass($var);
}
}
else if (filter_var($status, FILTER_VALIDATE_BOOLEAN) == $val) {
elseif (filter_var($status, FILTER_VALIDATE_BOOLEAN) == $val) {
$RCI->pass($var);
}
else {
Expand Down
14 changes: 7 additions & 7 deletions installer/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

if (!class_exists('rcmail_install', false) || !isset($RCI)) {
die("Not allowed! Please open installer/index.php instead.");
exit("Not allowed! Please open installer/index.php instead.");
}

// allow the current user to get to the next step
Expand All @@ -26,7 +26,7 @@

if ($RCI->save_configfile($_SESSION['config'])) {
echo '<p class="notice">The config file was saved successfully into'
. ' <tt>'.RCMAIL_CONFIG_DIR.'</tt> directory of your Roundcube installation.';
. ' <tt>' . RCMAIL_CONFIG_DIR . '</tt> directory of your Roundcube installation.';

if ($RCI->legacy_config) {
echo '<br/><br/>Afterwards, please <b>remove</b> the old configuration files'
Expand All @@ -47,7 +47,7 @@
}

echo '<p class="notice">Copy or download the following configuration and save it';
echo ' as <tt><b>config.inc.php</b></tt> within the <tt>'.RCUBE_CONFIG_DIR.'</tt> directory of your Roundcube installation.<br/>';
echo ' as <tt><b>config.inc.php</b></tt> within the <tt>' . RCUBE_CONFIG_DIR . '</tt> directory of your Roundcube installation.<br/>';
echo ' Make sure that there are no characters before the <tt>&lt;?php</tt> bracket when saving the file.';
echo '&nbsp;<input type="button" onclick="location.href=\'index.php?_getconfig=1\'" value="Download" />';
echo $save_button;
Expand Down Expand Up @@ -131,7 +131,7 @@
<?php

$check_ipcheck = new html_checkbox(['name' => '_ip_check', 'id' => 'cfgipcheck']);
echo $check_ipcheck->show(intval($RCI->getprop('ip_check')), array('value' => 1));
echo $check_ipcheck->show(intval($RCI->getprop('ip_check')), ['value' => 1]);

?>
<label for="cfgipcheck">Check client IP in session authorization</label><br />
Expand Down Expand Up @@ -326,7 +326,7 @@

$i = 0;
foreach ($default_hosts as $host) {
echo '<div id="defaulthostentry'.$i.'">' . $text_imaphost->show($host);
echo '<div id="defaulthostentry' . $i . '">' . $text_imaphost->show($host);
if ($i++ > 0) {
echo '<a href="#" onclick="removehostfield(this.parentNode);return false" class="removelink" title="Remove this entry">remove</a>';
}
Expand Down Expand Up @@ -626,11 +626,11 @@
<?php
$plugins = $RCI->list_plugins();
foreach ($plugins as $p) {
$p_check = new html_checkbox(['name' => '_plugins_'.$p['name'], 'id' => 'cfgplugin_'.$p['name'], 'value' => $p['name']]);
$p_check = new html_checkbox(['name' => '_plugins_' . $p['name'], 'id' => 'cfgplugin_' . $p['name'], 'value' => $p['name']]);
echo '<dt class="propname"><label>';
echo $p_check->show($p['enabled'] ? $p['name'] : 0);
echo '&nbsp;' . $p['name'] . '</label></dt><dd>';
echo '<label for="cfgplugin_'.$p['name'].'" class="hint">' . $p['desc'] . '</label><br/></dd>';
echo '<label for="cfgplugin_' . $p['name'] . '" class="hint">' . $p['desc'] . '</label><br/></dd>';
}

?>
Expand Down
12 changes: 6 additions & 6 deletions installer/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

ini_set('display_errors', 1);

define('INSTALL_PATH', realpath(__DIR__ . '/../').'/');
define('INSTALL_PATH', realpath(__DIR__ . '/../') . '/');

require INSTALL_PATH . 'program/include/iniset.php';

Expand All @@ -60,13 +60,13 @@

if (!empty($_SESSION['config'])) {
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="'.$filename.'"');
header('Content-Disposition: attachment; filename="' . $filename . '"');
echo $_SESSION['config'];
exit;
}

http_response_code(404);
die("The requested configuration was not found. Please run the installer from the beginning.");
exit("The requested configuration was not found. Please run the installer from the beginning.");
}

if (
Expand All @@ -77,7 +77,7 @@
$filename = 'config.inc.php';

header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="'.$filename.'"');
header('Content-Disposition: attachment; filename="' . $filename . '"');

$RCI->merge_config();
echo $RCI->create_config();
Expand Down Expand Up @@ -151,8 +151,8 @@

foreach (['Check environment', 'Create config', 'Test config'] as $i => $item) {
$j = $i + 1;
$link = ($RCI->step >= $j || $RCI->configured) ? '<a href="./index.php?_step='.$j.'">' . rcube::Q($item) . '</a>' : rcube::Q($item);
printf('<li class="step%d%s">%s</li>', $j+1, $RCI->step > $j ? ' passed' : ($RCI->step == $j ? ' current' : ''), $link);
$link = ($RCI->step >= $j || $RCI->configured) ? '<a href="./index.php?_step=' . $j . '">' . rcube::Q($item) . '</a>' : rcube::Q($item);
printf('<li class="step%d%s">%s</li>', $j + 1, $RCI->step > $j ? ' passed' : ($RCI->step == $j ? ' current' : ''), $link);
}
?>
</ol>
Expand Down
8 changes: 4 additions & 4 deletions installer/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

if (!class_exists('rcmail_install', false) || !isset($RCI)) {
die("Not allowed! Please open installer/index.php instead.");
exit("Not allowed! Please open installer/index.php instead.");
}

?>
Expand Down Expand Up @@ -160,7 +160,7 @@
Make sure that the configured database exists and that the user as write privileges</p>';
}
}
else if ($db_working && !empty($_POST['updatedb'])) {
elseif ($db_working && !empty($_POST['updatedb'])) {
if (!$RCI->update_db($_POST['version'])) {
echo '<p class="warning">Database schema update failed.</p>';
}
Expand All @@ -177,7 +177,7 @@

$db_working = false;
}
else if ($err = $RCI->db_schema_check($DB, $update = !empty($_POST['updatedb']))) {
elseif ($err = $RCI->db_schema_check($DB, $update = !empty($_POST['updatedb']))) {
$RCI->fail('DB Schema', "Database schema differs");
echo '<ul style="margin:0"><li>' . implode("</li>\n<li>", $err) . "</li></ul>";

Expand Down Expand Up @@ -208,7 +208,7 @@
// write test
$insert_id = md5(uniqid());
$db_write = $DB->query("INSERT INTO " . $DB->quote_identifier($RCI->config['db_prefix'] . 'session')
. " (`sess_id`, `changed`, `ip`, `vars`) VALUES (?, ".$DB->now().", '127.0.0.1', 'foo')", $insert_id);
. " (`sess_id`, `changed`, `ip`, `vars`) VALUES (?, " . $DB->now() . ", '127.0.0.1', 'foo')", $insert_id);

if ($db_write) {
$RCI->pass('DB Write');
Expand Down
24 changes: 12 additions & 12 deletions plugins/acl/acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ function acl_actions()
if ($action == 'save') {
$this->action_save();
}
else if ($action == 'delete') {
elseif ($action == 'delete') {
$this->action_delete();
}
else if ($action == 'list') {
elseif ($action == 'list') {
$this->action_list();
}

Expand Down Expand Up @@ -269,7 +269,7 @@ function templ_rights($attrib)
$id = "acl$val";
$ul .= html::tag('li', null,
$input->show('', ['name' => "acl[$val]", 'value' => $val, 'id' => $id])
. html::label(['for' => $id, 'title' => $this->gettext('longacl'.$val)], $this->gettext('acl'.$val))
. html::label(['for' => $id, 'title' => $this->gettext('longacl' . $val)], $this->gettext('acl' . $val))
);
}

Expand All @@ -282,7 +282,7 @@ function templ_rights($attrib)
'read' => 'lrs',
'write' => 'wi',
'delete' => $deleteright,
'other' => preg_replace('/[lrswi'.$deleteright.']/', '', implode('', $supported)),
'other' => preg_replace('/[lrswi' . $deleteright . ']/', '', implode('', $supported)),
];

// give plugins the opportunity to adjust this list
Expand All @@ -292,8 +292,8 @@ function templ_rights($attrib)

foreach ($data['rights'] as $key => $val) {
$id = "acl$key";
$title = !empty($data['titles'][$key]) ? $data['titles'][$key] : $this->gettext('longacl'.$key);
$label = !empty($data['labels'][$key]) ? $data['labels'][$key] : $this->gettext('acl'.$key);
$title = !empty($data['titles'][$key]) ? $data['titles'][$key] : $this->gettext('longacl' . $key);
$label = !empty($data['labels'][$key]) ? $data['labels'][$key] : $this->gettext('acl' . $key);
$ul .= html::tag('li', null,
$input->show('', ['name' => "acl[$val]", 'value' => $val, 'id' => $id])
. html::label(['for' => $id, 'title' => $title], $label)
Expand Down Expand Up @@ -415,7 +415,7 @@ private function list_rights($attrib = [])
'read' => 'lrs',
'write' => 'wi',
'delete' => $deleteright,
'other' => preg_replace('/[lrswi'.$deleteright.']/', '', implode('', $supported)),
'other' => preg_replace('/[lrswi' . $deleteright . ']/', '', implode('', $supported)),
];

// give plugins the opportunity to adjust this list
Expand Down Expand Up @@ -510,10 +510,10 @@ private function action_save()
if ($prefix && strpos($user, $prefix) === 0) {
$username = $user;
}
else if (!empty($this->specials) && in_array($user, $this->specials)) {
elseif (!empty($this->specials) && in_array($user, $this->specials)) {
$username = $this->gettext($user);
}
else if (!empty($user)) {
elseif (!empty($user)) {
if (!strpos($user, '@') && ($realm = $this->get_realm())) {
$user .= '@' . rcube_utils::idn_to_ascii(preg_replace('/^@/', '', $realm));
}
Expand Down Expand Up @@ -719,7 +719,7 @@ private function get_realm()
$self = $this->rc->get_user_name();

// find realm in username of logged user (?)
list($name, $domain) = rcube_utils::explode('@', $self);
[$name, $domain] = rcube_utils::explode('@', $self);

// Use (always existent) ACL entry on the INBOX for the user to determine
// whether or not the user ID in ACL entries need to be qualified and how
Expand Down Expand Up @@ -819,8 +819,8 @@ protected function mod_login($user)
$user = mb_strtolower($user);
}
// lowercase domain name
else if ($login_lc && strpos($user, '@')) {
list($local, $domain) = explode('@', $user);
elseif ($login_lc && strpos($user, '@')) {
[$local, $domain] = explode('@', $user);
$user = $local . '@' . mb_strtolower($domain);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* $config['additional_message_headers'] = ['User-Agent' => 'My-Very-Own-Webmail'];
*
* @author Ziba Scott
*
* @website http://roundcube.net
*/
class additional_message_headers extends rcube_plugin
Expand Down
Loading

0 comments on commit e7d7e62

Please sign in to comment.