From a03233cebafc62ec7d88a24856b8a7b37fef4381 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Wed, 07 Oct 2015 03:14:18 -0400
Subject: [PATCH] CS fixes
---
program/lib/Roundcube/rcube_browser.php | 10 ++-
program/lib/Roundcube/rcube_addressbook.php | 19 +++---
program/lib/Roundcube/bootstrap.php | 31 ++++++----
program/lib/Roundcube/rcube_imap.php | 1
program/lib/Roundcube/rcube_mime.php | 12 ++--
program/lib/Roundcube/rcube_image.php | 12 ++--
program/lib/Roundcube/rcube_string_replacer.php | 4 +
program/lib/Roundcube/rcube_utils.php | 72 ++++++++++++-----------
8 files changed, 86 insertions(+), 75 deletions(-)
diff --git a/program/lib/Roundcube/bootstrap.php b/program/lib/Roundcube/bootstrap.php
index c173274..94e628b 100644
--- a/program/lib/Roundcube/bootstrap.php
+++ b/program/lib/Roundcube/bootstrap.php
@@ -138,7 +138,7 @@
/**
* Parse a human readable string for a number of bytes.
*
- * @param string $str Input string
+ * @param string $str Input string
*
* @return float Number of bytes
*/
@@ -188,7 +188,7 @@
/**
* Returns number of seconds for a specified offset string.
*
- * @param string $str String representation of the offset (e.g. 20min, 5h, 2days, 1week)
+ * @param string $str String representation of the offset (e.g. 20min, 5h, 2days, 1week)
*
* @return int Number of seconds
*/
@@ -220,12 +220,12 @@
/**
* Create a unix timestamp with a specified offset from now.
*
- * @param string $offset_str String representation of the offset (e.g. 20min, 5h, 2days)
- * @param int $factor Factor to multiply with the offset
+ * @param string $offset_str String representation of the offset (e.g. 20min, 5h, 2days)
+ * @param int $factor Factor to multiply with the offset
*
* @return int Unix timestamp
*/
-function get_offset_time($offset_str, $factor=1)
+function get_offset_time($offset_str, $factor = 1)
{
return time() + get_offset_sec($offset_str) * $factor;
}
@@ -241,7 +241,7 @@
*
* @return string Abbreviated string
*/
-function abbreviate_string($str, $maxlength, $placeholder='...', $ending=false)
+function abbreviate_string($str, $maxlength, $placeholder = '...', $ending = false)
{
$length = mb_strlen($str);
@@ -254,7 +254,9 @@
$first_part_length = floor(($maxlength - $placeholder_length)/2);
$second_starting_location = $length - $maxlength + $first_part_length + $placeholder_length;
- $str = mb_substr($str, 0, $first_part_length) . $placeholder . mb_substr($str, $second_starting_location);
+ $prefix = mb_substr($str, 0, $first_part_length);
+ $suffix = mb_substr($str, $second_starting_location);
+ $str = $prefix . $placeholder . $suffix;
}
return $str;
@@ -263,7 +265,7 @@
/**
* Get all keys from array (recursive).
*
- * @param array $array Input array
+ * @param array $array Input array
*
* @return array List of array keys
*/
@@ -309,8 +311,8 @@
/**
* Compose a valid representation of name and e-mail address
*
- * @param string $email E-mail address
- * @param string $name Person name
+ * @param string $email E-mail address
+ * @param string $name Person name
*
* @return string Formatted string
*/
@@ -364,7 +366,8 @@
return str_replace(
array('-stable', '-git'),
array('.0', '.99'),
- $version);
+ $version
+ );
}
/**
@@ -378,7 +381,7 @@
static $idn, $loaded;
if (!$loaded) {
- $idn = new Net_IDNA2();
+ $idn = new Net_IDNA2();
$loaded = true;
}
@@ -389,6 +392,7 @@
catch (Exception $e) {
}
}
+
return $domain;
}
}
@@ -400,7 +404,7 @@
static $idn, $loaded;
if (!$loaded) {
- $idn = new Net_IDNA2();
+ $idn = new Net_IDNA2();
$loaded = true;
}
@@ -411,6 +415,7 @@
catch (Exception $e) {
}
}
+
return $domain;
}
}
diff --git a/program/lib/Roundcube/rcube_addressbook.php b/program/lib/Roundcube/rcube_addressbook.php
index a08baf7..eb8bd3d 100644
--- a/program/lib/Roundcube/rcube_addressbook.php
+++ b/program/lib/Roundcube/rcube_addressbook.php
@@ -150,7 +150,7 @@
/**
* Setter for errors for internal use
*
- * @param int Error type (one of this class' error constants)
+ * @param int Error type (one of this class' error constants)
* @param string Error message (name of a text label)
*/
protected function set_error($type, $message)
@@ -167,8 +167,7 @@
/**
* Set internal list page
*
- * @param number Page number to list
- * @access public
+ * @param number Page number to list
*/
function set_page($page)
{
@@ -178,8 +177,7 @@
/**
* Set internal page size
*
- * @param number Number of messages to display on one page
- * @access public
+ * @param number Number of messages to display on one page
*/
function set_pagesize($size)
{
@@ -206,8 +204,9 @@
* Check the given data before saving.
* If input isn't valid, the message to display can be fetched using get_error()
*
- * @param array Assoziative array with data to save
+ * @param array Assoziative array with data to save
* @param boolean Attempt to fix/complete record automatically
+ *
* @return boolean True if input is valid, False if not.
*/
public function validate(&$save_data, $autofix = false)
@@ -296,10 +295,10 @@
/**
* Mark one or more contact records as deleted
*
- * @param array Record identifiers
- * @param bool Remove records irreversible (see self::undelete)
+ * @param array Record identifiers
+ * @param bool Remove records irreversible (see self::undelete)
*/
- function delete($ids, $force=true)
+ function delete($ids, $force = true)
{
/* empty for read-only address books */
}
@@ -307,7 +306,7 @@
/**
* Unmark delete flag on contact record(s)
*
- * @param array Record identifiers
+ * @param array Record identifiers
*/
function undelete($ids)
{
diff --git a/program/lib/Roundcube/rcube_browser.php b/program/lib/Roundcube/rcube_browser.php
index 3b51691..6b1448f 100644
--- a/program/lib/Roundcube/rcube_browser.php
+++ b/program/lib/Roundcube/rcube_browser.php
@@ -3,7 +3,7 @@
/**
+-----------------------------------------------------------------------+
| This file is part of the Roundcube Webmail client |
- | Copyright (C) 2007-2009, The Roundcube Dev Team |
+ | Copyright (C) 2007-2015, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
@@ -54,14 +54,16 @@
$this->ver = (float) $regs[1];
}
- if (preg_match('/ ([a-z]{2})-([a-z]{2})/', $HTTP_USER_AGENT, $regs))
+ if (preg_match('/ ([a-z]{2})-([a-z]{2})/', $HTTP_USER_AGENT, $regs)) {
$this->lang = $regs[1];
- else
+ }
+ else {
$this->lang = 'en';
+ }
$this->dom = $this->mz || $this->safari || ($this->ie && $this->ver>=5) || ($this->opera && $this->ver>=7);
$this->pngalpha = $this->mz || $this->safari || ($this->ie && $this->ver>=5.5) ||
- ($this->ie && $this->ver>=5 && $this->mac) || ($this->opera && $this->ver>=7) ? true : false;
+ ($this->ie && $this->ver>=5 && $this->mac) || ($this->opera && $this->ver>=7);
$this->imgdata = !$this->ie;
}
}
diff --git a/program/lib/Roundcube/rcube_image.php b/program/lib/Roundcube/rcube_image.php
index deaa470..b5eec5e 100644
--- a/program/lib/Roundcube/rcube_image.php
+++ b/program/lib/Roundcube/rcube_image.php
@@ -90,9 +90,9 @@
* Resize image to a given size. Use only to shrink an image.
* If an image is smaller than specified size it will be not resized.
*
- * @param int $size Max width/height size
- * @param string $filename Output filename
- * @param boolean $browser_compat Convert to image type displayable by any browser
+ * @param int $size Max width/height size
+ * @param string $filename Output filename
+ * @param boolean $browser_compat Convert to image type displayable by any browser
*
* @return mixed Output type on success, False on failure
*/
@@ -285,9 +285,9 @@
/**
* Convert image to a given type
*
- * @param int $type Destination file type (see class constants)
- * @param string $filename Output filename (if empty, original file will be used
- * and filename extension will be modified)
+ * @param int $type Destination file type (see class constants)
+ * @param string $filename Output filename (if empty, original file will be used
+ * and filename extension will be modified)
*
* @return bool True on success, False on failure
*/
diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php
index 8d45111..2940446 100644
--- a/program/lib/Roundcube/rcube_imap.php
+++ b/program/lib/Roundcube/rcube_imap.php
@@ -4353,7 +4353,6 @@
/**
* This is our own debug handler for the IMAP connection
- * @access public
*/
public function debug_handler(&$imap, $message)
{
diff --git a/program/lib/Roundcube/rcube_mime.php b/program/lib/Roundcube/rcube_mime.php
index 3e26e86..1954856 100644
--- a/program/lib/Roundcube/rcube_mime.php
+++ b/program/lib/Roundcube/rcube_mime.php
@@ -133,8 +133,8 @@
/**
* Decode a message header value
*
- * @param string $input Header value
- * @param string $fallback Fallback charset if none specified
+ * @param string $input Header value
+ * @param string $fallback Fallback charset if none specified
*
* @return string Decoded string
*/
@@ -290,7 +290,7 @@
}
/**
- * @access private
+ * E-mail address list parser
*/
private static function parse_address_list($str, $decode = true, $fallback = null)
{
@@ -671,9 +671,9 @@
/**
* A method to guess the mime_type of an attachment.
*
- * @param string $path Path to the file or file contents
- * @param string $name File name (with suffix)
- * @param string $failover Mime type supplied for failover
+ * @param string $path Path to the file or file contents
+ * @param string $name File name (with suffix)
+ * @param string $failover Mime type supplied for failover
* @param boolean $is_stream Set to True if $path contains file contents
* @param boolean $skip_suffix Set to True if the config/mimetypes.php mappig should be ignored
*
diff --git a/program/lib/Roundcube/rcube_string_replacer.php b/program/lib/Roundcube/rcube_string_replacer.php
index c106da0..eb281ee 100644
--- a/program/lib/Roundcube/rcube_string_replacer.php
+++ b/program/lib/Roundcube/rcube_string_replacer.php
@@ -58,7 +58,8 @@
/**
* Add a string to the internal list
*
- * @param string String value
+ * @param string String value
+ *
* @return int Index of value for retrieval
*/
public function add($str)
@@ -140,6 +141,7 @@
* Callback function used to build mailto: links around e-mail strings
*
* @param array Matches result from preg_replace_callback
+ *
* @return int Index of saved string value
*/
public function mailto_callback($matches)
diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php
index 103a374..07dc870 100644
--- a/program/lib/Roundcube/rcube_utils.php
+++ b/program/lib/Roundcube/rcube_utils.php
@@ -162,12 +162,12 @@
/**
* Replacing specials characters to a specific encoding type
*
- * @param string Input string
- * @param string Encoding type: text|html|xml|js|url
- * @param string Replace mode for tags: show|remove|strict
- * @param boolean Convert newlines
+ * @param string Input string
+ * @param string Encoding type: text|html|xml|js|url
+ * @param string Replace mode for tags: show|remove|strict
+ * @param boolean Convert newlines
*
- * @return string The quoted string
+ * @return string The quoted string
*/
public static function rep_specialchars_output($str, $enctype = '', $mode = '', $newlines = true)
{
@@ -253,16 +253,16 @@
* Read input value and convert it for internal use
* Performs stripslashes() and charset conversion if necessary
*
- * @param string Field name to read
- * @param int Source to get value from (GPC)
- * @param boolean Allow HTML tags in field value
- * @param string Charset to convert into
+ * @param string Field name to read
+ * @param int Source to get value from (GPC)
+ * @param boolean Allow HTML tags in field value
+ * @param string Charset to convert into
*
- * @return string Field value or NULL if not available
+ * @return string Field value or NULL if not available
*/
- public static function get_input_value($fname, $source, $allow_html=FALSE, $charset=NULL)
+ public static function get_input_value($fname, $source, $allow_html = false, $charset = null)
{
- $value = NULL;
+ $value = null;
if ($source == self::INPUT_GET) {
if (isset($_GET[$fname])) {
@@ -293,13 +293,13 @@
* Parse/validate input value. See self::get_input_value()
* Performs stripslashes() and charset conversion if necessary
*
- * @param string Input value
- * @param boolean Allow HTML tags in field value
- * @param string Charset to convert into
+ * @param string Input value
+ * @param boolean Allow HTML tags in field value
+ * @param string Charset to convert into
*
- * @return string Parsed value
+ * @return string Parsed value
*/
- public static function parse_input_value($value, $allow_html=FALSE, $charset=NULL)
+ public static function parse_input_value($value, $allow_html = false, $charset = null)
{
global $OUTPUT;
@@ -387,9 +387,9 @@
*
* @return string Modified CSS source
*/
- public static function mod_css_styles($source, $container_id, $allow_remote=false)
+ public static function mod_css_styles($source, $container_id, $allow_remote = false)
{
- $last_pos = 0;
+ $last_pos = 0;
$replacements = new rcube_string_replacer;
// ignore the whole block if evil styles are detected
@@ -457,8 +457,8 @@
/**
* Generate CSS classes from mimetype and filename extension
*
- * @param string $mimetype Mimetype
- * @param string $filename Filename
+ * @param string $mimetype Mimetype
+ * @param string $filename Filename
*
* @return string CSS classes separated by space
*/
@@ -544,7 +544,8 @@
}
if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO'])
&& strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https'
- && in_array($_SERVER['REMOTE_ADDR'], rcube::get_instance()->config->get('proxy_whitelist', array()))) {
+ && in_array($_SERVER['REMOTE_ADDR'], rcube::get_instance()->config->get('proxy_whitelist', array()))
+ ) {
return true;
}
if ($port && $_SERVER['SERVER_PORT'] == $port) {
@@ -581,7 +582,8 @@
$h = $_SESSION['storage_host'] ? $_SESSION['storage_host'] : $host;
// %z - IMAP domain without first part, e.g. %h=imap.domain.tld, %z=domain.tld
$z = preg_replace('/^[^\.]+\./', '', $h);
- // %s - domain name after the '@' from e-mail address provided at login screen. Returns FALSE if an invalid email is provided
+ // %s - domain name after the '@' from e-mail address provided at login screen.
+ // Returns FALSE if an invalid email is provided
if (strpos($name, '%s') !== false) {
$user_email = self::get_input_value('_user', self::INPUT_POST);
$user_email = self::idn_convert($user_email, true);
@@ -607,6 +609,7 @@
if (!empty($_SERVER['HTTP_X_REAL_IP'])) {
$remote_ip[] = 'X-Real-IP: ' . $_SERVER['HTTP_X_REAL_IP'];
}
+
// append the X-Forwarded-For header, if set
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$remote_ip[] = 'X-Forwarded-For: ' . $_SERVER['HTTP_X_FORWARDED_FOR'];
@@ -654,9 +657,9 @@
/**
* Read a specific HTTP request header.
*
- * @param string $name Header name
+ * @param string $name Header name
*
- * @return mixed Header value or null if not available
+ * @return mixed Header value or null if not available
*/
public static function request_header($name)
{
@@ -703,14 +706,14 @@
/**
* Improved equivalent to strtotime()
*
- * @param string $date Date string
- * @param object DateTimeZone to use for DateTime object
+ * @param string $date Date string
+ * @param DateTimeZone $timezone Timezone to use for DateTime object
*
* @return int Unix timestamp
*/
public static function strtotime($date, $timezone = null)
{
- $date = self::clean_datestr($date);
+ $date = self::clean_datestr($date);
$tzname = $timezone ? ' ' . $timezone->getName() : '';
// unix timestamp
@@ -735,14 +738,14 @@
/**
* Date parsing function that turns the given value into a DateTime object
*
- * @param string $date Date string
- * @param object DateTimeZone to use for DateTime object
+ * @param string $date Date string
+ * @param DateTimeZone $timezone Timezone to use for DateTime object
*
- * @return object DateTime instance or false on failure
+ * @return DateTime instance or false on failure
*/
public static function anytodatetime($date, $timezone = null)
{
- if (is_object($date) && is_a($date, 'DateTime')) {
+ if ($date instanceof DateTime) {
return $date;
}
@@ -887,7 +890,7 @@
* @param boolean True to return list of words as array
* @param integer Minimum length of tokens
*
- * @return mixed Normalized string or a list of normalized tokens
+ * @return mixed Normalized string or a list of normalized tokens
*/
public static function normalize_string($str, $as_array = false, $minlen = 2)
{
@@ -939,7 +942,8 @@
*
* @param string Haystack
* @param string Needle
- * @return boolen True if match, False otherwise
+ *
+ * @return boolean True if match, False otherwise
*/
public static function words_match($haystack, $needle)
{
--
Gitblit v1.9.1