From a205186488e2ef9b9f7c8d2f58d810d37c24f058 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Mon, 15 Nov 2010 12:16:25 +0100 Subject: [PATCH] CS --- framework/Date/lib/Horde/Date.php | 8 ++++--- framework/Date/lib/Horde/Date/Recurrence.php | 30 ++++++++++++------------ framework/Date/lib/Horde/Date/Repeater/Time.php | 4 +++- framework/Ldap/lib/Horde/Ldap/Entry.php | 2 +- framework/Ldap/lib/Horde/Ldap/Filter.php | 31 ++++++++++++++----------- framework/Ldap/lib/Horde/Ldap/Ldif.php | 2 +- framework/Ldap/lib/Horde/Ldap/Schema.php | 2 +- framework/Ldap/lib/Horde/Ldap/Util.php | 2 +- 8 files changed, 44 insertions(+), 37 deletions(-) diff --git a/framework/Date/lib/Horde/Date.php b/framework/Date/lib/Horde/Date.php index d4e6635a8..147ec45ea 100644 --- a/framework/Date/lib/Horde/Date.php +++ b/framework/Date/lib/Horde/Date.php @@ -188,7 +188,9 @@ class Horde_Date { if (!self::$_supportedSpecs) { self::$_supportedSpecs = self::$_defaultSpecs; - if (function_exists('nl_langinfo')) { self::$_supportedSpecs .= 'bBpxX'; } + if (function_exists('nl_langinfo')) { + self::$_supportedSpecs .= 'bBpxX'; + } } if (func_num_args() > 2) { @@ -310,7 +312,7 @@ class Horde_Date public function toDays() { if (function_exists('GregorianToJD')) { - return GregorianToJD($this->_month, $this->_mday, $this->_year); + return gregoriantojd($this->_month, $this->_mday, $this->_year); } $day = $this->_mday; @@ -617,7 +619,7 @@ class Horde_Date $this->_mday = 1; $first = $this->dayOfWeek(); - if ($weekday < $first) { + if ($weekday < $first) { $this->_mday = 8 + $weekday - $first; } else { $this->_mday = $weekday - $first + 1; diff --git a/framework/Date/lib/Horde/Date/Recurrence.php b/framework/Date/lib/Horde/Date/Recurrence.php index c8f293924..04c9d2b68 100644 --- a/framework/Date/lib/Horde/Date/Recurrence.php +++ b/framework/Date/lib/Horde/Date/Recurrence.php @@ -56,28 +56,28 @@ class Horde_Date_Recurrence * * @var Horde_Date */ - var $start; + public $start; /** * The end date of the recurrence interval. * * @var Horde_Date */ - var $recurEnd = null; + public $recurEnd = null; /** * The number of recurrences. * * @var integer */ - var $recurCount = null; + public $recurCount = null; /** * The type of recurrence this event follows. RECUR_* constant. * * @var integer */ - var $recurType = self::RECUR_NONE; + public $recurType = self::RECUR_NONE; /** * The length of time between recurrences. The time unit depends on the @@ -85,28 +85,28 @@ class Horde_Date_Recurrence * * @var integer */ - var $recurInterval = 1; + public $recurInterval = 1; /** * Any additional recurrence data. * * @var integer */ - var $recurData = null; + public $recurData = null; /** * All the exceptions from recurrence for this event. * * @var array */ - var $exceptions = array(); + public $exceptions = array(); /** * All the dates this recurrence has been marked as completed. * * @var array */ - var $completions = array(); + public $completions = array(); /** * Constructor. @@ -976,7 +976,7 @@ class Horde_Date_Recurrence $rrule = 'W' . $this->recurInterval; $vcaldays = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'); - for ($i = 0; $i <= 7 ; ++$i) { + for ($i = 0; $i <= 7; ++$i) { if ($this->recurOnDay(pow(2, $i))) { $rrule .= ' ' . $vcaldays[$i]; } @@ -1142,7 +1142,7 @@ class Horde_Date_Recurrence $rrule = 'FREQ=WEEKLY;INTERVAL=' . $this->recurInterval . ';BYDAY='; $vcaldays = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'); - for ($i = $flag = 0; $i <= 7 ; ++$i) { + for ($i = $flag = 0; $i <= 7; ++$i) { if ($this->recurOnDay(pow(2, $i))) { if ($flag) { $rrule .= ','; @@ -1218,7 +1218,7 @@ class Horde_Date_Recurrence return false; } - $this->setRecurInterval((int) $hash['interval']); + $this->setRecurInterval((int)$hash['interval']); $parse_day = false; $set_daymask = false; @@ -1252,7 +1252,7 @@ class Horde_Date_Recurrence case 'weekday': $this->setRecurType(self::RECUR_MONTHLY_WEEKDAY); - $nth_weekday = (int) $hash['daynumber']; + $nth_weekday = (int)$hash['daynumber']; $hash['daynumber'] = 1; $parse_day = true; $update_daynumber = true; @@ -1294,7 +1294,7 @@ class Horde_Date_Recurrence } $this->setRecurType(self::RECUR_YEARLY_WEEKDAY); - $nth_weekday = (int) $hash['daynumber']; + $nth_weekday = (int)$hash['daynumber']; $hash['daynumber'] = 1; $parse_day = true; $update_month = true; @@ -1311,7 +1311,7 @@ class Horde_Date_Recurrence return false; } - $this->setRecurCount((int) $hash['range']); + $this->setRecurCount((int)$hash['range']); break; case 'date': @@ -1469,7 +1469,7 @@ class Horde_Date_Recurrence 'sunday' => Horde_Date::MASK_SUNDAY, ); $days = array(); - foreach($bits as $name => $bit) { + foreach ($bits as $name => $bit) { if ($this->recurOnDay($bit)) { $days[] = $name; } diff --git a/framework/Date/lib/Horde/Date/Repeater/Time.php b/framework/Date/lib/Horde/Date/Repeater/Time.php index b39537d20..a90cd1f7f 100644 --- a/framework/Date/lib/Horde/Date/Repeater/Time.php +++ b/framework/Date/lib/Horde/Date/Repeater/Time.php @@ -119,7 +119,9 @@ class Horde_Date_Repeater_Time extends Horde_Date_Repeater { parent::this($context); - if ($context == 'none') { $context = 'future'; } + if ($context == 'none') { + $context = 'future'; + } return $this->next($context); } diff --git a/framework/Ldap/lib/Horde/Ldap/Entry.php b/framework/Ldap/lib/Horde/Ldap/Entry.php index dc7eeeb74..75dda34be 100644 --- a/framework/Ldap/lib/Horde/Ldap/Entry.php +++ b/framework/Ldap/lib/Horde/Ldap/Entry.php @@ -215,7 +215,7 @@ class Horde_Ldap_Entry */ public static function createExisting($dn, array $attrs = array()) { - $entry = Horde_Ldap_Entry::createFresh($dn, $attrs); + $entry = self::createFresh($dn, $attrs); $entry->markAsNew(false); return $entry; } diff --git a/framework/Ldap/lib/Horde/Ldap/Filter.php b/framework/Ldap/lib/Horde/Ldap/Filter.php index 4370ab619..f3666d6e3 100644 --- a/framework/Ldap/lib/Horde/Ldap/Filter.php +++ b/framework/Ldap/lib/Horde/Ldap/Filter.php @@ -209,9 +209,15 @@ class Horde_Ldap_Filter { // Substitute named operators with logical operators. switch ($operator) { - case 'and': $operator = '&'; break; - case 'or': $operator = '|'; break; - case 'not': $operator = '!'; break; + case 'and': + $operator = '&'; + break; + case 'or': + $operator = '|'; + break; + case 'not': + $operator = '!'; + break; } // Tests for sane operation. @@ -235,7 +241,7 @@ class Horde_Ldap_Filter if (!is_array($filters) || count($filters) < 2) { throw new Horde_Ldap_Exception('Parameter $filters is not an array or contains less than two Horde_Ldap_Filter objects'); } - break; + break; default: throw new Horde_Ldap_Exception('Logical operator is unknown'); @@ -274,19 +280,19 @@ class Horde_Ldap_Filter public static function build(array $params, $operator = 'and') { if (!empty($params['filter'])) { - return Horde_Ldap_Filter::parse($params['filter']); + return self::parse($params['filter']); } if (!is_array($params['objectclass'])) { - return Horde_Ldap_Filter::create('objectclass', 'equals', $params['objectclass']); + return self::create('objectclass', 'equals', $params['objectclass']); } $filters = array(); foreach ($params['objectclass'] as $objectclass) { - $filters[] = Horde_Ldap_Filter::create('objectclass', 'equals', $objectclass); + $filters[] = self::create('objectclass', 'equals', $objectclass); } if (count($filters) == 1) { return $filters[0]; } - return Horde_Ldap_Filter::combine($operator, $filters); + return self::combine($operator, $filters); } /** @@ -342,7 +348,7 @@ class Horde_Ldap_Filter // Denotes the current bracket level we are, >1 is too deep, 1 is ok, 0 // is outside any subcomponent. $level = 0; - for ($curpos = 0; $curpos < strlen($filter); $curpos++) { + for ($curpos = 0, $len = strlen($filter); $curpos < $len; $curpos++) { $cur_char = $filter{$curpos}; // Rise/lower bracket level. @@ -370,15 +376,12 @@ class Horde_Ldap_Filter $oldpos = $s_pos; } - // Some error checking... - if (count($subfilters) == 1) { - // Only one subfilter found. - } elseif (count($subfilters) > 1) { + if (count($subfilters) > 1) { // Several subfilters found. if ($operator == '!') { throw new Horde_Ldap_Exception('Invalid filter syntax: NOT operator detected but several arguments given'); } - } else { + } elseif (!count($subfilters)) { // This should not happen unless the user specified a wrong filter. throw new Horde_Ldap_Exception('Invalid filter syntax: got operator ' . $operator . ' but no argument'); } diff --git a/framework/Ldap/lib/Horde/Ldap/Ldif.php b/framework/Ldap/lib/Horde/Ldap/Ldif.php index d40175583..3c1740dee 100644 --- a/framework/Ldap/lib/Horde/Ldap/Ldif.php +++ b/framework/Ldap/lib/Horde/Ldap/Ldif.php @@ -737,7 +737,7 @@ class Horde_Ldap_Ldif } // Test for illegal content char. - for ($i = 0; $i < strlen($value); $i++) { + for ($i = 0, $len = strlen($value); $i < $len; $i++) { $char_ord = ord(substr($value, $i, 1)); if ($char_ord >= 127 || in_array($char_ord, $unsafe)) { $binary = true; diff --git a/framework/Ldap/lib/Horde/Ldap/Schema.php b/framework/Ldap/lib/Horde/Ldap/Schema.php index eb56f444b..e715daa9b 100644 --- a/framework/Ldap/lib/Horde/Ldap/Schema.php +++ b/framework/Ldap/lib/Horde/Ldap/Schema.php @@ -398,7 +398,7 @@ class Horde_Ldap_Schema $tokens = array(); // Number of tokens (full pattern match). - for ($i = 0; $i < count($matches[0]); $i++) { + for ($i = 0, $c = count($matches[0]); $i < $c; $i++) { // Each subpattern. for ($j = 1; $j < 4; $j++) { // Pattern match in this subpattern. diff --git a/framework/Ldap/lib/Horde/Ldap/Util.php b/framework/Ldap/lib/Horde/Ldap/Util.php index 5855bf75f..4e172063e 100644 --- a/framework/Ldap/lib/Horde/Ldap/Util.php +++ b/framework/Ldap/lib/Horde/Ldap/Util.php @@ -475,7 +475,7 @@ class Horde_Ldap_Util */ public static function asc2hex32($string) { - for ($i = 0; $i < strlen($string); $i++) { + for ($i = 0, $len = strlen($string); $i < $len; $i++) { $char = substr($string, $i, 1); if (ord($char) < 32) { $hex = dechex(ord($char)); -- 2.11.0