Completed
Push — 123 ( d13f38 )
by Vasily
05:11
created
lib/XMPPRoster.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 	public function __construct($xmpp) {
11 11
 		$this->xmpp = $xmpp;
12 12
 
13
-		$this->xmpp->xml->addXPathHandler('{jabber:client}presence', function ($xml) {
13
+		$this->xmpp->xml->addXPathHandler('{jabber:client}presence', function($xml) {
14 14
 			$payload = array();
15 15
 			$payload['type'] = (isset($xml->attrs['type'])) ? $xml->attrs['type'] : 'available';
16 16
 			$payload['show'] = (isset($xml->sub('show')->data)) ? $xml->sub('show')->data : $payload['type'];
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
25 25
 				$this->setPresence($payload['from'], $payload['priority'], $payload['show'], $payload['status']);
26 26
 			}
27 27
 			//Daemon::log("Presence: {$payload['from']} [{$payload['show']}] {$payload['status']}");
28
-			if(array_key_exists('type', $xml->attrs) and $xml->attrs['type'] == 'subscribe') {
29
-				if($this->auto_subscribe) {
28
+			if (array_key_exists('type', $xml->attrs) and $xml->attrs['type'] == 'subscribe') {
29
+				if ($this->auto_subscribe) {
30 30
 					$this->xmpp->sendXML("<presence type='subscribed' to='{$xml->attrs['from']}' from='{$this->xmpp->fulljid}' />");
31 31
 					$this->xmpp->sendXML("<presence type='subscribe' to='{$xml->attrs['from']}' from='{$this->xmpp->fulljid}' />");
32 32
 				}
33 33
 				$this->event('subscription_requested', $payload);
34
-			} elseif(array_key_exists('type', $xml->attrs) and $xml->attrs['type'] == 'subscribed') {
34
+			} elseif (array_key_exists('type', $xml->attrs) and $xml->attrs['type'] == 'subscribed') {
35 35
 				$this->event('subscription_accepted', $payload);
36 36
 			} else {
37 37
 				$this->event('presence', $payload);
@@ -46,20 +46,20 @@  discard block
 block discarded – undo
46 46
 	}
47 47
 
48 48
 	public function setSubscription($jid, $type, $cb = null) {
49
-		$this->rosterSet('<item jid="'.htmlspecialchars($jid).'" subscription="'.htmlspecialchars($type).'" />', $cb);
49
+		$this->rosterSet('<item jid="' . htmlspecialchars($jid) . '" subscription="' . htmlspecialchars($type) . '" />', $cb);
50 50
 	} 
51 51
 	public function fetch($cb = null) {
52
-		$this->xmpp->queryGet($this->ns, function ($xml) use ($cb) {
52
+		$this->xmpp->queryGet($this->ns, function($xml) use ($cb) {
53 53
 			$status = "result";
54 54
 			$xmlroster = $xml->sub('query');
55 55
 			$contacts = array();
56
-			foreach($xmlroster->subs as $item) {
56
+			foreach ($xmlroster->subs as $item) {
57 57
 				$groups = array();
58 58
 				if ($item->name == 'item') {
59 59
 					$jid = $item->attrs['jid']; //REQUIRED
60 60
 					$name = isset($item->attrs['name']) ? $item->attrs['name'] : ''; //MAY
61 61
 					$subscription = $item->attrs['subscription'];
62
-					foreach($item->subs as $subitem) {
62
+					foreach ($item->subs as $subitem) {
63 63
 						if ($subitem->name == 'group') {
64 64
 							$groups[] = $subitem->data;
65 65
 						}
@@ -70,12 +70,12 @@  discard block
 block discarded – undo
70 70
 				}
71 71
 			}
72 72
 			if ($status == "result") { //No errors, add contacts
73
-				foreach($contacts as $contact) {
73
+				foreach ($contacts as $contact) {
74 74
 					$this->_addContact($contact[0], $contact[1], $contact[2], $contact[3]);
75 75
 				}
76 76
 			}
77 77
 			if ($xml->attrs['type'] == 'set') {
78
-				$this->xmpp->sendXML('<iq type="reply" id="'.$xml->attrs['id'].'" to="'.$xml->attrs['from'].'" />');
78
+				$this->xmpp->sendXML('<iq type="reply" id="' . $xml->attrs['id'] . '" to="' . $xml->attrs['from'] . '" />');
79 79
 			}
80 80
 			if ($cb) {
81 81
 				call_user_func($cb, $status);
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 * @param string $name
110 110
 	 * @param array $groups
111 111
 	 */
112
-	public function _addContact($jid, $subscription, $name='', $groups=array()) {
112
+	public function _addContact($jid, $subscription, $name = '', $groups = array()) {
113 113
 		$contact = array('jid' => $jid, 'subscription' => $subscription, 'name' => $name, 'groups' => $groups);
114 114
 		if ($this->isContact($jid)) {
115 115
 			$this->roster_array[$jid]['contact'] = $contact;
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
 	public function getPresence($jid) {
171 171
 		$split = split("/", $jid);
172 172
 		$jid = $split[0];
173
-		if($this->isContact($jid)) {
173
+		if ($this->isContact($jid)) {
174 174
 			$current = array('resource' => '', 'active' => '', 'priority' => -129, 'show' => '', 'status' => ''); //Priorities can only be -128 = 127
175
-			foreach($this->roster_array[$jid]['presence'] as $resource => $presence) {
175
+			foreach ($this->roster_array[$jid]['presence'] as $resource => $presence) {
176 176
 				//Highest available priority or just highest priority
177 177
 				if ($presence['priority'] > $current['priority'] and (($presence['show'] == "chat" or $presence['show'] == "available") or ($current['show'] != "chat" or $current['show'] != "available"))) {
178 178
 					$current = $presence;
Please login to merge, or discard this patch.
lib/Daemon_WorkerThread.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		$this->prepareSystemEnv();
69 69
 		$this->overrideNativeFuncs();
70 70
 
71
-		$this->setState(Daemon::WSTATE_INIT);;
71
+		$this->setState(Daemon::WSTATE_INIT); ;
72 72
 		$this->dnsBase = new EventDnsBase($this->eventBase, true); 
73 73
 		$this->registerEventSignals();
74 74
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 			Daemon::callAutoGC();
107 107
 
108 108
 			$event->timeout();
109
-		}, 1e6 * 1,	'breakMainLoopCheck');
109
+		}, 1e6 * 1, 'breakMainLoopCheck');
110 110
 		if (Daemon::$config->autoreload->value > 0) {
111 111
 			Timer::add(function($event) {
112 112
 				$self = Daemon::$process;
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 					$cache = array_slice($cache, $maxCacheSize);
250 250
 				}
251 251
 
252
-				$cache[$key] = array($cb = eval('return function('.$arg.'){'.$body.'};'), 0);
252
+				$cache[$key] = array($cb = eval('return function(' . $arg . '){' . $body . '};'), 0);
253 253
 				return $cb;
254 254
 			}
255 255
 		}
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	public function prepareSystemEnv() {
263 263
 		proc_nice(Daemon::$config->workerpriority->value);
264 264
 		
265
-		register_shutdown_function(array($this,'shutdown'));
265
+		register_shutdown_function(array($this, 'shutdown'));
266 266
 		
267 267
 		$this->setproctitle(
268 268
 			Daemon::$runName . ': worker process'
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 		$error = error_get_last(); 
424 424
 		if ($error) {
425 425
 			if ($error['type'] === E_ERROR) {
426
-				Daemon::log('W#' . $this->pid . ' crashed by error \''.$error['message'].'\' at '.$error['file'].':'.$error['line']);
426
+				Daemon::log('W#' . $this->pid . ' crashed by error \'' . $error['message'] . '\' at ' . $error['file'] . ':' . $error['line']);
427 427
 			}
428 428
 
429 429
 		}
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 
467 467
 		unset(Timer::$list['breakMainLoopCheck']);
468 468
 
469
-		Timer::add(function($event) 	{
469
+		Timer::add(function($event) {
470 470
 			$self = Daemon::$process;
471 471
 
472 472
 			$self->reloadReady = $self->appInstancesReloadReady();
Please login to merge, or discard this patch.
lib/HTTPClient.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		if (isset($u['path'])) {
81 81
 			$uri .= $u['path'];
82 82
 			if (isset($u['query'])) {
83
-				$uri .= '?'.$u['query'];
83
+				$uri .= '?' . $u['query'];
84 84
 			}
85 85
 		}
86 86
 		return array($u['host'], $uri, isset($u['port']) ? $u['port'] : null);
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
 		if (!isset($params['version'])) {
119 119
 			$params['version'] = '1.1';
120 120
 		}
121
-		$this->writeln('GET '.$params['uri']. ' HTTP/'.$params['version']);
122
-		$this->writeln('Host: '.$params['host']);
121
+		$this->writeln('GET ' . $params['uri'] . ' HTTP/' . $params['version']);
122
+		$this->writeln('Host: ' . $params['host']);
123 123
 		if ($this->pool->config->expose->value) {
124
-			$this->writeln('User-Agent: phpDaemon/'.Daemon::$version);
124
+			$this->writeln('User-Agent: phpDaemon/' . Daemon::$version);
125 125
 		}
126 126
 		if (isset($params['cookie']) && sizeof($params['cookie'])) {
127
-			$this->writeln('Cookie: '.http_build_query($this->cookie, '', '; '));
127
+			$this->writeln('Cookie: ' . http_build_query($this->cookie, '', '; '));
128 128
 		}
129 129
 		if (isset($params['headers'])) {
130 130
 			$this->customRequestHeaders($params['headers']);
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
                     $this->writeln($item);
144 144
                 }
145 145
 				elseif (is_array($item)) {
146
-					$this->writeln($item[0].': '.$item[1]); // @TODO: prevent injections?
146
+					$this->writeln($item[0] . ': ' . $item[1]); // @TODO: prevent injections?
147 147
 				}
148 148
 			}
149 149
 			else {
150
-				$this->writeln($key.': '.$item);
150
+				$this->writeln($key . ': ' . $item);
151 151
 			}
152 152
 		}
153 153
 	}
@@ -172,13 +172,13 @@  discard block
 block discarded – undo
172 172
 		if (!isset($params['contentType'])) {
173 173
 			$params['contentType'] = 'application/x-www-form-urlencoded';
174 174
 		}
175
-		$this->writeln('POST '.$params['uri']. ' HTTP/'.$params['version']);
176
-		$this->writeln('Host: '.$params['host']);
175
+		$this->writeln('POST ' . $params['uri'] . ' HTTP/' . $params['version']);
176
+		$this->writeln('Host: ' . $params['host']);
177 177
 		if ($this->pool->config->expose->value) {
178
-			$this->writeln('User-Agent: phpDaemon/'.Daemon::$version);
178
+			$this->writeln('User-Agent: phpDaemon/' . Daemon::$version);
179 179
 		}
180 180
 		if (isset($params['cookie']) && sizeof($params['cookie'])) {
181
-			$this->writeln('Cookie: '.http_build_query($this->cookie, '', '; '));
181
+			$this->writeln('Cookie: ' . http_build_query($this->cookie, '', '; '));
182 182
 		}
183 183
 		$body = '';
184 184
 		foreach ($data as $k => $v) {
Please login to merge, or discard this patch.
lib/BoundUDPSocket.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
 		do {
91 91
 			$l = @socket_recvfrom($this->fd, $buf, 10240, MSG_DONTWAIT, $host, $port);
92 92
 			if ($l) {
93
-				$key = '['.$host . ']:' . $port;
93
+				$key = '[' . $host . ']:' . $port;
94 94
 				if (!isset($this->portsMap[$key])) {
95 95
 
96 96
 					if ($this->pool->allowedClients !== null) {
Please login to merge, or discard this patch.
lib/ValveClient.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -19,9 +19,9 @@  discard block
 block discarded – undo
19 19
 	
20 20
 	public static $zombie = 0;
21 21
 
22
-	public function request($addr, $name, $data,  $cb) {
22
+	public function request($addr, $name, $data, $cb) {
23 23
 		$e = explode(':', $addr);
24
-		$this->getConnection('valve://[udp:' . $e[0] . ']' . (isset($e[1]) ? ':'.$e[1] : '') . '/', function($conn) use ($cb, $addr, $data, $name) {
24
+		$this->getConnection('valve://[udp:' . $e[0] . ']' . (isset($e[1]) ? ':' . $e[1] : '') . '/', function($conn) use ($cb, $addr, $data, $name) {
25 25
 			if (!$conn->connected) {
26 26
 				call_user_func($cb, $conn, false);
27 27
 				return;
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
 
34 34
 	public function ping($addr, $cb) {
35 35
 		$e = explode(':', $addr);
36
-		$this->getConnection('valve://[udp:' . $e[0] . ']' . (isset($e[1]) ? ':'.$e[1] : '') . '/ping', function($conn) use ($cb) {
36
+		$this->getConnection('valve://[udp:' . $e[0] . ']' . (isset($e[1]) ? ':' . $e[1] : '') . '/ping', function($conn) use ($cb) {
37 37
 			if (!$conn->connected) {
38 38
 				call_user_func($cb, $conn, false);
39 39
 				return;
40 40
 			}
41 41
 			$mt = microtime(true);
42
-			$conn->request('ping', null, function ($conn, $success) use ($mt, $cb) {
42
+			$conn->request('ping', null, function($conn, $success) use ($mt, $cb) {
43 43
 				call_user_func($cb, $conn, $success ? (microtime(true) - $mt) : false);
44 44
 			});
45 45
 		});
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	}
51 51
 
52 52
 	public function requestPlayers($addr, $cb) {
53
-		$this->request($addr, 'challenge', null, function ($conn, $result) use ($cb) {
53
+		$this->request($addr, 'challenge', null, function($conn, $result) use ($cb) {
54 54
 			if (is_array($result)) {
55 55
 				$cb($conn, $result);
56 56
 				return;
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	public $timeout = 1;
78 78
 
79 79
 	public function requestPlayers($cb) {
80
-		$this->request('challenge', null, function ($conn, $result) use ($cb) {
80
+		$this->request('challenge', null, function($conn, $result) use ($cb) {
81 81
 			if (is_array($result)) {
82 82
 				call_user_func($cb, $conn, $result);
83 83
 				return;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		for ($i = 1; $i < $playersn; ++$i) {
160 160
 			$n = Binary::getByte($st);
161 161
 			$name = Binary::getString($st);
162
-			$score = Binary::getDWord($st,TRUE);
162
+			$score = Binary::getDWord($st, TRUE);
163 163
 			if (strlen($st) === 0) {
164 164
 				break;
165 165
 			}
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 				$info['mod_website'] = Binary::getString($st);
215 215
 				$info['mod_downloadserver'] = Binary::getString($st);
216 216
 				$info['mod_unused'] = Binary::getString($st);
217
-				$info['mod_version'] = Binary::getDWord($st,TRUE);
217
+				$info['mod_version'] = Binary::getDWord($st, TRUE);
218 218
 				$info['mod_size'] = Binary::getDWord($st);
219 219
 				$info['mod_serverside'] = Binary::getByte($st);
220 220
 				$info['mod_customdll'] = Binary::getByte($st);
Please login to merge, or discard this patch.
lib/MongoClientAsync.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
 	
11 11
 	public $requests    = array(); // Pending requests
12 12
 	public $cursors     = array(); // Active cursors
13
-	public $lastReqId   = 0;       // ID of the last request
13
+	public $lastReqId   = 0; // ID of the last request
14 14
 	public $collections = array(); // Objects of MongoClientAsyncCollection
15
-	public $dbname      = '';      // Current database
16
-	public $lastRequestConnection;    // Holds last used MongoClientAsyncConnection object.
15
+	public $dbname      = ''; // Current database
16
+	public $lastRequestConnection; // Holds last used MongoClientAsyncConnection object.
17 17
 
18 18
 	/* Codes of operations */
19 19
 	const OP_REPLY        = 1; 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	const OP_DELETE       = 2006;
26 26
 	const OP_KILL_CURSORS = 2007;
27 27
 
28
-	public $cache;                 // object of MemcacheClient
28
+	public $cache; // object of MemcacheClient
29 29
 
30 30
 	/**
31 31
 	 * Setting default config options
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	public function request($key, $opcode, $data, $reply = false) {
88 88
 		$reqId = ++$this->lastReqId;
89
-		$cb = function ($conn) use ($opcode, $data, $reply, $reqId) {
89
+		$cb = function($conn) use ($opcode, $data, $reply, $reqId) {
90 90
 			if (!$conn->connected) {
91 91
 				throw new MongoClientConnectionAsyncFinished;
92 92
 			}
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	public function findOne($p, $callback, $key = '') {
218 218
 		if (isset($p['cachekey'])) {
219 219
 			$db = $this;
220
-			$this->cache->get($p['cachekey'], function($r) use ($db,  $p,  $callback,  $key) {
220
+			$this->cache->get($p['cachekey'], function($r) use ($db, $p, $callback, $key) {
221 221
 				if ($r->result !== NULL) {
222 222
 					call_user_func($callback, bson_decode($r->result));
223 223
 				} else {
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 		}
616 616
 		
617 617
 		if (strpos($p['col'], '.') === false) {
618
-			$p['col'] = $this->dbname.'.'.$p['col'];
618
+			$p['col'] = $this->dbname . '.' . $p['col'];
619 619
 		}
620 620
 		
621 621
 		$e = explode('.', $p['col']);
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 		);
631 631
 		
632 632
 		if (isset($p[$k = 'cond'])) {
633
-			$query['group'][$k]= $p[$k];
633
+			$query['group'][$k] = $p[$k];
634 634
 		}
635 635
 		
636 636
 		if (isset($p[$k = 'finalize'])) {
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 	 * @param string Optional. Distribution key.
726 726
 	 * @return object MongoId
727 727
 	 */
728
-	public function insert($col, $doc = array(), $cb = NULL,  $key = '') {
728
+	public function insert($col, $doc = array(), $cb = NULL, $key = '') {
729 729
 		if (strpos($col, '.') === false) {
730 730
 			$col = $this->dbname . '.' . $col;
731 731
 		}
Please login to merge, or discard this patch.
lib/RedisClientConnection.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,15 +9,15 @@
 block discarded – undo
9 9
 
10 10
 class RedisClientConnection extends NetworkClientConnection {
11 11
 
12
-	public $result = null;      	// current result (array)
12
+	public $result = null; // current result (array)
13 13
 	public $resultLength = 0;
14
-	public $resultSize = 0;			// number of received array items in result
14
+	public $resultSize = 0; // number of received array items in result
15 15
 	public $value = '';
16
-	public $valueLength = 0;        // length of incoming value
17
-	public $valueSize = 0;         // size of received part of the value
18
-	public $error;                 // error message
19
-	public $key;                   // current incoming key
20
-	public $EOL = "\r\n";			// EOL for gets() and writeln()
16
+	public $valueLength = 0; // length of incoming value
17
+	public $valueSize = 0; // size of received part of the value
18
+	public $error; // error message
19
+	public $key; // current incoming key
20
+	public $EOL = "\r\n"; // EOL for gets() and writeln()
21 21
 	const STATE_BINARY = 1;
22 22
 
23 23
 	/**
Please login to merge, or discard this patch.
lib/RedisClient.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@
 block discarded – undo
26 26
 
27 27
 	public function __call($name, $args) {
28 28
 		$onResponse = null;		
29
-		if (($e = end($args)) && (is_array($e) || is_object($e)) &&	is_callable($e)) {
30
-			$onResponse= array_pop($args);
29
+		if (($e = end($args)) && (is_array($e) || is_object($e)) && is_callable($e)) {
30
+			$onResponse = array_pop($args);
31 31
 		}
32 32
 		reset($args);
33 33
 		$name = strtoupper($name);
Please login to merge, or discard this patch.
lib/Connection.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 			if (@inet_pton($host) === false) { // dirty condition check
173 173
 				DNSClient::getInstance()->resolve($host, function($result) use ($host) {
174 174
 					if ($result === false) {
175
-						Daemon::log(get_class($this).'->connectTo (raw) : enable to resolve hostname: '.$host);
175
+						Daemon::log(get_class($this) . '->connectTo (raw) : enable to resolve hostname: ' . $host);
176 176
 						$this->onFailureEvent(null);
177 177
 						return;
178 178
 					}
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 					} else {
185 185
 						$real = $result;
186 186
 					}
187
-					$this->connectTo('raw:'. $real);
187
+					$this->connectTo('raw:' . $real);
188 188
 				});
189 189
 				return;
190 190
 			}
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			if ($pton === false) { // dirty condition check
211 211
 				DNSClient::getInstance()->resolve($host, function($result) use ($host) {
212 212
 					if ($result === false) {
213
-						Daemon::log(get_class($this).'->connectTo (udp) : enable to resolve hostname: '.$host);
213
+						Daemon::log(get_class($this) . '->connectTo (udp) : enable to resolve hostname: ' . $host);
214 214
 						$this->onStateEvent($this->bev, EventBufferEvent::ERROR);
215 215
 						return;
216 216
 					}
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 			if ($pton === false) { // dirty condition check
257 257
 				DNSClient::getInstance()->resolve($this->host, function($result) use ($host) {
258 258
 					if ($result === false) {
259
-						Daemon::log(get_class($this).'->connectTo (tcp) : enable to resolve hostname: '.$host);
259
+						Daemon::log(get_class($this) . '->connectTo (tcp) : enable to resolve hostname: ' . $host);
260 260
 						$this->onStateEvent($this->bev, EventBufferEvent::ERROR);
261 261
 						return;
262 262
 					}
Please login to merge, or discard this patch.