Skip to content

Commit

Permalink
Fix binary operator spaces CS (roundcube#9330)
Browse files Browse the repository at this point in the history
* align_single_space_minimal for assign

* assign operators grouping is not supported by PHP CS Fixer

* binary_operator_spaces = single_space

* fix anonymous function on single line

* align comments manually
  • Loading branch information
mvorisek authored Feb 2, 2024
1 parent 372c8bd commit d18406a
Show file tree
Hide file tree
Showing 365 changed files with 6,845 additions and 6,811 deletions.
1 change: 0 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@

// TODO
'array_indentation' => false,
'binary_operator_spaces' => ['default' => 'at_least_single_space'],
'general_phpdoc_annotation_remove' => false,
'method_argument_space' => ['on_multiline' => 'ignore'],
'modernize_types_casting' => false,
Expand Down
2 changes: 1 addition & 1 deletion bin/gc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require INSTALL_PATH . 'program/include/clisetup.php';

$rcmail = rcube::get_instance();

$session_driver = $rcmail->config->get('session_storage', 'db');
$session_driver = $rcmail->config->get('session_storage', 'db');
$session_lifetime = $rcmail->config->get('session_lifetime', 0) * 60 * 2;

// Clean expired SQL sessions
Expand Down
2 changes: 1 addition & 1 deletion bin/identity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function add_identity($options)

$new_identity['email'] = get_option_value($options, 'email', '', false, true, 'Enter the email e.g. -e somemail@example.com');
$new_identity['name'] = get_option_value($options, 'name', '', false, true, "Enter the name of an identity e.g. -n 'John Smith'");
$new_identity['organization'] = get_option_value($options, 'organization', '', false, false);
$new_identity['organization'] = get_option_value($options, 'organization', '', false, false);

$new_identity['html_signature'] = 0;
$new_identity['signature'] = get_option_value($options, 'plain_text_signature', '', false, false);
Expand Down
20 changes: 10 additions & 10 deletions bin/install-jsdeps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ if (empty($SOURCES['dependencies'])) {
rcube::raise_error("Failed to read dependencies list from {$cfgfile}", false, true);
}

$CURL = trim(shell_exec('which curl'));
$WGET = trim(shell_exec('which wget'));
$CURL = trim(shell_exec('which curl'));
$WGET = trim(shell_exec('which wget'));

if (($CACHEDIR = getenv('CACHEDIR')) && is_writable($CACHEDIR)) {
// use $CACHEDIR
Expand Down Expand Up @@ -126,7 +126,7 @@ function fetch_from_source($package, $useCache = true, &$filetype = null)

// Try Github API as a fallback (#6248)
if ($retval !== 0 && !empty($package['api_url'])) {
$url = str_replace('$v', $package['version'], $package['api_url']);
$url = str_replace('$v', $package['version'], $package['api_url']);
$header = 'Accept:application/vnd.github.v3.raw';

rcube::raise_error("Fetching failed. Using Github API on {$url}");
Expand All @@ -153,7 +153,7 @@ function extract_filetype($package, &$filetype = null)
{
global $CACHEDIR;

$filetype = pathinfo(preg_replace('/[?&].*$/', '', $package['url']), \PATHINFO_EXTENSION) ?: 'tmp';
$filetype = pathinfo(preg_replace('/[?&].*$/', '', $package['url']), \PATHINFO_EXTENSION) ?: 'tmp';
$cache_file = $CACHEDIR . '/' . $package['lib'] . '-' . $package['version'] . '.' . $filetype;

// Make sure it is a zip file
Expand Down Expand Up @@ -235,13 +235,13 @@ function extract_zipfile($package, $srcfile)
if (!empty($package['map'])) {
// get the root folder of the extracted package
$extract_tree = glob("{$extract}/*", \GLOB_ONLYDIR);
$sourcedir = count($extract_tree) ? $extract_tree[0] : $extract;
$sourcedir = count($extract_tree) ? $extract_tree[0] : $extract;

foreach ($package['map'] as $src => $dest) {
echo "Installing {$sourcedir}/{$src} into {$destdir}/{$dest}\n";

$dest_file = $destdir . '/' . $dest;
$src_file = $sourcedir . '/' . $src;
$src_file = $sourcedir . '/' . $src;

// make sure the destination's parent directory exists
if (strpos($dest, '/') !== false) {
Expand Down Expand Up @@ -317,13 +317,13 @@ $args = rcube_utils::get_opt([
'g' => 'get:bool',
'e' => 'extract:bool',
]) + [
'force' => false,
'delete' => false,
'get' => false,
'force' => false,
'delete' => false,
'get' => false,
'extract' => false,
];

$WHAT = $args[0] ?? null;
$WHAT = $args[0] ?? null;
$useCache = !$args['force'] && !$args['get'];

if (!$args['get'] && !$args['extract'] && !$args['delete']) {
Expand Down
6 changes: 3 additions & 3 deletions bin/installto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if (strtolower($input) == 'y') {

foreach ($dirs as $dir) {
// @FIXME: should we use --delete for all directories?
$delete = in_array($dir, ['program', 'vendor', 'installer']) ? '--delete ' : '';
$delete = in_array($dir, ['program', 'vendor', 'installer']) ? '--delete ' : '';
$command = 'rsync -aC --out-format=%n ' . $delete . INSTALL_PATH . "{$dir}/ {$target_dir}/{$dir}/";

if (system($command, $ret) === false || $ret > 0) {
Expand Down Expand Up @@ -120,8 +120,8 @@ if (strtolower($input) == 'y') {
}
// check if js-deps are up-to-date
elseif (file_exists("{$target_dir}/jsdeps.json") && file_exists("{$target_dir}/bin/install-jsdeps.sh")) {
$jsdeps = json_decode(file_get_contents("{$target_dir}/jsdeps.json"));
$package = $jsdeps->dependencies[0];
$jsdeps = json_decode(file_get_contents("{$target_dir}/jsdeps.json"));
$package = $jsdeps->dependencies[0];
$dest_file = $target_dir . '/' . $package->dest;

if (!file_exists($dest_file) || sha1_file($dest_file) !== $package->sha1) {
Expand Down
2 changes: 1 addition & 1 deletion bin/moduserprefs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ if (empty($_SERVER['argv'][1]) || $_SERVER['argv'][1] == 'help') {
exit;
}

$pref_name = trim($args[0]);
$pref_name = trim($args[0]);
$pref_value = !empty($args['delete']) ? null : trim($args[1]);

if ($pref_value === null) {
Expand Down
10 changes: 5 additions & 5 deletions bin/msgexport.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ $args['pass'] = rcube_utils::prompt_silent('Password: ');
// parse $host URL
$a_host = parse_url($args['host']);
if (!empty($a_host['host'])) {
$host = $a_host['host'];
$imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], ['ssl', 'imaps', 'tls'])) ? true : false;
$host = $a_host['host'];
$imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], ['ssl', 'imaps', 'tls'])) ? true : false;
$imap_port = $a_host['port'] ?? ($imap_ssl ? 993 : 143);
} else {
$host = $args['host'];
$host = $args['host'];
$imap_port = 143;
$imap_ssl = false;
$imap_ssl = false;
}

// instantiate IMAP class
Expand All @@ -123,7 +123,7 @@ $IMAP = new rcube_imap(null);
if ($IMAP->connect($host, $args['user'], $args['pass'], $imap_port, $imap_ssl)) {
vputs("IMAP login successful.\n");

$filename = null;
$filename = null;
$mailboxes = $args['mbox'] == '*' ? $IMAP->list_folders(null) : [$args['mbox']];

foreach ($mailboxes as $mbox) {
Expand Down
10 changes: 5 additions & 5 deletions bin/msgimport.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ if (empty($args['pass'])) {
// parse $host URL
$a_host = parse_url($args['host']);
if (!empty($a_host['host'])) {
$host = $a_host['host'];
$imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], ['ssl', 'imaps', 'tls'])) ? true : false;
$host = $a_host['host'];
$imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], ['ssl', 'imaps', 'tls'])) ? true : false;
$imap_port = $a_host['port'] ?? ($imap_ssl ? 993 : 143);
} else {
$host = $args['host'];
$host = $args['host'];
$imap_port = 143;
$imap_ssl = false;
$imap_ssl = false;
}

// instantiate IMAP class
Expand All @@ -76,7 +76,7 @@ if ($IMAP->connect($host, $args['user'], $args['pass'], $imap_port, $imap_ssl))
echo "IMAP login successful.\n";
echo "Uploading messages...\n";

$count = 0;
$count = 0;
$message = $lastline = '';

$fp = fopen($args['file'], 'r');
Expand Down
6 changes: 3 additions & 3 deletions bin/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ if ($RCI->configured) {

// update composer dependencies
if (is_file(INSTALL_PATH . 'composer.json') && is_readable(INSTALL_PATH . 'composer.json-dist')) {
$composer_data = json_decode(file_get_contents(INSTALL_PATH . 'composer.json'), true);
$composer_data = json_decode(file_get_contents(INSTALL_PATH . 'composer.json'), true);
$composer_template = json_decode(file_get_contents(INSTALL_PATH . 'composer.json-dist'), true);
$composer_json = null;
$composer_json = null;

// update the require section with the new dependencies
if (!empty($composer_data['require']) && !empty($composer_template['require'])) {
Expand Down Expand Up @@ -213,7 +213,7 @@ if ($RCI->configured) {
$rkey = repo_key($repo);
$existing = false;

foreach ($composer_data['repositories'] as $k => $_repo) {
foreach ($composer_data['repositories'] as $k => $_repo) {
if ($rkey == repo_key($_repo)) {
// switch to https://
if (isset($_repo['url']) && strpos($_repo['url'], 'http://') === 0) {
Expand Down
22 changes: 11 additions & 11 deletions bin/updatecss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ $opts = rcube_utils::get_opt(['d' => 'dir']);
if (empty($opts['dir'])) {
echo "Skin directory not specified (--dir). Using skins/ and plugins/*/skins/.\n";

$dir = INSTALL_PATH . 'skins';
$dir_p = INSTALL_PATH . 'plugins';
$skins = glob("{$dir}/*", \GLOB_ONLYDIR);
$dir = INSTALL_PATH . 'skins';
$dir_p = INSTALL_PATH . 'plugins';
$skins = glob("{$dir}/*", \GLOB_ONLYDIR);
$skins_p = glob("{$dir_p}/*/skins/*", \GLOB_ONLYDIR);

$dirs = array_merge($skins, $skins_p);
Expand All @@ -48,20 +48,20 @@ foreach ($dirs as $dir) {
continue;
}

$files = get_files($dir);
$images = get_images($img_dir);
$find = [];
$files = get_files($dir);
$images = get_images($img_dir);
$find = [];
$replace = [];

// build regexps array
foreach ($images as $path => $sum) {
$path_ex = str_replace('.', '\\.', $path);
$find[] = "#url\\(['\"]?images/{$path_ex}(\\?v=[a-f0-9-\\.]+)?['\"]?\\)#";
$path_ex = str_replace('.', '\\.', $path);
$find[] = "#url\\(['\"]?images/{$path_ex}(\\?v=[a-f0-9-\\.]+)?['\"]?\\)#";
$replace[] = "url(images/{$path}?v={$sum})";
}

foreach ($files as $file) {
$file = $dir . '/' . $file;
$file = $dir . '/' . $file;
echo "File: {$file}\n";
$content = file_get_contents($file);
$content = preg_replace($find, $replace, $content, -1, $count);
Expand All @@ -74,7 +74,7 @@ foreach ($dirs as $dir) {
function get_images($dir)
{
$images = [];
$dh = opendir($dir);
$dh = opendir($dir);

while ($file = readdir($dh)) {
if (preg_match('/^(.+)\.(gif|ico|png|jpg|jpeg)$/', $file, $m)) {
Expand All @@ -96,7 +96,7 @@ function get_images($dir)
function get_files($dir)
{
$files = [];
$dh = opendir($dir);
$dh = opendir($dir);

while ($file = readdir($dh)) {
if (preg_match('/^(.+)\.(css|html)$/', $file, $m)) {
Expand Down
28 changes: 14 additions & 14 deletions config/defaults.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@
// Note: These can be used also to overwrite server's namespaces
// Note: Set these to FALSE to disable access to specified namespace
$config['imap_ns_personal'] = null;
$config['imap_ns_other'] = null;
$config['imap_ns_shared'] = null;
$config['imap_ns_other'] = null;
$config['imap_ns_shared'] = null;

// By default IMAP capabilities are read after connection to IMAP server
// In some cases, e.g. when using IMAP proxy, there's a need to refresh the list
Expand Down Expand Up @@ -1526,19 +1526,19 @@
// Note: At minimum the font name set in default_font must be present in this array
// Setting a single value will hide the font select box in the interface
$config['available_fonts'] = [
'Andale Mono' => '"Andale Mono",Times,monospace',
'Arial' => 'Arial,Helvetica,sans-serif',
'Arial Black' => '"Arial Black","Avant Garde",sans-serif',
'Book Antiqua' => '"Book Antiqua",Palatino,serif',
'Courier New' => '"Courier New",Courier,monospace',
'Georgia' => 'Georgia,Palatino,serif',
'Helvetica' => 'Helvetica,Arial,sans-serif',
'Impact' => 'Impact,Chicago,sans-serif',
'Tahoma' => 'Tahoma,Arial,Helvetica,sans-serif',
'Terminal' => 'Terminal,Monaco,monospace',
'Andale Mono' => '"Andale Mono",Times,monospace',
'Arial' => 'Arial,Helvetica,sans-serif',
'Arial Black' => '"Arial Black","Avant Garde",sans-serif',
'Book Antiqua' => '"Book Antiqua",Palatino,serif',
'Courier New' => '"Courier New",Courier,monospace',
'Georgia' => 'Georgia,Palatino,serif',
'Helvetica' => 'Helvetica,Arial,sans-serif',
'Impact' => 'Impact,Chicago,sans-serif',
'Tahoma' => 'Tahoma,Arial,Helvetica,sans-serif',
'Terminal' => 'Terminal,Monaco,monospace',
'Times New Roman' => '"Times New Roman",Times,serif',
'Trebuchet MS' => '"Trebuchet MS",Geneva,sans-serif',
'Verdana' => 'Verdana,Geneva,sans-serif',
'Trebuchet MS' => '"Trebuchet MS",Geneva,sans-serif',
'Verdana' => 'Verdana,Geneva,sans-serif',
];

// Default font size for composed HTML message
Expand Down
2 changes: 1 addition & 1 deletion config/mimetypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'xps' => 'application/vnd.ms-xpsdocument',
'rar' => 'application/x-rar-compressed',
'7z' => 'application/x-7z-compressed',
'7z' => 'application/x-7z-compressed',
's7z' => 'application/x-7z-compressed',
'vcf' => 'text/vcard',
'ics' => 'text/calendar',
Expand Down
20 changes: 10 additions & 10 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,17 @@
// try to log in
if ($RCMAIL->task == 'login' && $RCMAIL->action == 'login') {
$request_valid = !empty($_SESSION['temp']) && $RCMAIL->check_request();
$pass_charset = $RCMAIL->config->get('password_charset', 'UTF-8');
$pass_charset = $RCMAIL->config->get('password_charset', 'UTF-8');

// purge the session in case of new login when a session already exists
if ($request_valid) {
$RCMAIL->kill_session();
}

$auth = $RCMAIL->plugins->exec_hook('authenticate', [
'host' => $RCMAIL->autoselect_host(),
'user' => trim(rcube_utils::get_input_string('_user', rcube_utils::INPUT_POST)),
'pass' => rcube_utils::get_input_string('_pass', rcube_utils::INPUT_POST, true, $pass_charset),
'host' => $RCMAIL->autoselect_host(),
'user' => trim(rcube_utils::get_input_string('_user', rcube_utils::INPUT_POST)),
'pass' => rcube_utils::get_input_string('_pass', rcube_utils::INPUT_POST, true, $pass_charset),
'valid' => $request_valid,
'error' => null,
'cookiecheck' => true,
Expand Down Expand Up @@ -160,11 +160,11 @@
}

$error_labels = [
rcmail::ERROR_STORAGE => 'storageerror',
rcmail::ERROR_STORAGE => 'storageerror',
rcmail::ERROR_COOKIES_DISABLED => 'cookiesdisabled',
rcmail::ERROR_INVALID_REQUEST => 'invalidrequest',
rcmail::ERROR_INVALID_HOST => 'invalidhost',
rcmail::ERROR_RATE_LIMIT => 'accountlocked',
rcmail::ERROR_INVALID_REQUEST => 'invalidrequest',
rcmail::ERROR_INVALID_HOST => 'invalidhost',
rcmail::ERROR_RATE_LIMIT => 'accountlocked',
];

if (!empty($auth['error']) && !is_numeric($auth['error'])) {
Expand Down Expand Up @@ -242,8 +242,8 @@
}

$plugin = $RCMAIL->plugins->exec_hook('unauthenticated', [
'task' => 'login',
'error' => $session_error,
'task' => 'login',
'error' => $session_error,
// Return 401 only on failed logins (#7010)
'http_code' => empty($session_error) && !empty($error_message) ? 401 : 200,
]);
Expand Down
Loading

0 comments on commit d18406a

Please sign in to comment.