Completed
Pull Request — developer (#4001)
by Thom
542:26 queued 508:45
created
include/utils/ConfigReader.php 2 patches
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,8 +37,9 @@  discard block
 block discarded – undo
37 37
 
38 38
 	public function setConfig($key, $value)
39 39
 	{
40
-		if (empty($key))
41
-			return;
40
+		if (empty($key)) {
41
+					return;
42
+		}
42 43
 		$this->properties[$key] = $value;
43 44
 		//not neccessary for php5.x versions
44 45
 		self::$propertiesCache[$this->name] = $this->properties;
@@ -46,8 +47,9 @@  discard block
 block discarded – undo
46 47
 
47 48
 	public function getConfig($key)
48 49
 	{
49
-		if (empty($key))
50
-			return '';
50
+		if (empty($key)) {
51
+					return '';
52
+		}
51 53
 		return $this->properties[$key];
52 54
 	}
53 55
 }
Please login to merge, or discard this patch.
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -15,6 +15,10 @@  discard block
 block discarded – undo
15 15
 	protected $name;
16 16
 	static $propertiesCache = [];
17 17
 
18
+	/**
19
+	 * @param string $path
20
+	 * @param string $name
21
+	 */
18 22
 	public function __construct($path, $name, $force = false)
19 23
 	{
20 24
 		$this->load($path, $name, $force);
@@ -41,6 +45,9 @@  discard block
 block discarded – undo
41 45
 		self::$propertiesCache[$this->name] = $this->properties;
42 46
 	}
43 47
 
48
+	/**
49
+	 * @param string $key
50
+	 */
44 51
 	public function getConfig($key)
45 52
 	{
46 53
 		if (empty($key))
Please login to merge, or discard this patch.
include/utils/ExportUtils.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,8 +28,9 @@
 block discarded – undo
28 28
 	$blockid_list = '(';
29 29
 	for ($i = 0; $i < $noofrows; $i++) {
30 30
 		$blockid = $adb->query_result($result, $i, "blockid");
31
-		if ($i != 0)
32
-			$blockid_list .= ', ';
31
+		if ($i != 0) {
32
+					$blockid_list .= ', ';
33
+		}
33 34
 		$blockid_list .= $blockid;
34 35
 		$block_label[$blockid] = $adb->query_result($result, $i, "blocklabel");
35 36
 	}
Please login to merge, or discard this patch.
include/utils/utils.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1401,7 +1401,7 @@
 block discarded – undo
1401 1401
 function isRecordExists($recordId, $cache = true)
1402 1402
 {
1403 1403
 	$recordMetaData = vtlib\Functions::getCRMRecordMetadata($recordId);
1404
-	return (isset($recordMetaData) && $recordMetaData['deleted'] == 0 ) ? true : false;
1404
+	return (isset($recordMetaData) && $recordMetaData['deleted'] == 0) ? true : false;
1405 1405
 }
1406 1406
 
1407 1407
 /** Function to set date values compatible to database (YY_MM_DD)
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -367,6 +367,7 @@  discard block
 block discarded – undo
367 367
 
368 368
 /**
369 369
  * Function to find the UI type of a field based on the uitype id
370
+ * @param string $reqtype
370 371
  */
371 372
 function is_uitype($uitype, $reqtype)
372 373
 {
@@ -752,6 +753,8 @@  discard block
 block discarded – undo
752 753
 
753 754
 /**
754 755
  * Function to get the approximate difference between two date time values as string
756
+ * @param integer $d1
757
+ * @param integer $d2
755 758
  */
756 759
 function dateDiffAsString($d1, $d2)
757 760
 {
Please login to merge, or discard this patch.
Braces   +35 added lines, -25 removed lines patch added patch discarded remove patch
@@ -289,13 +289,15 @@  discard block
 block discarded – undo
289 289
 		while (($i--) > 0) {
290 290
 			if ($data != ($a = $data % ($p = pow(64, $i)))) {
291 291
 				$ret = chr(base_convert(str_pad(str_repeat(1, $i + 1), 8, "0"), 2, 10) + (($data - $a) / $p));
292
-				for ($i; $i > 0; $i--)
293
-					$ret .= chr(128 + ((($data % pow(64, $i)) - ($data % ($p = pow(64, $i - 1)))) / $p));
292
+				for ($i; $i > 0; $i--) {
293
+									$ret .= chr(128 + ((($data % pow(64, $i)) - ($data % ($p = pow(64, $i - 1)))) / $p));
294
+				}
294 295
 				break;
295 296
 			}
296 297
 		}
297
-	} else
298
-		$ret = "&#$data;";
298
+	} else {
299
+			$ret = "&#$data;";
300
+	}
299 301
 	return $ret;
300 302
 }
301 303
 
@@ -344,8 +346,9 @@  discard block
 block discarded – undo
344 346
  */
345 347
 function escape_single_quotes($value)
346 348
 {
347
-	if (isset($value))
348
-		$value = str_replace("'", "\'", $value);
349
+	if (isset($value)) {
350
+			$value = str_replace("'", "\'", $value);
351
+	}
349 352
 	return $value;
350 353
 }
351 354
 
@@ -366,10 +369,11 @@  discard block
 block discarded – undo
366 369
 			$str = str_replace('_', '\_', $str);
367 370
 			if ($flag == 0) {
368 371
 				// If value what to search is null then we should not add % which will fail
369
-				if (empty($str))
370
-					$str = '' . $str . '';
371
-				else
372
-					$str = '%' . $str . '%';
372
+				if (empty($str)) {
373
+									$str = '' . $str . '';
374
+				} else {
375
+									$str = '%' . $str . '%';
376
+				}
373 377
 			} elseif ($flag == 1) {
374 378
 				$str = '%' . $str;
375 379
 			} elseif ($flag == 2) {
@@ -402,8 +406,9 @@  discard block
 block discarded – undo
402 406
 
403 407
 		$ret_str .= " ifnull($tbl_name.$col_name,'null') = ifnull(temp.$col_name,'null')";
404 408
 
405
-		if (count($field_array) != $i)
406
-			$ret_str .= " and ";
409
+		if (count($field_array) != $i) {
410
+					$ret_str .= " and ";
411
+		}
407 412
 		$i++;
408 413
 	}
409 414
 	return $ret_str;
@@ -430,8 +435,9 @@  discard block
 block discarded – undo
430 435
 	foreach ($name as $module) {
431 436
 		$focus = CRMEntity::getInstance($module);
432 437
 		$query = $focus->buildSearchQueryForFieldTypes(11, $number);
433
-		if (empty($query))
434
-			return;
438
+		if (empty($query)) {
439
+					return;
440
+		}
435 441
 
436 442
 		$result = $adb->pquery($query, []);
437 443
 		if ($adb->num_rows($result) > 0) {
@@ -556,8 +562,9 @@  discard block
 block discarded – undo
556 562
 function relateEntities($focus, $sourceModule, $sourceRecordId, $destinationModule, $destinationRecordIds, $relatedName = false)
557 563
 {
558 564
 	\App\Log::trace("Entering relateEntities method ($sourceModule, $sourceRecordId, $destinationModule, $destinationRecordIds)");
559
-	if (!is_array($destinationRecordIds))
560
-		$destinationRecordIds = [$destinationRecordIds];
565
+	if (!is_array($destinationRecordIds)) {
566
+			$destinationRecordIds = [$destinationRecordIds];
567
+	}
561 568
 
562 569
 	$data = [
563 570
 		'CRMEntity' => $focus,
@@ -600,20 +607,23 @@  discard block
 block discarded – undo
600 607
 	$delim = array('/', '.');
601 608
 	foreach ($delim as $delimiter) {
602 609
 		$x = strpos($value, $delimiter);
603
-		if ($x === false)
604
-			continue;
605
-		else {
610
+		if ($x === false) {
611
+					continue;
612
+		} else {
606 613
 			$value = str_replace($delimiter, '-', $value);
607 614
 			break;
608 615
 		}
609 616
 	}
610 617
 	list($y, $m, $d) = explode('-', $value);
611
-	if (strlen($y) == 1)
612
-		$y = '0' . $y;
613
-	if (strlen($m) == 1)
614
-		$m = '0' . $m;
615
-	if (strlen($d) == 1)
616
-		$d = '0' . $d;
618
+	if (strlen($y) == 1) {
619
+			$y = '0' . $y;
620
+	}
621
+	if (strlen($m) == 1) {
622
+			$m = '0' . $m;
623
+	}
624
+	if (strlen($d) == 1) {
625
+			$d = '0' . $d;
626
+	}
617 627
 	$value = implode('-', array($y, $m, $d));
618 628
 
619 629
 	if (strlen($y) < 4) {
Please login to merge, or discard this patch.
include/ConfigUtils.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,8 +61,9 @@
 block discarded – undo
61 61
 		self::$modules[$module] = $CONFIG;
62 62
 		switch ($argsLength) {
63 63
 			case 2:
64
-				if (!isset($CONFIG[$key]))
65
-					return false;
64
+				if (!isset($CONFIG[$key])) {
65
+									return false;
66
+				}
66 67
 				return $CONFIG[$key];
67 68
 				break;
68 69
 			default:
Please login to merge, or discard this patch.
Doc Comments   +36 added lines patch added patch discarded remove patch
@@ -16,11 +16,17 @@  discard block
 block discarded – undo
16 16
 	protected static $sounds = [];
17 17
 	protected static $search = [];
18 18
 
19
+	/**
20
+	 * @param string $key
21
+	 */
19 22
 	public static function load($key, $config)
20 23
 	{
21 24
 		self::$$key = $config;
22 25
 	}
23 26
 
27
+	/**
28
+	 * @param string $key
29
+	 */
24 30
 	public static function main($key, $value = false)
25 31
 	{
26 32
 		if (isset(self::$main[$key])) {
@@ -75,11 +81,17 @@  discard block
 block discarded – undo
75 81
 		}
76 82
 	}
77 83
 
84
+	/**
85
+	 * @param string $key
86
+	 */
78 87
 	public static function api($key, $defvalue = false)
79 88
 	{
80 89
 		return self::$api[$key];
81 90
 	}
82 91
 
92
+	/**
93
+	 * @param string $key
94
+	 */
83 95
 	public static function debug($key, $defvalue = false)
84 96
 	{
85 97
 		if (empty(self::$debug)) {
@@ -89,6 +101,9 @@  discard block
 block discarded – undo
89 101
 		return self::$debug[$key];
90 102
 	}
91 103
 
104
+	/**
105
+	 * @param string $key
106
+	 */
92 107
 	public static function developer($key, $defvalue = false)
93 108
 	{
94 109
 		if (empty(self::$developer)) {
@@ -98,6 +113,9 @@  discard block
 block discarded – undo
98 113
 		return self::$developer[$key];
99 114
 	}
100 115
 
116
+	/**
117
+	 * @param string $key
118
+	 */
101 119
 	public static function security($key, $defvalue = false)
102 120
 	{
103 121
 		if (empty(self::$security)) {
@@ -107,6 +125,9 @@  discard block
 block discarded – undo
107 125
 		return self::$security[$key];
108 126
 	}
109 127
 
128
+	/**
129
+	 * @param string $key
130
+	 */
110 131
 	public static function securityKeys($key, $defvalue = false)
111 132
 	{
112 133
 		if (empty(self::$securityKeys)) {
@@ -116,6 +137,11 @@  discard block
 block discarded – undo
116 137
 		return self::$securityKeys[$key];
117 138
 	}
118 139
 
140
+	/**
141
+	 * @param string $key
142
+	 *
143
+	 * @return integer
144
+	 */
119 145
 	public static function performance($key, $defvalue = false)
120 146
 	{
121 147
 		if (!self::$performance) {
@@ -125,6 +151,9 @@  discard block
 block discarded – undo
125 151
 		return self::$performance[$key];
126 152
 	}
127 153
 
154
+	/**
155
+	 * @param string $key
156
+	 */
128 157
 	public static function relation($key, $defvalue = false)
129 158
 	{
130 159
 		if (empty(self::$relation)) {
@@ -147,6 +176,9 @@  discard block
 block discarded – undo
147 176
 		return self::$sounds[$key];
148 177
 	}
149 178
 
179
+	/**
180
+	 * @param string $key
181
+	 */
150 182
 	public static function search($key, $defvalue = false)
151 183
 	{
152 184
 		if (empty(self::$search)) {
@@ -156,6 +188,10 @@  discard block
 block discarded – undo
156 188
 		return self::$search[$key];
157 189
 	}
158 190
 
191
+	/**
192
+	 * @param string $key
193
+	 * @param integer $value
194
+	 */
159 195
 	public static function iniSet($key, $value)
160 196
 	{
161 197
 		@ini_set($key, $value);
Please login to merge, or discard this patch.
include/Webservices/VtigerCRMObjectMeta.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -212,8 +212,9 @@  discard block
 block discarded – undo
212 212
 		$adb = PearDatabase::getInstance();
213 213
 
214 214
 		// administrator's have assign privilege
215
-		if (\vtlib\Functions::userIsAdministrator($this->user))
216
-			return true;
215
+		if (\vtlib\Functions::userIsAdministrator($this->user)) {
216
+					return true;
217
+		}
217 218
 
218 219
 		$idComponents = vtws_getIdComponents($webserviceId);
219 220
 		$userId = $idComponents[1];
@@ -353,8 +354,9 @@  discard block
 block discarded – undo
353 354
 		$theme = vtws_preserveGlobal('theme', $this->user->theme);
354 355
 		$default_language = AppConfig::main('default_language');
355 356
 		$current_language = vglobal('current_language');
356
-		if (empty($current_language))
357
-			$current_language = $default_language;
357
+		if (empty($current_language)) {
358
+					$current_language = $default_language;
359
+		}
358 360
 		$current_language = vtws_preserveGlobal('current_language', $current_language);
359 361
 
360 362
 		$this->computeAccess();
Please login to merge, or discard this patch.
include/Webservices/History.php 1 patch
Braces   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,8 +31,9 @@  discard block
 block discarded – undo
31 31
 	$page = empty($element['page']) ? 0 : intval($element['page']); // Page to start
32 32
 
33 33
 	$acrossAllModule = false;
34
-	if ($moduleName == 'Home')
35
-		$acrossAllModule = true;
34
+	if ($moduleName == 'Home') {
35
+			$acrossAllModule = true;
36
+	}
36 37
 
37 38
 	// Pre-condition check
38 39
 	if (empty($moduleName)) {
@@ -71,8 +72,10 @@  discard block
 block discarded – undo
71 72
 
72 73
 	// Get most recently tracked changes with limit
73 74
 	$start = $page * $MAXLIMIT;
74
-	if ($start > 0)
75
-		$start = $start + 1; // Adjust the start range
75
+	if ($start > 0) {
76
+			$start = $start + 1;
77
+	}
78
+	// Adjust the start range
76 79
 	$sql .= sprintf(' ORDER BY vtiger_modtracker_basic.id DESC LIMIT %s,%s', $start, $MAXLIMIT);
77 80
 
78 81
 	$result = $adb->pquery($sql, $params);
Please login to merge, or discard this patch.
libraries/SabreDAV/DAVACL/FS/Collection.php 3 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -59,8 +59,12 @@
 block discarded – undo
59 59
 
60 60
         $path = $this->path . '/' . $name;
61 61
 
62
-        if (!file_exists($path)) throw new NotFound('File could not be located');
63
-        if ($name == '.' || $name == '..') throw new Forbidden('Permission denied to . and ..');
62
+        if (!file_exists($path)) {
63
+        	throw new NotFound('File could not be located');
64
+        }
65
+        if ($name == '.' || $name == '..') {
66
+        	throw new Forbidden('Permission denied to . and ..');
67
+        }
64 68
 
65 69
         if (is_dir($path)) {
66 70
 
Please login to merge, or discard this patch.
Unused Use Statements   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,10 +2,10 @@
 block discarded – undo
2 2
 
3 3
 namespace Sabre\DAVACL\FS;
4 4
 
5
-use Sabre\DAV\FSExt\Directory as BaseCollection;
6 5
 use Sabre\DAVACL\IACL;
7 6
 use Sabre\DAV\Exception\Forbidden;
8 7
 use Sabre\DAV\Exception\NotFound;
8
+use Sabre\DAV\FSExt\Directory as BaseCollection;
9 9
 
10 10
 /**
11 11
  * This is an ACL-enabled collection.
Please login to merge, or discard this patch.
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -16,138 +16,138 @@
 block discarded – undo
16 16
  */
17 17
 class Collection extends BaseCollection implements IACL {
18 18
 
19
-    /**
20
-     * A list of ACL rules.
21
-     *
22
-     * @var array
23
-     */
24
-    protected $acl;
25
-
26
-    /**
27
-     * Owner uri, or null for no owner.
28
-     *
29
-     * @var string|null
30
-     */
31
-    protected $owner;
32
-
33
-    /**
34
-     * Constructor
35
-     *
36
-     * @param string $path on-disk path.
37
-     * @param array $acl ACL rules.
38
-     * @param string|null $owner principal owner string.
39
-     */
40
-    public function __construct($path, array $acl, $owner = null) {
41
-
42
-        parent::__construct($path);
43
-        $this->acl = $acl;
44
-        $this->owner = $owner;
45
-
46
-    }
47
-
48
-    /**
49
-     * Returns a specific child node, referenced by its name
50
-     *
51
-     * This method must throw Sabre\DAV\Exception\NotFound if the node does not
52
-     * exist.
53
-     *
54
-     * @param string $name
55
-     * @throws DAV\Exception\NotFound
56
-     * @return DAV\INode
57
-     */
58
-    public function getChild($name) {
59
-
60
-        $path = $this->path . '/' . $name;
61
-
62
-        if (!file_exists($path)) throw new NotFound('File could not be located');
63
-        if ($name == '.' || $name == '..') throw new Forbidden('Permission denied to . and ..');
64
-
65
-        if (is_dir($path)) {
66
-
67
-            return new self($path, $this->acl, $this->owner);
68
-
69
-        } else {
70
-
71
-            return new File($path, $this->acl, $this->owner);
72
-
73
-        }
74
-
75
-    }
76
-
77
-    /**
78
-     * Returns the owner principal
79
-     *
80
-     * This must be a url to a principal, or null if there's no owner
81
-     *
82
-     * @return string|null
83
-     */
84
-    public function getOwner() {
85
-
86
-        return $this->owner;
87
-
88
-    }
89
-
90
-    /**
91
-     * Returns a group principal
92
-     *
93
-     * This must be a url to a principal, or null if there's no owner
94
-     *
95
-     * @return string|null
96
-     */
97
-    public function getGroup() {
98
-
99
-        return null;
100
-
101
-    }
102
-
103
-    /**
104
-     * Returns a list of ACE's for this node.
105
-     *
106
-     * Each ACE has the following properties:
107
-     *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
108
-     *     currently the only supported privileges
109
-     *   * 'principal', a url to the principal who owns the node
110
-     *   * 'protected' (optional), indicating that this ACE is not allowed to
111
-     *      be updated.
112
-     *
113
-     * @return array
114
-     */
115
-    public function getACL() {
116
-
117
-        return $this->acl;
118
-
119
-    }
120
-
121
-    /**
122
-     * Updates the ACL
123
-     *
124
-     * This method will receive a list of new ACE's as an array argument.
125
-     *
126
-     * @param array $acl
127
-     * @return void
128
-     */
129
-    public function setACL(array $acl) {
130
-
131
-        throw new Forbidden('Setting ACL is not allowed here');
132
-
133
-    }
134
-
135
-    /**
136
-     * Returns the list of supported privileges for this node.
137
-     *
138
-     * The returned data structure is a list of nested privileges.
139
-     * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple
140
-     * standard structure.
141
-     *
142
-     * If null is returned from this method, the default privilege set is used,
143
-     * which is fine for most common usecases.
144
-     *
145
-     * @return array|null
146
-     */
147
-    public function getSupportedPrivilegeSet() {
148
-
149
-        return null;
150
-
151
-    }
19
+	/**
20
+	 * A list of ACL rules.
21
+	 *
22
+	 * @var array
23
+	 */
24
+	protected $acl;
25
+
26
+	/**
27
+	 * Owner uri, or null for no owner.
28
+	 *
29
+	 * @var string|null
30
+	 */
31
+	protected $owner;
32
+
33
+	/**
34
+	 * Constructor
35
+	 *
36
+	 * @param string $path on-disk path.
37
+	 * @param array $acl ACL rules.
38
+	 * @param string|null $owner principal owner string.
39
+	 */
40
+	public function __construct($path, array $acl, $owner = null) {
41
+
42
+		parent::__construct($path);
43
+		$this->acl = $acl;
44
+		$this->owner = $owner;
45
+
46
+	}
47
+
48
+	/**
49
+	 * Returns a specific child node, referenced by its name
50
+	 *
51
+	 * This method must throw Sabre\DAV\Exception\NotFound if the node does not
52
+	 * exist.
53
+	 *
54
+	 * @param string $name
55
+	 * @throws DAV\Exception\NotFound
56
+	 * @return DAV\INode
57
+	 */
58
+	public function getChild($name) {
59
+
60
+		$path = $this->path . '/' . $name;
61
+
62
+		if (!file_exists($path)) throw new NotFound('File could not be located');
63
+		if ($name == '.' || $name == '..') throw new Forbidden('Permission denied to . and ..');
64
+
65
+		if (is_dir($path)) {
66
+
67
+			return new self($path, $this->acl, $this->owner);
68
+
69
+		} else {
70
+
71
+			return new File($path, $this->acl, $this->owner);
72
+
73
+		}
74
+
75
+	}
76
+
77
+	/**
78
+	 * Returns the owner principal
79
+	 *
80
+	 * This must be a url to a principal, or null if there's no owner
81
+	 *
82
+	 * @return string|null
83
+	 */
84
+	public function getOwner() {
85
+
86
+		return $this->owner;
87
+
88
+	}
89
+
90
+	/**
91
+	 * Returns a group principal
92
+	 *
93
+	 * This must be a url to a principal, or null if there's no owner
94
+	 *
95
+	 * @return string|null
96
+	 */
97
+	public function getGroup() {
98
+
99
+		return null;
100
+
101
+	}
102
+
103
+	/**
104
+	 * Returns a list of ACE's for this node.
105
+	 *
106
+	 * Each ACE has the following properties:
107
+	 *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
108
+	 *     currently the only supported privileges
109
+	 *   * 'principal', a url to the principal who owns the node
110
+	 *   * 'protected' (optional), indicating that this ACE is not allowed to
111
+	 *      be updated.
112
+	 *
113
+	 * @return array
114
+	 */
115
+	public function getACL() {
116
+
117
+		return $this->acl;
118
+
119
+	}
120
+
121
+	/**
122
+	 * Updates the ACL
123
+	 *
124
+	 * This method will receive a list of new ACE's as an array argument.
125
+	 *
126
+	 * @param array $acl
127
+	 * @return void
128
+	 */
129
+	public function setACL(array $acl) {
130
+
131
+		throw new Forbidden('Setting ACL is not allowed here');
132
+
133
+	}
134
+
135
+	/**
136
+	 * Returns the list of supported privileges for this node.
137
+	 *
138
+	 * The returned data structure is a list of nested privileges.
139
+	 * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple
140
+	 * standard structure.
141
+	 *
142
+	 * If null is returned from this method, the default privilege set is used,
143
+	 * which is fine for most common usecases.
144
+	 *
145
+	 * @return array|null
146
+	 */
147
+	public function getSupportedPrivilegeSet() {
148
+
149
+		return null;
150
+
151
+	}
152 152
 
153 153
 }
Please login to merge, or discard this patch.
libraries/SabreDAV/Uri/functions.php 3 patches
Indentation   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -22,80 +22,80 @@  discard block
 block discarded – undo
22 22
  */
23 23
 function resolve($basePath, $newPath) {
24 24
 
25
-    $base = parse($basePath);
26
-    $delta = parse($newPath);
27
-
28
-    $pick = function($part) use ($base, $delta) {
29
-
30
-        if ($delta[$part]) {
31
-            return $delta[$part];
32
-        } elseif ($base[$part]) {
33
-            return $base[$part];
34
-        }
35
-        return null;
36
-
37
-    };
38
-
39
-    // If the new path defines a scheme, it's absolute and we can just return
40
-    // that.
41
-    if ($delta['scheme']) {
42
-        return build($delta);
43
-    }
44
-
45
-    $newParts = [];
46
-
47
-    $newParts['scheme'] = $pick('scheme');
48
-    $newParts['host']   = $pick('host');
49
-    $newParts['port']   = $pick('port');
50
-
51
-    $path = '';
52
-    if ($delta['path']) {
53
-        // If the path starts with a slash
54
-        if ($delta['path'][0] === '/') {
55
-            $path = $delta['path'];
56
-        } else {
57
-            // Removing last component from base path.
58
-            $path = $base['path'];
59
-            if (strpos($path, '/') !== false) {
60
-                $path = substr($path, 0, strrpos($path, '/'));
61
-            }
62
-            $path .= '/' . $delta['path'];
63
-        }
64
-    } else {
65
-        $path = $base['path'] ?: '/';
66
-    }
67
-    // Removing .. and .
68
-    $pathParts = explode('/', $path);
69
-    $newPathParts = [];
70
-    foreach ($pathParts as $pathPart) {
71
-
72
-        switch ($pathPart) {
73
-            //case '' :
74
-            case '.' :
75
-                break;
76
-            case '..' :
77
-                array_pop($newPathParts);
78
-                break;
79
-            default :
80
-                $newPathParts[] = $pathPart;
81
-                break;
82
-        }
83
-    }
84
-
85
-    $path = implode('/', $newPathParts);
86
-
87
-    // If the source url ended with a /, we want to preserve that.
88
-    $newParts['path'] = $path;
89
-    if ($delta['query']) {
90
-        $newParts['query'] = $delta['query'];
91
-    } elseif (!empty($base['query']) && empty($delta['host']) && empty($delta['path'])) {
92
-        // Keep the old query if host and path didn't change
93
-        $newParts['query'] = $base['query'];
94
-    }
95
-    if ($delta['fragment']) {
96
-        $newParts['fragment'] = $delta['fragment'];
97
-    }
98
-    return build($newParts);
25
+	$base = parse($basePath);
26
+	$delta = parse($newPath);
27
+
28
+	$pick = function($part) use ($base, $delta) {
29
+
30
+		if ($delta[$part]) {
31
+			return $delta[$part];
32
+		} elseif ($base[$part]) {
33
+			return $base[$part];
34
+		}
35
+		return null;
36
+
37
+	};
38
+
39
+	// If the new path defines a scheme, it's absolute and we can just return
40
+	// that.
41
+	if ($delta['scheme']) {
42
+		return build($delta);
43
+	}
44
+
45
+	$newParts = [];
46
+
47
+	$newParts['scheme'] = $pick('scheme');
48
+	$newParts['host']   = $pick('host');
49
+	$newParts['port']   = $pick('port');
50
+
51
+	$path = '';
52
+	if ($delta['path']) {
53
+		// If the path starts with a slash
54
+		if ($delta['path'][0] === '/') {
55
+			$path = $delta['path'];
56
+		} else {
57
+			// Removing last component from base path.
58
+			$path = $base['path'];
59
+			if (strpos($path, '/') !== false) {
60
+				$path = substr($path, 0, strrpos($path, '/'));
61
+			}
62
+			$path .= '/' . $delta['path'];
63
+		}
64
+	} else {
65
+		$path = $base['path'] ?: '/';
66
+	}
67
+	// Removing .. and .
68
+	$pathParts = explode('/', $path);
69
+	$newPathParts = [];
70
+	foreach ($pathParts as $pathPart) {
71
+
72
+		switch ($pathPart) {
73
+			//case '' :
74
+			case '.' :
75
+				break;
76
+			case '..' :
77
+				array_pop($newPathParts);
78
+				break;
79
+			default :
80
+				$newPathParts[] = $pathPart;
81
+				break;
82
+		}
83
+	}
84
+
85
+	$path = implode('/', $newPathParts);
86
+
87
+	// If the source url ended with a /, we want to preserve that.
88
+	$newParts['path'] = $path;
89
+	if ($delta['query']) {
90
+		$newParts['query'] = $delta['query'];
91
+	} elseif (!empty($base['query']) && empty($delta['host']) && empty($delta['path'])) {
92
+		// Keep the old query if host and path didn't change
93
+		$newParts['query'] = $base['query'];
94
+	}
95
+	if ($delta['fragment']) {
96
+		$newParts['fragment'] = $delta['fragment'];
97
+	}
98
+	return build($newParts);
99 99
 
100 100
 }
101 101
 
@@ -113,55 +113,55 @@  discard block
 block discarded – undo
113 113
  */
114 114
 function normalize($uri) {
115 115
 
116
-    $parts = parse($uri);
117
-
118
-    if (!empty($parts['path'])) {
119
-        $pathParts = explode('/', ltrim($parts['path'], '/'));
120
-        $newPathParts = [];
121
-        foreach ($pathParts as $pathPart) {
122
-            switch ($pathPart) {
123
-                case '.':
124
-                    // skip
125
-                    break;
126
-                case '..' :
127
-                    // One level up in the hierarchy
128
-                    array_pop($newPathParts);
129
-                    break;
130
-                default :
131
-                    // Ensuring that everything is correctly percent-encoded.
132
-                    $newPathParts[] = rawurlencode(rawurldecode($pathPart));
133
-                    break;
134
-            }
135
-        }
136
-        $parts['path'] = '/' . implode('/', $newPathParts);
137
-    }
138
-
139
-    if ($parts['scheme']) {
140
-        $parts['scheme'] = strtolower($parts['scheme']);
141
-        $defaultPorts = [
142
-            'http'  => '80',
143
-            'https' => '443',
144
-        ];
145
-
146
-        if (!empty($parts['port']) && isset($defaultPorts[$parts['scheme']]) && $defaultPorts[$parts['scheme']] == $parts['port']) {
147
-            // Removing default ports.
148
-            unset($parts['port']);
149
-        }
150
-        // A few HTTP specific rules.
151
-        switch ($parts['scheme']) {
152
-            case 'http' :
153
-            case 'https' :
154
-                if (empty($parts['path'])) {
155
-                    // An empty path is equivalent to / in http.
156
-                    $parts['path'] = '/';
157
-                }
158
-                break;
159
-        }
160
-    }
161
-
162
-    if ($parts['host']) $parts['host'] = strtolower($parts['host']);
163
-
164
-    return build($parts);
116
+	$parts = parse($uri);
117
+
118
+	if (!empty($parts['path'])) {
119
+		$pathParts = explode('/', ltrim($parts['path'], '/'));
120
+		$newPathParts = [];
121
+		foreach ($pathParts as $pathPart) {
122
+			switch ($pathPart) {
123
+				case '.':
124
+					// skip
125
+					break;
126
+				case '..' :
127
+					// One level up in the hierarchy
128
+					array_pop($newPathParts);
129
+					break;
130
+				default :
131
+					// Ensuring that everything is correctly percent-encoded.
132
+					$newPathParts[] = rawurlencode(rawurldecode($pathPart));
133
+					break;
134
+			}
135
+		}
136
+		$parts['path'] = '/' . implode('/', $newPathParts);
137
+	}
138
+
139
+	if ($parts['scheme']) {
140
+		$parts['scheme'] = strtolower($parts['scheme']);
141
+		$defaultPorts = [
142
+			'http'  => '80',
143
+			'https' => '443',
144
+		];
145
+
146
+		if (!empty($parts['port']) && isset($defaultPorts[$parts['scheme']]) && $defaultPorts[$parts['scheme']] == $parts['port']) {
147
+			// Removing default ports.
148
+			unset($parts['port']);
149
+		}
150
+		// A few HTTP specific rules.
151
+		switch ($parts['scheme']) {
152
+			case 'http' :
153
+			case 'https' :
154
+				if (empty($parts['path'])) {
155
+					// An empty path is equivalent to / in http.
156
+					$parts['path'] = '/';
157
+				}
158
+				break;
159
+		}
160
+	}
161
+
162
+	if ($parts['host']) $parts['host'] = strtolower($parts['host']);
163
+
164
+	return build($parts);
165 165
 
166 166
 }
167 167
 
@@ -180,29 +180,29 @@  discard block
 block discarded – undo
180 180
  */
181 181
 function parse($uri) {
182 182
 
183
-    // Normally a URI must be ASCII, however. However, often it's not and
184
-    // parse_url might corrupt these strings.
185
-    //
186
-    // For that reason we take any non-ascii characters from the uri and
187
-    // uriencode them first.
188
-    $uri = preg_replace_callback(
189
-        '/[^[:ascii:]]/u',
190
-        function($matches) {
191
-            return rawurlencode($matches[0]);
192
-        },
193
-        $uri
194
-    );
195
-
196
-    return
197
-        parse_url($uri) + [
198
-            'scheme'   => null,
199
-            'host'     => null,
200
-            'path'     => null,
201
-            'port'     => null,
202
-            'user'     => null,
203
-            'query'    => null,
204
-            'fragment' => null,
205
-        ];
183
+	// Normally a URI must be ASCII, however. However, often it's not and
184
+	// parse_url might corrupt these strings.
185
+	//
186
+	// For that reason we take any non-ascii characters from the uri and
187
+	// uriencode them first.
188
+	$uri = preg_replace_callback(
189
+		'/[^[:ascii:]]/u',
190
+		function($matches) {
191
+			return rawurlencode($matches[0]);
192
+		},
193
+		$uri
194
+	);
195
+
196
+	return
197
+		parse_url($uri) + [
198
+			'scheme'   => null,
199
+			'host'     => null,
200
+			'path'     => null,
201
+			'port'     => null,
202
+			'user'     => null,
203
+			'query'    => null,
204
+			'fragment' => null,
205
+		];
206 206
 
207 207
 }
208 208
 
@@ -215,41 +215,41 @@  discard block
 block discarded – undo
215 215
  */
216 216
 function build(array $parts) {
217 217
 
218
-    $uri = '';
219
-
220
-    $authority = '';
221
-    if (!empty($parts['host'])) {
222
-        $authority = $parts['host'];
223
-        if (!empty($parts['user'])) {
224
-            $authority = $parts['user'] . '@' . $authority;
225
-        }
226
-        if (!empty($parts['port'])) {
227
-            $authority = $authority . ':' . $parts['port'];
228
-        }
229
-    }
230
-
231
-    if (!empty($parts['scheme'])) {
232
-        // If there's a scheme, there's also a host.
233
-        $uri = $parts['scheme'] . ':';
234
-
235
-    }
236
-    if ($authority) {
237
-        // No scheme, but there is a host.
238
-        $uri .= '//' . $authority;
239
-
240
-    }
241
-
242
-    if (!empty($parts['path'])) {
243
-        $uri .= $parts['path'];
244
-    }
245
-    if (!empty($parts['query'])) {
246
-        $uri .= '?' . $parts['query'];
247
-    }
248
-    if (!empty($parts['fragment'])) {
249
-        $uri .= '#' . $parts['fragment'];
250
-    }
251
-
252
-    return $uri;
218
+	$uri = '';
219
+
220
+	$authority = '';
221
+	if (!empty($parts['host'])) {
222
+		$authority = $parts['host'];
223
+		if (!empty($parts['user'])) {
224
+			$authority = $parts['user'] . '@' . $authority;
225
+		}
226
+		if (!empty($parts['port'])) {
227
+			$authority = $authority . ':' . $parts['port'];
228
+		}
229
+	}
230
+
231
+	if (!empty($parts['scheme'])) {
232
+		// If there's a scheme, there's also a host.
233
+		$uri = $parts['scheme'] . ':';
234
+
235
+	}
236
+	if ($authority) {
237
+		// No scheme, but there is a host.
238
+		$uri .= '//' . $authority;
239
+
240
+	}
241
+
242
+	if (!empty($parts['path'])) {
243
+		$uri .= $parts['path'];
244
+	}
245
+	if (!empty($parts['query'])) {
246
+		$uri .= '?' . $parts['query'];
247
+	}
248
+	if (!empty($parts['fragment'])) {
249
+		$uri .= '#' . $parts['fragment'];
250
+	}
251
+
252
+	return $uri;
253 253
 
254 254
 }
255 255
 
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
  */
274 274
 function split($path) {
275 275
 
276
-    $matches = [];
277
-    if (preg_match('/^(?:(?:(.*)(?:\/+))?([^\/]+))(?:\/?)$/u', $path, $matches)) {
278
-        return [$matches[1], $matches[2]];
279
-    }
280
-    return [null,null];
276
+	$matches = [];
277
+	if (preg_match('/^(?:(?:(.*)(?:\/+))?([^\/]+))(?:\/?)$/u', $path, $matches)) {
278
+		return [$matches[1], $matches[2]];
279
+	}
280
+	return [null,null];
281 281
 
282 282
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -277,6 +277,6 @@
 block discarded – undo
277 277
     if (preg_match('/^(?:(?:(.*)(?:\/+))?([^\/]+))(?:\/?)$/u', $path, $matches)) {
278 278
         return [$matches[1], $matches[2]];
279 279
     }
280
-    return [null,null];
280
+    return [null, null];
281 281
 
282 282
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -159,7 +159,9 @@
 block discarded – undo
159 159
         }
160 160
     }
161 161
 
162
-    if ($parts['host']) $parts['host'] = strtolower($parts['host']);
162
+    if ($parts['host']) {
163
+    	$parts['host'] = strtolower($parts['host']);
164
+    }
163 165
 
164 166
     return build($parts);
165 167
 
Please login to merge, or discard this patch.
libraries/SabreDAV/Uri/Version.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@
 block discarded – undo
11 11
  */
12 12
 class Version {
13 13
 
14
-    /**
15
-     * Full version number
16
-     */
17
-    const VERSION = '1.1.0';
14
+	/**
15
+	 * Full version number
16
+	 */
17
+	const VERSION = '1.1.0';
18 18
 
19 19
 }
Please login to merge, or discard this patch.