Completed
Push — 123 ( d13f38 )
by Vasily
05:11
created
lib/Pool.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 		if ($this->isEnabled()) {
28 28
 			list ($class, $name) = explode(':', $this->name . ':');
29 29
 			if (!class_exists($class)) {
30
-				Daemon::log($class. ' class not exists.');
30
+				Daemon::log($class . ' class not exists.');
31 31
 				return;
32 32
 			}
33 33
 			$this->pool = call_user_func(array($class, 'getInstance'), $name);
Please login to merge, or discard this patch.
lib/XMLStream.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -50,24 +50,24 @@  discard block
 block discarded – undo
50 50
 			$this->current_ns[$this->xml_depth] = $attr['XMLNS'];
51 51
 		} else {
52 52
 			$this->current_ns[$this->xml_depth] = $this->current_ns[$this->xml_depth - 1];
53
-			if(!$this->current_ns[$this->xml_depth]) $this->current_ns[$this->xml_depth] = $this->default_ns;
53
+			if (!$this->current_ns[$this->xml_depth]) $this->current_ns[$this->xml_depth] = $this->default_ns;
54 54
 		}
55 55
 		$ns = $this->current_ns[$this->xml_depth];
56
-		foreach($attr as $key => $value) {
57
-			if(strstr($key, ':')) {
56
+		foreach ($attr as $key => $value) {
57
+			if (strstr($key, ':')) {
58 58
 				$key = explode(':', $key);
59 59
 				$key = $key[1];
60 60
 				$this->ns_map[$key] = $value;
61 61
 			}
62 62
 		}
63
-		if(!strstr($name, ":") === false)
63
+		if (!strstr($name, ":") === false)
64 64
 		{
65 65
 			$name = explode(':', $name);
66 66
 			$ns = $this->ns_map[$name[0]];
67 67
 			$name = $name[1];
68 68
 		}
69 69
 		$obj = new XMLStream_Object($name, $ns, $attr);
70
-		if($this->xml_depth > 1) {
70
+		if ($this->xml_depth > 1) {
71 71
 			$this->xmlobj[$this->xml_depth - 1]->subs[] = $obj;
72 72
 		}
73 73
 		$this->xmlobj[$this->xml_depth] = $obj;
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
 	public function endXML($parser, $name) {
85 85
 		--$this->xml_depth;
86 86
 		if ($this->xml_depth == 1) {
87
-			foreach($this->xpathhandlers as $handler) {
87
+			foreach ($this->xpathhandlers as $handler) {
88 88
 				if (is_array($this->xmlobj) && array_key_exists(2, $this->xmlobj)) {
89 89
 					$searchxml = $this->xmlobj[2];
90 90
 					$nstag = array_shift($handler[0]);
91 91
 					if (($nstag[0] == null or $searchxml->ns == $nstag[0]) and ($nstag[1] == "*" or $nstag[1] == $searchxml->name)) {
92
-						foreach($handler[0] as $nstag) {
93
-							if ($searchxml !== null and $searchxml->hasSub($nstag[1], $ns=$nstag[0])) {
94
-								$searchxml = $searchxml->sub($nstag[1], $ns=$nstag[0]);
92
+						foreach ($handler[0] as $nstag) {
93
+							if ($searchxml !== null and $searchxml->hasSub($nstag[1], $ns = $nstag[0])) {
94
+								$searchxml = $searchxml->sub($nstag[1], $ns = $nstag[0]);
95 95
 							} else {
96 96
 								$searchxml = null;
97 97
 								break;
@@ -106,23 +106,23 @@  discard block
 block discarded – undo
106 106
 					}
107 107
 				}
108 108
 			}
109
-			foreach($this->idhandlers as $id => $handler) {
110
-				if(array_key_exists('id', $this->xmlobj[2]->attrs) and $this->xmlobj[2]->attrs['id'] == $id) {
109
+			foreach ($this->idhandlers as $id => $handler) {
110
+				if (array_key_exists('id', $this->xmlobj[2]->attrs) and $this->xmlobj[2]->attrs['id'] == $id) {
111 111
 					call_user_func($handler, $this->xmlobj[2]);
112 112
 					#id handlers are only used once
113 113
 					unset($this->idhandlers[$id]);
114 114
 					break;
115 115
 				}
116 116
 			}
117
-			if(is_array($this->xmlobj)) {
117
+			if (is_array($this->xmlobj)) {
118 118
 				$this->xmlobj = array_slice($this->xmlobj, 0, 1);
119
-				if(isset($this->xmlobj[0]) && $this->xmlobj[0] instanceof XMLStream_Object) {
119
+				if (isset($this->xmlobj[0]) && $this->xmlobj[0] instanceof XMLStream_Object) {
120 120
 					$this->xmlobj[0]->subs = null;
121 121
 				}
122 122
 			}
123 123
 			unset($this->xmlobj[2]);
124 124
 		}
125
-		if($this->xml_depth == 0) {
125
+		if ($this->xml_depth == 0) {
126 126
 			$this->event('streamEnd');
127 127
 		}
128 128
 	}
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @param string   $data
136 136
 	 */
137 137
 	public function charXML($parser, $data) {
138
-		if(array_key_exists($this->xml_depth, $this->xmlobj)) {
138
+		if (array_key_exists($this->xml_depth, $this->xmlobj)) {
139 139
 			$this->xmlobj[$this->xml_depth]->data .= $data;
140 140
 		}
141 141
 	}
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 *
157 157
 	 * @return integer
158 158
 	 */
159
-	public function useSSL($use=true) {
159
+	public function useSSL($use = true) {
160 160
 		$this->use_ssl = $use;
161 161
 	}
162 162
 
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 		} else {
206 206
 			$ns_tags = array($xpath);
207 207
 		}
208
-		foreach($ns_tags as $ns_tag) {
208
+		foreach ($ns_tags as $ns_tag) {
209 209
 			list($l, $r) = explode("}", $ns_tag);
210 210
 			if ($r != null) {
211 211
 				$xpart = array(substr($l, 1), $r);
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
 	public function __construct($name, $ns = '', $attrs = array(), $data = '') {
268 268
 		$this->name = strtolower($name);
269 269
 		$this->ns   = $ns;
270
-		if(is_array($attrs) && count($attrs)) {
271
-			foreach($attrs as $key => $value) {
270
+		if (is_array($attrs) && count($attrs)) {
271
+			foreach ($attrs as $key => $value) {
272 272
 				$this->attrs[strtolower($key)] = $value;
273 273
 			}
274 274
 		}
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 */
283 283
 	public function printObj($depth = 0) {
284 284
 		$s = str_repeat("\t", $depth) . $this->name . " " . $this->ns . ' ' . $this->data . "\n";
285
-		foreach($this->subs as $sub) {
285
+		foreach ($this->subs as $sub) {
286 286
 			$s .= $sub->printObj($depth + 1);
287 287
 		}
288 288
 		return $s;
@@ -295,14 +295,14 @@  discard block
 block discarded – undo
295 295
 	 */
296 296
 	public function toString($str = '') {
297 297
 		$str .= "<{$this->name} xmlns='{$this->ns}' ";
298
-		foreach($this->attrs as $key => $value) {
299
-			if($key != 'xmlns') {
298
+		foreach ($this->attrs as $key => $value) {
299
+			if ($key != 'xmlns') {
300 300
 				$value = htmlspecialchars($value);
301 301
 				$str .= "$key='$value' ";
302 302
 			}
303 303
 		}
304 304
 		$str .= ">";
305
-		foreach($this->subs as $sub) {
305
+		foreach ($this->subs as $sub) {
306 306
 			$str .= $sub->toString();
307 307
 		}
308 308
 		$body = htmlspecialchars($this->data);
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
 	 * @return boolean
318 318
 	 */
319 319
 	public function hasSub($name, $ns = null) {
320
-		foreach($this->subs as $sub) {
321
-			if(($name == "*" or $sub->name == $name) and ($ns == null or $sub->ns == $ns)) return true;
320
+		foreach ($this->subs as $sub) {
321
+			if (($name == "*" or $sub->name == $name) and ($ns == null or $sub->ns == $ns)) return true;
322 322
 		}
323 323
 		return false;
324 324
 	}
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
 	 */
333 333
 	public function sub($name, $attrs = null, $ns = null) {
334 334
 		#TODO attrs is ignored
335
-		foreach($this->subs as $sub) {
336
-			if($sub->name == $name and ($ns == null or $sub->ns == $ns)) {
335
+		foreach ($this->subs as $sub) {
336
+			if ($sub->name == $name and ($ns == null or $sub->ns == $ns)) {
337 337
 				return $sub;
338 338
 			}
339 339
 		}
Please login to merge, or discard this patch.
lib/WebSocketProtocolV0.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -28,21 +28,21 @@  discard block
 block discarded – undo
28 28
 			if (strlen($data) < 8) {
29 29
 				return 0; // not enough data yet;
30 30
 			}
31
-			$final_key = $this->_computeFinalKey($this->connection->server['HTTP_SEC_WEBSOCKET_KEY1'], $this->connection->server['HTTP_SEC_WEBSOCKET_KEY2'], $data) ;
31
+			$final_key = $this->_computeFinalKey($this->connection->server['HTTP_SEC_WEBSOCKET_KEY1'], $this->connection->server['HTTP_SEC_WEBSOCKET_KEY2'], $data);
32 32
 
33 33
 			if (!$final_key) {
34 34
 				return false;
35 35
 			}
36 36
 
37 37
             if (!isset($this->connection->server['HTTP_SEC_WEBSOCKET_ORIGIN'])) {
38
-                $this->connection->server['HTTP_SEC_WEBSOCKET_ORIGIN'] = '' ;
38
+                $this->connection->server['HTTP_SEC_WEBSOCKET_ORIGIN'] = '';
39 39
             }
40 40
 
41 41
             $reply = "HTTP/1.1 101 Web Socket Protocol Handshake\r\n"
42 42
                 . "Upgrade: WebSocket\r\n"
43 43
                 . "Connection: Upgrade\r\n"
44 44
                 . "Sec-WebSocket-Origin: " . $this->connection->server['HTTP_ORIGIN'] . "\r\n"
45
-                . "Sec-WebSocket-Location: ws://" . $this->connection->server['HTTP_HOST'] . $this->connection->server['REQUEST_URI'] . "\r\n" ;
45
+                . "Sec-WebSocket-Location: ws://" . $this->connection->server['HTTP_HOST'] . $this->connection->server['REQUEST_URI'] . "\r\n";
46 46
 			if ($this->connection->pool->config->expose->value) {
47 47
 				$reply .= 'X-Powered-By: phpDaemon/' . Daemon::$version . "\r\n";
48 48
 			}
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             return $reply;
54 54
         }
55 55
 
56
-        return FALSE ;
56
+        return FALSE;
57 57
     }
58 58
 
59 59
 	/**
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
 	protected function _computeFinalKey($key1, $key2, $data) {
68 68
 		if (strlen($data) < 8)
69 69
 		{
70
-			Daemon::$process->log(get_class($this) . '::' . __METHOD__ . ' : Invalid handshake data for client "' . $this->connection->addr . '"') ;
71
-			return FALSE ;
70
+			Daemon::$process->log(get_class($this) . '::' . __METHOD__ . ' : Invalid handshake data for client "' . $this->connection->addr . '"');
71
+			return FALSE;
72 72
 		}
73 73
 
74
-		$bodyData = binarySubstr($data, 0, 8) ;
74
+		$bodyData = binarySubstr($data, 0, 8);
75 75
 			
76
-		return md5($this->_computeKey($key1) . $this->_computeKey($key2) . binarySubstr($data, 0, 8), TRUE) ;
76
+		return md5($this->_computeKey($key1) . $this->_computeKey($key2) . binarySubstr($data, 0, 8), TRUE);
77 77
 	}
78 78
 
79 79
 	/**
@@ -132,61 +132,61 @@  discard block
 block discarded – undo
132 132
 				goto char;
133 133
 			};
134 134
 			
135
-			return chr(self::BINARY) . $len . $data ;
135
+			return chr(self::BINARY) . $len . $data;
136 136
 		}
137 137
 		// String
138 138
 		else
139 139
 		{
140
-			return chr(self::STRING) . $data . "\xFF" ;
140
+			return chr(self::STRING) . $data . "\xFF";
141 141
 		}
142 142
     }
143 143
 
144 144
     public function onRead() {
145 145
 		while ($this->connection && (($buflen = strlen($this->connection->buf)) >= 1)) {
146
-			$frametype = ord(binarySubstr($this->connection->buf, 0, 1)) ;
146
+			$frametype = ord(binarySubstr($this->connection->buf, 0, 1));
147 147
 			if (($frametype & 0x80) === 0x80) {
148
-				$len = 0 ;
149
-				$i = 0 ;
148
+				$len = 0;
149
+				$i = 0;
150 150
 
151 151
 				do {
152 152
 					$b = ord(binarySubstr($this->connection->buf, ++$i, 1));
153
-					$n = $b & 0x7F ;
154
-					$len *= 0x80 ;
155
-					$len += $n ;
156
-				} while ($b > 0x80) ;
153
+					$n = $b & 0x7F;
154
+					$len *= 0x80;
155
+					$len += $n;
156
+				} while ($b > 0x80);
157 157
 
158 158
 				if ($this->connection->pool->maxAllowedPacket <= $len) {
159 159
 					// Too big packet
160 160
 					$this->connection->finish();
161
-					return FALSE ;
161
+					return FALSE;
162 162
 				}
163 163
 
164
-				if ($buflen < $len + 2)	{
164
+				if ($buflen < $len + 2) {
165 165
 					// not enough data yet
166
-					return FALSE ;
166
+					return FALSE;
167 167
 				} 
168 168
 					
169
-				$decodedData = binarySubstr($this->connection->buf, 2, $len) ;
170
-				$this->connection->buf = binarySubstr($this->connection->buf, 2 + $len) ;
169
+				$decodedData = binarySubstr($this->connection->buf, 2, $len);
170
+				$this->connection->buf = binarySubstr($this->connection->buf, 2 + $len);
171 171
 				$this->connection->onFrame($decodedData, 'BINARY');
172 172
 			}
173 173
 			else {
174 174
 				if (($p = strpos($this->connection->buf, "\xFF")) !== FALSE) {
175 175
 					if ($this->connection->pool->maxAllowedPacket <= $p - 1) {
176 176
 						// Too big packet
177
-						$this->connection->finish() ;
178
-						return FALSE ;
177
+						$this->connection->finish();
178
+						return FALSE;
179 179
 					}
180 180
 						
181
-					$decodedData = binarySubstr($this->connection->buf, 1, $p - 1) ;
182
-					$this->connection->buf = binarySubstr($this->connection->buf, $p + 1) ;
181
+					$decodedData = binarySubstr($this->connection->buf, 1, $p - 1);
182
+					$this->connection->buf = binarySubstr($this->connection->buf, $p + 1);
183 183
 					$this->connection->onFrame($decodedData, 'STRING');
184 184
 				}
185 185
 				else {
186 186
 					if ($this->connection->pool->maxAllowedPacket <= $buflen - 1) {
187 187
 						// Too big packet
188
-						$this->connection->finish() ;
189
-						return FALSE ;
188
+						$this->connection->finish();
189
+						return FALSE;
190 190
 					}
191 191
 					// not enough data yet					
192 192
 					return;
Please login to merge, or discard this patch.
lib/Daemon_ConfigParser.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 		$cfg->revision = ++Daemon_Config::$lastRevision;
38 38
 		$cfg->data = file_get_contents($file);
39 39
 		
40
-		if (substr($cfg->data,0,2) === '#!') 	{
40
+		if (substr($cfg->data, 0, 2) === '#!') {
41 41
 			if (!is_executable($file)) {
42 42
 				$this->raiseError('Shebang (#!) detected in the first line, but file hasn\'t +x mode.');
43 43
 				return;
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 				$str = '';
59 59
 				++$cfg->p;
60 60
 
61
-				for (;$cfg->p < $cfg->len;++$cfg->p) {
61
+				for (;$cfg->p < $cfg->len; ++$cfg->p) {
62 62
 					$c = $cfg->getCurrentChar();
63 63
 
64 64
 					if ($c === $q) {
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 							if ($c === "\n") {
112 112
 								$newLineDetected = $prePoint;
113 113
 							}
114
-							if ($elTypes[$i] !== NULL)	{
114
+							if ($elTypes[$i] !== NULL) {
115 115
 								++$i;
116 116
 								$elTypes[$i] = NULL;
117 117
 							}
@@ -120,14 +120,14 @@  discard block
 block discarded – undo
120 120
 							($c === '"') 
121 121
 							|| ($c === '\'')
122 122
 						) {
123
-							if ($elTypes[$i] != NULL)	 {
123
+							if ($elTypes[$i] != NULL) {
124 124
 								$cfg->raiseError('Unexpected T_STRING.');
125 125
 							}
126 126
 
127 127
 							$string = call_user_func($cfg->tokens[Daemon_ConfigParser::T_STRING], $cfg, $c);
128 128
 							--$cfg->p;
129 129
 
130
-							if ($elTypes[$i] === NULL)	 {
130
+							if ($elTypes[$i] === NULL) {
131 131
 								$elements[$i] = $string;
132 132
 								$elTypes[$i] = Daemon_ConfigParser::T_STRING;
133 133
 							}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 							$tokenType = Daemon_ConfigParser::T_BLOCK;
147 147
 							break;
148 148
 						} else {
149
-							if ($elTypes[$i] === Daemon_ConfigParser::T_STRING)	 {
149
+							if ($elTypes[$i] === Daemon_ConfigParser::T_STRING) {
150 150
 								$cfg->raiseError('Unexpected T_CVALUE.');
151 151
 							} else {
152 152
 								if (!isset($elements[$i])) {
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 						
191 191
 						if ($name === 'include') {
192 192
 							$path = $elements[1];
193
-							if (substr($path,0,1) !== '/') {
194
-								$path = 'conf/'.$path;
193
+							if (substr($path, 0, 1) !== '/') {
194
+								$path = 'conf/' . $path;
195 195
 							}
196 196
 							$files = glob($path);
197 197
 							if ($files) {
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
 									$parser = new Daemon_ConfigParser($fn, $scope, true);
200 200
 								}
201 201
 							}
202
-						} elseif (substr(strtolower($elements[0]),0,4) === 'mod-') { // @TODO: remove in 1.0
202
+						} elseif (substr(strtolower($elements[0]), 0, 4) === 'mod-') { // @TODO: remove in 1.0
203 203
 							$cfg->raiseError('Variable started with \'mod-\'. This style is deprecated. You should replace it with block.');
204 204
 						} else {
205 205
 							if (sizeof($elements) > 2) {
206 206
 								$cfg->raiseError('Too many arguments.');
207 207
 							}
208 208
 							if (isset($scope->{$name})) {
209
-								if ($scope->{$name}->source !== 'cmdline')	{
209
+								if ($scope->{$name}->source !== 'cmdline') {
210 210
 									if (!isset($elements[1])) {
211 211
 										$elements[1] = true;
212 212
 										$elTypes[1] = Daemon_ConfigParser::T_CVALUE;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 								$scope->{$name}->setValue($elements[1]);
234 234
 								$scope->{$name}->setValueType($elTypes[1]);
235 235
 							}
236
-							else {$cfg->raiseError('Unrecognized parameter \''.$name.'\'');}
236
+							else {$cfg->raiseError('Unrecognized parameter \'' . $name . '\''); }
237 237
 						}
238 238
 					}
239 239
 					elseif ($tokenType === Daemon_ConfigParser::T_BLOCK) {
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 						);
252 252
 					}
253 253
 				} else {
254
-					$cfg->raiseError('Unexpected char \''.Debug::exportBytes($c).'\'');
254
+					$cfg->raiseError('Unexpected char \'' . Debug::exportBytes($c) . '\'');
255 255
 				}
256 256
 			}
257 257
 		);
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 			$e = end($this->state);
262 262
 			$cfg->token($e[0], $c);
263 263
 		}
264
-		if (!$included) {$this->purgeScope($this->result);}
264
+		if (!$included) {$this->purgeScope($this->result); }
265 265
 	}
266 266
 	
267 267
 	/**
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 		$cfg = $this;
273 273
 		foreach ($scope as $name => $obj) {
274 274
 			if ($obj instanceof Daemon_ConfigEntry) {
275
-					if ($obj->source === 'config' && ($obj->revision < $cfg->revision))	{
275
+					if ($obj->source === 'config' && ($obj->revision < $cfg->revision)) {
276 276
 						if (!$obj->resetToDefault()) {
277 277
 							unset($scope->{$name});
278 278
 						}
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 			}
281 281
 			elseif ($obj instanceof Daemon_ConfigSection) {
282 282
 				
283
-				if ($obj->source === 'config' && ($obj->revision < $cfg->revision))	{
283
+				if ($obj->source === 'config' && ($obj->revision < $cfg->revision)) {
284 284
 					if (sizeof($obj) === 0) {
285 285
 						unset($scope->{$name});
286 286
 					}
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
 			$line = $this->line;
317 317
 		}
318 318
 		if ($col === null) {
319
-			$col = $this->col -1 ;
319
+			$col = $this->col - 1;
320 320
 		}
321 321
 
322
-		Daemon::log('[conf#' . $level . '][' . $this->file . ' L:' . $line . ' C: ' . $col . ']   '.$msg);
322
+		Daemon::log('[conf#' . $level . '][' . $this->file . ' L:' . $line . ' C: ' . $col . ']   ' . $msg);
323 323
 	}
324 324
 
325 325
 	/**
Please login to merge, or discard this patch.
lib/HTTPRequest.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	 * Status codes
14 14
 	 * @var array
15 15
 	 */
16
-	private static $codes = array (
16
+	private static $codes = array(
17 17
 		100 => 'Continue',
18 18
 		101 => 'Switching Protocols',
19 19
 		200 => 'OK',
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 					$URLprefix = $this->attrs->server['REQUEST_PREPARED_UPLOADS_URL_PREFIX'];
243 243
 					$l = strlen($URLprefix);
244 244
 					foreach (array('PHP_SELF', 'REQUEST_URI', 'SCRIPT_NAME', 'DOCUMENT_URI') as $k) {
245
-						if (!isset($this->attrs->server[$k])) {continue;}
245
+						if (!isset($this->attrs->server[$k])) {continue; }
246 246
 						if (strncmp($this->attrs->server[$k], $URLprefix, $l) === 0) {
247 247
 							$this->attrs->server[$k] = substr($this->attrs->server[$k], $l - 1);
248 248
 						}
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 					if ($this->oldFashionUploadFP) {
273 273
 						$file['fp'] = fopen($file['tmp_name'], 'c+');
274 274
 					} else {
275
-						FS::open($file['tmp_name'], 'c+', function ($fp) use (&$file) {
275
+						FS::open($file['tmp_name'], 'c+', function($fp) use (&$file) {
276 276
 							if (!$fp) {
277 277
 								return;
278 278
 							}
@@ -529,8 +529,8 @@  discard block
 block discarded – undo
529 529
 		$this->header(
530 530
 			'Set-Cookie: ' . $name . '=' . rawurlencode($value)
531 531
 			. (empty($domain) ? '' : '; Domain=' . $domain)
532
-			. (empty($maxage) ? '' : '; Max-Age='.$maxage)
533
-			. (empty($path) ? '' : '; Path='.$path)
532
+			. (empty($maxage) ? '' : '; Max-Age=' . $maxage)
533
+			. (empty($path) ? '' : '; Path=' . $path)
534 534
 			. (!$secure ? '' : '; Secure')
535 535
 			. (!$HTTPOnly ? '' : '; HttpOnly'), false);
536 536
 	}
@@ -570,17 +570,17 @@  discard block
 block discarded – undo
570 570
 			if (!isset($ctype['charset'])) {
571 571
 				$ctype['charset'] = $this->upstream->pool->config->defaultcharset->value;
572 572
 
573
-				$s = $e[0].': ';
573
+				$s = $e[0] . ': ';
574 574
 				$i = 0;
575 575
 				foreach ($ctype as $k => $v) {
576
-					$s .= ($i > 0 ? '; ' : '') . $k.  ($v !== '' ? '=' . $v : '');
576
+					$s .= ($i > 0 ? '; ' : '') . $k . ($v !== '' ? '=' . $v : '');
577 577
 					++$i;
578 578
 				}
579 579
 			}
580 580
 		}
581 581
 
582 582
 		if ($k === 'SET_COOKIE') {
583
-			$k .= '_'.++$this->cookieNum;
583
+			$k .= '_' . ++$this->cookieNum;
584 584
 		}
585 585
 		elseif (
586 586
 			!$replace
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 									if (FS::$supported) {
704 704
 										$this->upstream->lockRead();
705 705
 									}
706
-									FS::open($this->attrs->files[$name]['tmp_name'], 'c+', function ($fp) use ($req, $name) {
706
+									FS::open($this->attrs->files[$name]['tmp_name'], 'c+', function($fp) use ($req, $name) {
707 707
 										if (!$fp) {
708 708
 											$req->attrs->files[$name]['error'] = UPLOAD_ERR_CANT_WRITE;
709 709
 										}
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
 	 * @param string The destination of the moved file.
865 865
 	 * @return boolean Success.
866 866
 	 */
867
-	public function moveUploadedFile($filename,$dest) {
867
+	public function moveUploadedFile($filename, $dest) {
868 868
 		if (!$this->isUploadedFile($filename)) {
869 869
 			return false;
870 870
 		}
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 			return false;
881 881
 		}
882 882
 		FS::readfileChunked($this->attrs->server['REQUEST_BODY_FILE'],
883
-			function ($file, $success) {
883
+			function($file, $success) {
884 884
 				$this->attrs->stdin_done = true;
885 885
 				if ($this->sleepTime === 0) {
886 886
 					$this->wakeup();
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
 	public static function parse_str($s, &$var, $header = false) {
903 903
 		static $cb;
904 904
 		if ($cb === NULL) {
905
-			$cb = function ($m) {
905
+			$cb = function($m) {
906 906
 				return urlencode(html_entity_decode('&#' . hexdec($m[1]) . ';', ENT_NOQUOTES, 'utf-8'));
907 907
 			};
908 908
 		}
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
 			$s = strtr($s, HTTPRequest::$hvaltr);
911 911
 		}
912 912
 		if (
913
-			(stripos($s,'%u') !== false)
913
+			(stripos($s, '%u') !== false)
914 914
 			&& preg_match('~(%u[a-f\d]{4}|%[c-f][a-f\d](?!%[89a-f][a-f\d]))~is', $s, $m)
915 915
 		) {
916 916
 			$s = preg_replace_callback('~%(u[a-f\d]{4}|[a-f\d]{2})~i', $cb, $s);
Please login to merge, or discard this patch.
lib/DNSClient.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  */
8 8
 class DNSClient extends NetworkClient {
9 9
 	public static $type = array(
10
- 		1 => 'A', 2 => 'NS',  3 => 'MD', 4 => 'MF', 5 => 'CNAME',
10
+ 		1 => 'A', 2 => 'NS', 3 => 'MD', 4 => 'MF', 5 => 'CNAME',
11 11
  		6 => 'SOA', 7 => 'MB', 8 => 'MG', 9 => 'MR', 10 => 'RR',
12 12
  		11 => 'WKS', 12 => 'PTR', 13 => 'HINFO', 14 => 'MINFO',
13 13
  		15 => 'MX', 16 => 'TXT', 17 => 'RP', 18 => 'AFSDB',
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 			$this->preloading = new ComplexJob;
66 66
 		}
67 67
 		$job = $this->preloading;
68
-		$job->addJob('resolvfile', function ($jobname, $job) use ($pool) {
68
+		$job->addJob('resolvfile', function($jobname, $job) use ($pool) {
69 69
 			FS::readfile($pool->config->resolvfile->value, function($file, $data) use ($pool, $job, $jobname) {
70 70
 				if ($file) {
71 71
 					preg_match_all('~nameserver ([^\r\n;]+)~', $data, $m);
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 				$job->setResult($jobname);
78 78
 			});
79 79
 		});
80
-		$job->addJob('hostsfile', function ($jobname, $job) use ($pool) {
80
+		$job->addJob('hostsfile', function($jobname, $job) use ($pool) {
81 81
 			FS::readfile($pool->config->hostsfile->value, function($file, $data) use ($pool, $job, $jobname) {
82 82
 				if ($file) {
83 83
 					preg_match_all('~^(\S+)\s+([^\r\n]+)\s*~m', $data, $m, PREG_SET_ORDER);
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	public function resolve($hostname, $cb, $noncache = false) {
101 101
 		if (!$this->preloading->hasCompleted()) {
102 102
 			$pool = $this;
103
-			$this->preloading->addListener(function ($job) use ($hostname, $cb, $noncache, $pool) {
103
+			$this->preloading->addListener(function($job) use ($hostname, $cb, $noncache, $pool) {
104 104
 				$pool->resolve($hostname, $cb, $noncache);
105 105
 			});
106 106
 			return;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 			$item->addListener($cb);
124 124
 		}
125 125
 		$pool = $this;
126
-		$this->get($hostname, function ($response) use ($cb, $noncache, $hostname, $pool) {
126
+		$this->get($hostname, function($response) use ($cb, $noncache, $hostname, $pool) {
127 127
 			if (!isset($response['A'])) {
128 128
 				if ($noncache) {
129 129
 					call_user_func($cb, false);
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	public function get($hostname, $cb, $noncache = false) {
156 156
 		if (!$this->preloading->hasCompleted()) {
157 157
 			$pool = $this;
158
-			$this->preloading->addListener(function ($job) use ($hostname, $cb, $noncache, $pool) {
158
+			$this->preloading->addListener(function($job) use ($hostname, $cb, $noncache, $pool) {
159 159
 				$pool->get($hostname, $cb, $noncache);
160 160
 			});
161 161
 			return;
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 				call_user_func($cb, false);
179 179
 				return;
180 180
 			}
181
-			$q =	Binary::labels($hostname) .  // domain
181
+			$q = Binary::labels($hostname) . // domain
182 182
 					Binary::word($qtypeInt) . 
183 183
 					Binary::word($qclassInt);
184 184
 			$QD[] = $q;
Please login to merge, or discard this patch.
lib/MySQLClient.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -8,54 +8,54 @@
 block discarded – undo
8 8
  */
9 9
 class MySQLClient extends NetworkClient {
10 10
 
11
-	const CLIENT_LONG_PASSWORD     = 1;       // new more secure passwords
12
-	const CLIENT_FOUND_ROWS        = 2;       // Found instead of affected rows
13
-	const CLIENT_LONG_FLAG         = 4;       // Get all column flags
14
-	const CLIENT_CONNECT_WITH_DB   = 8;       // One can specify db on connect
15
-	const CLIENT_NO_SCHEMA         = 16;      // Don't allow database.table.column
16
-	const CLIENT_COMPRESS          = 32;      // Can use compression protocol
17
-	const CLIENT_ODBC              = 64;      // Odbc client
18
-	const CLIENT_LOCAL_FILES       = 128;     // Can use LOAD DATA LOCAL
19
-	const CLIENT_IGNORE_SPACE      = 256;     // Ignore spaces before '('
20
-	const CLIENT_PROTOCOL_41       = 512;     // New 4.1 protocol
21
-	const CLIENT_INTERACTIVE       = 1024;    // This is an interactive client
22
-	const CLIENT_SSL               = 2048;    // Switch to SSL after handshake
23
-	const CLIENT_IGNORE_SIGPIPE    = 4096;    // IGNORE sigpipes
24
-	const CLIENT_TRANSACTIONS      = 8192;    // Client knows about transactions
25
-	const CLIENT_RESERVED          = 16384;   // Old flag for 4.1 protocol
26
-	const CLIENT_SECURE_CONNECTION = 32768;   // New 4.1 authentication
27
-	const CLIENT_MULTI_STATEMENTS  = 65536;   // Enable/disable multi-stmt support
28
-	const CLIENT_MULTI_RESULTS     = 131072;  // Enable/disable multi-results
11
+	const CLIENT_LONG_PASSWORD     = 1; // new more secure passwords
12
+	const CLIENT_FOUND_ROWS        = 2; // Found instead of affected rows
13
+	const CLIENT_LONG_FLAG         = 4; // Get all column flags
14
+	const CLIENT_CONNECT_WITH_DB   = 8; // One can specify db on connect
15
+	const CLIENT_NO_SCHEMA         = 16; // Don't allow database.table.column
16
+	const CLIENT_COMPRESS          = 32; // Can use compression protocol
17
+	const CLIENT_ODBC              = 64; // Odbc client
18
+	const CLIENT_LOCAL_FILES       = 128; // Can use LOAD DATA LOCAL
19
+	const CLIENT_IGNORE_SPACE      = 256; // Ignore spaces before '('
20
+	const CLIENT_PROTOCOL_41       = 512; // New 4.1 protocol
21
+	const CLIENT_INTERACTIVE       = 1024; // This is an interactive client
22
+	const CLIENT_SSL               = 2048; // Switch to SSL after handshake
23
+	const CLIENT_IGNORE_SIGPIPE    = 4096; // IGNORE sigpipes
24
+	const CLIENT_TRANSACTIONS      = 8192; // Client knows about transactions
25
+	const CLIENT_RESERVED          = 16384; // Old flag for 4.1 protocol
26
+	const CLIENT_SECURE_CONNECTION = 32768; // New 4.1 authentication
27
+	const CLIENT_MULTI_STATEMENTS  = 65536; // Enable/disable multi-stmt support
28
+	const CLIENT_MULTI_RESULTS     = 131072; // Enable/disable multi-results
29 29
 
30
-	const COM_SLEEP               = 0x00;  // (none, this is an internal thread state)
31
-	const COM_QUIT                = 0x01;  // mysql_close
32
-	const COM_INIT_DB             = 0x02;  // mysql_select_db
33
-	const COM_QUERY               = 0x03;  // mysql_real_query
34
-	const COM_FIELD_LIST          = 0x04;  // mysql_list_fields
35
-	const COM_CREATE_DB           = 0x05;  // mysql_create_db (deprecated)
36
-	const COM_DROP_DB             = 0x06;  // mysql_drop_db (deprecated)
37
-	const COM_REFRESH             = 0x07;  // mysql_refresh
38
-	const COM_SHUTDOWN            = 0x08;  // mysql_shutdown
39
-	const COM_STATISTICS          = 0x09;  // mysql_stat
40
-	const COM_PROCESS_INFO        = 0x0a;  // mysql_list_processes
41
-	const COM_CONNECT             = 0x0b;  // (none, this is an internal thread state)
42
-	const COM_PROCESS_KILL        = 0x0c;  // mysql_kill
43
-	const COM_DEBUG               = 0x0d;  // mysql_dump_debug_info
44
-	const COM_PING                = 0x0e;  // mysql_ping
45
-	const COM_TIME                = 0x0f;  // (none, this is an internal thread state)
46
-	const COM_DELAYED_INSERT      = 0x10;  // (none, this is an internal thread state)
47
-	const COM_CHANGE_USER         = 0x11;  // mysql_change_user
48
-	const COM_BINLOG_DUMP         = 0x12;  // sent by the slave IO thread to request a binlog
49
-	const COM_TABLE_DUMP          = 0x13;  // LOAD TABLE ... FROM MASTER (deprecated)
50
-	const COM_CONNECT_OUT         = 0x14;  // (none, this is an internal thread state)
51
-	const COM_REGISTER_SLAVE      = 0x15;  // sent by the slave to register with the master (optional)
52
-	const COM_STMT_PREPARE        = 0x16;  // mysql_stmt_prepare
53
-	const COM_STMT_EXECUTE        = 0x17;  // mysql_stmt_execute
54
-	const COM_STMT_SEND_LONG_DATA = 0x18;  // mysql_stmt_send_long_data
55
-	const COM_STMT_CLOSE          = 0x19;  // mysql_stmt_close
56
-	const COM_STMT_RESET          = 0x1a;  // mysql_stmt_reset
57
-	const COM_SET_OPTION          = 0x1b;  // mysql_set_server_option
58
-	const COM_STMT_FETCH          = 0x1c;  // mysql_stmt_fetch
30
+	const COM_SLEEP               = 0x00; // (none, this is an internal thread state)
31
+	const COM_QUIT                = 0x01; // mysql_close
32
+	const COM_INIT_DB             = 0x02; // mysql_select_db
33
+	const COM_QUERY               = 0x03; // mysql_real_query
34
+	const COM_FIELD_LIST          = 0x04; // mysql_list_fields
35
+	const COM_CREATE_DB           = 0x05; // mysql_create_db (deprecated)
36
+	const COM_DROP_DB             = 0x06; // mysql_drop_db (deprecated)
37
+	const COM_REFRESH             = 0x07; // mysql_refresh
38
+	const COM_SHUTDOWN            = 0x08; // mysql_shutdown
39
+	const COM_STATISTICS          = 0x09; // mysql_stat
40
+	const COM_PROCESS_INFO        = 0x0a; // mysql_list_processes
41
+	const COM_CONNECT             = 0x0b; // (none, this is an internal thread state)
42
+	const COM_PROCESS_KILL        = 0x0c; // mysql_kill
43
+	const COM_DEBUG               = 0x0d; // mysql_dump_debug_info
44
+	const COM_PING                = 0x0e; // mysql_ping
45
+	const COM_TIME                = 0x0f; // (none, this is an internal thread state)
46
+	const COM_DELAYED_INSERT      = 0x10; // (none, this is an internal thread state)
47
+	const COM_CHANGE_USER         = 0x11; // mysql_change_user
48
+	const COM_BINLOG_DUMP         = 0x12; // sent by the slave IO thread to request a binlog
49
+	const COM_TABLE_DUMP          = 0x13; // LOAD TABLE ... FROM MASTER (deprecated)
50
+	const COM_CONNECT_OUT         = 0x14; // (none, this is an internal thread state)
51
+	const COM_REGISTER_SLAVE      = 0x15; // sent by the slave to register with the master (optional)
52
+	const COM_STMT_PREPARE        = 0x16; // mysql_stmt_prepare
53
+	const COM_STMT_EXECUTE        = 0x17; // mysql_stmt_execute
54
+	const COM_STMT_SEND_LONG_DATA = 0x18; // mysql_stmt_send_long_data
55
+	const COM_STMT_CLOSE          = 0x19; // mysql_stmt_close
56
+	const COM_STMT_RESET          = 0x1a; // mysql_stmt_reset
57
+	const COM_SET_OPTION          = 0x1b; // mysql_set_server_option
58
+	const COM_STMT_FETCH          = 0x1c; // mysql_stmt_fetch
59 59
 
60 60
 	const FIELD_TYPE_DECIMAL      = 0x00;
61 61
 	const FIELD_TYPE_TINY         = 0x01;
Please login to merge, or discard this patch.
app-servers/MongoNode.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 		if ($this->config->enable->value) {
48 48
 			$appInstance = $this;
49 49
 			
50
-			$this->LockClient->job(__CLASS__,TRUE,
51
-				function($command,$jobname,$client) use ($appInstance) {
50
+			$this->LockClient->job(__CLASS__, TRUE,
51
+				function($command, $jobname, $client) use ($appInstance) {
52 52
 					$appInstance->pushRequest(new MongoNode_ReplicationRequest($appInstance, $appInstance));
53 53
 				}
54 54
 			);
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
 		if (isset($o['_key'])) {
69 69
 			$this->cache->set($o['_key'], bson_encode($o));
70
-			$this->cache->set('_id.' . ((string)$o['_id']), $o['_key']);
70
+			$this->cache->set('_id.' . ((string) $o['_id']), $o['_key']);
71 71
 		}
72 72
 
73 73
 		if (isset($o['_ev'])) {
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 			Daemon::log(__METHOD__ . '(' . json_encode($o) . ')');
95 95
 		}
96 96
 	      
97
-		$this->cache->get('_id.' . ((string)$o['_id']),
97
+		$this->cache->get('_id.' . ((string) $o['_id']),
98 98
 			function($m) use ($o) {
99 99
 				if (is_string($m->result)) {
100 100
 					$m->appInstance->delete($m->result);
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 				$this->inited = TRUE;
185 185
 			    
186 186
 				$this->appInstance->cache->get('_rp',
187
-					function ($answer) use ($req) {
187
+					function($answer) use ($req) {
188 188
 						$req->inited = FALSE;
189 189
 						$e = explode(' ', $answer->result);
190 190
 					   
Please login to merge, or discard this patch.
old-code-for-refactoring/AsteriskDriver.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
 			return; // Not enough data buffered yet
264 264
 		}
265 265
 		elseif (strpos($this->buf, "\r\n\r\n") !== false) {
266
-			while(($line = $this->gets()) !== false) {
266
+			while (($line = $this->gets()) !== false) {
267 267
 				if ($line == "\r\n") {
268 268
 					$this->instate = AsteriskDriver::INPUT_STATE_END_OF_PACKET;
269
-					$packet =& $this->packets[$this->cnt];
269
+					$packet = & $this->packets[$this->cnt];
270 270
 					$this->cnt++;
271 271
 				} else {
272 272
 					$this->instate = AsteriskDriver::INPUT_STATE_PROCESSING;
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 					$this->packets[$this->cnt][$header] = $value;
275 275
 				}
276 276
 
277
-				if ((int)$this->cstate === AsteriskDriver::CONN_STATE_AUTH) {
277
+				if ((int) $this->cstate === AsteriskDriver::CONN_STATE_AUTH) {
278 278
 					if ($this->instate == AsteriskDriver::INPUT_STATE_END_OF_PACKET) {
279 279
 						if ($packet['response'] == 'success') {
280 280
 							if (
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 						}
318 318
 						// Response
319 319
 						elseif (isset($packet['actionid'])) {
320
-							$action_id =& $packet['actionid'];
320
+							$action_id = & $packet['actionid'];
321 321
 
322 322
 							if (isset($this->callbacks[$action_id])) {
323 323
 								if (isset($this->assertions[$action_id])) {
@@ -503,10 +503,10 @@  discard block
 block discarded – undo
503 503
 	 */
504 504
 	public function setVar($channel, $variable, $value, $callback) {
505 505
 		$cmd = "Action: SetVar\r\n";
506
-		if($channel) {
506
+		if ($channel) {
507 507
 			$cmd .= "Channel: " . trim($channel) . "\r\n";
508 508
 		}
509
-		if(isset($variable, $value)) {
509
+		if (isset($variable, $value)) {
510 510
 			$cmd .= "Variable: " . trim($variable) . "\r\n";
511 511
 			$cmd .= "Value: " . trim($value) . "\r\n";
512 512
 			$this->command($cmd, $callback);
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 	 */
541 541
 	public function status($callback, $channel = null) {
542 542
 		$cmd = "Action: Status\r\n";
543
-		if($channel !== null) {
543
+		if ($channel !== null) {
544 544
 			$cmd .= "Channel: " . trim($channel) . "\r\n";
545 545
 		}
546 546
 		$this->command($cmd, $callback, array('event' => 'statuscomplete'));
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 		}
661 661
 
662 662
 		$action_id = $this->uniqid();
663
-		if(!is_callable($callback, true)) {
663
+		if (!is_callable($callback, true)) {
664 664
 			$callback = false;
665 665
 		}
666 666
 		$this->callbacks[$action_id] = $callback;
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
 	 */
680 680
 	protected function implodeParams(array $params) {
681 681
 		$s = '';
682
-		foreach($params as $header => $value) {
682
+		foreach ($params as $header => $value) {
683 683
 			$s .= trim($header) . ": " . trim($value) . "\r\n";
684 684
 		}
685 685
 		return $s;
Please login to merge, or discard this patch.