CS
authorJan Schneider <jan@horde.org>
Mon, 15 Nov 2010 11:16:25 +0000 (12:16 +0100)
committerJan Schneider <jan@horde.org>
Mon, 15 Nov 2010 15:09:14 +0000 (16:09 +0100)
framework/Date/lib/Horde/Date.php
framework/Date/lib/Horde/Date/Recurrence.php
framework/Date/lib/Horde/Date/Repeater/Time.php
framework/Ldap/lib/Horde/Ldap/Entry.php
framework/Ldap/lib/Horde/Ldap/Filter.php
framework/Ldap/lib/Horde/Ldap/Ldif.php
framework/Ldap/lib/Horde/Ldap/Schema.php
framework/Ldap/lib/Horde/Ldap/Util.php

index d4e6635..147ec45 100644 (file)
@@ -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;
index c8f2939..04c9d2b 100644 (file)
@@ -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;
                 }
index b39537d..a90cd1f 100644 (file)
@@ -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);
     }
 
index dc7eeeb..75dda34 100644 (file)
@@ -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;
     }
index 4370ab6..f3666d6 100644 (file)
@@ -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');
         }
index d401755..3c1740d 100644 (file)
@@ -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;
index eb56f44..e715daa 100644 (file)
@@ -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.
index 5855bf7..4e17206 100644 (file)
@@ -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));