Completed
Push — 123 ( d13f38 )
by Vasily
05:11
created
lib/Daemon_IPCThread.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 */
68 68
 	public function prepareSystemEnv() {
69 69
 		proc_nice(Daemon::$config->ipcthreadpriority->value);
70
-		register_shutdown_function(array($this,'shutdown'));
70
+		register_shutdown_function(array($this, 'shutdown'));
71 71
 		
72 72
 		$this->setproctitle(
73 73
 			Daemon::$runName . ': IPC process'
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		$error = error_get_last(); 
169 169
 		if ($error) {
170 170
 			if ($error['type'] === E_ERROR) {
171
-				$this->log('crashed by error \''.$error['message'].'\' at '.$error['file'].':'.$error['line']);
171
+				$this->log('crashed by error \'' . $error['message'] . '\' at ' . $error['file'] . ':' . $error['line']);
172 172
 			}
173 173
 
174 174
 		}
Please login to merge, or discard this patch.
lib/MongoClientAsyncCollection.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -162,7 +162,7 @@
 block discarded – undo
162 162
             'function () { '
163 163
                 . 'return db.autoincrement.findAndModify({ '
164 164
                 . 'query: {"_id":"' . $this->name . '"}, update: {$inc:{"id":1}}, new: true, upsert: true }); }',
165
-            function ($res) use ($cb) {
165
+            function($res) use ($cb) {
166 166
                 call_user_func($cb, $res);
167 167
             },
168 168
             $key
Please login to merge, or discard this patch.
lib/AsyncProcess.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -41,21 +41,21 @@  discard block
 block discarded – undo
41 41
 	public $outputErrors = false;
42 42
 
43 43
 	// @todo make methods setUser and setGroup, variables change to $user and $group with null values
44
-	public $setUser;                               // optinal SUID.
45
-	public $setGroup;                              // optional SGID.
44
+	public $setUser; // optinal SUID.
45
+	public $setGroup; // optional SGID.
46 46
 
47 47
 	// @todo the same, make a method setChroot
48
-	public $chroot = '/';                          // optional chroot.
48
+	public $chroot = '/'; // optional chroot.
49 49
 
50
-	public $env = array();                         // hash of environment's variables
50
+	public $env = array(); // hash of environment's variables
51 51
 
52 52
 	// @todo setCwd
53
-	public $cwd;                                   // optional chdir
54
-	public $errlogfile = '/tmp/cgi-errorlog.log';  // path to error logfile
55
-	public $args;                                  // array of arguments
53
+	public $cwd; // optional chdir
54
+	public $errlogfile = '/tmp/cgi-errorlog.log'; // path to error logfile
55
+	public $args; // array of arguments
56 56
 
57 57
 	// @todo setNice
58
-	public $nice;                                  // optional priority
58
+	public $nice; // optional priority
59 59
  
60 60
 	/**
61 61
 	 * AsyncProcess constructor
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 				&& isset($this->setGroup) 
141 141
 				&& ($this->setUser !== $this->setGroup)
142 142
 			) {
143
-				$this->cmd = 'sudo -g ' . escapeshellarg($this->setGroup). '  -u ' . escapeshellarg($this->setUser) . ' ' . $this->cmd;
143
+				$this->cmd = 'sudo -g ' . escapeshellarg($this->setGroup) . '  -u ' . escapeshellarg($this->setUser) . ' ' . $this->cmd;
144 144
 			} else {
145 145
 				$this->cmd = 'su ' . escapeshellarg($this->setGroup) . ' -c ' . escapeshellarg($this->cmd);
146 146
 			}
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 		}
156 156
 
157 157
 		$pipesDescr = array(
158
-			0 => array('pipe', 'r'),  // stdin is a pipe that the child will read from
159
-			1 => array('pipe', 'w'),  // stdout is a pipe that the child will write to
158
+			0 => array('pipe', 'r'), // stdin is a pipe that the child will read from
159
+			1 => array('pipe', 'w'), // stdout is a pipe that the child will write to
160 160
 		);
161 161
 
162 162
 		if (
Please login to merge, or discard this patch.
lib/WebSocketProtocolVE.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
                 goto char;
100 100
             };
101 101
             
102
-            return chr(self::BINARY) . $len . $data ;
102
+            return chr(self::BINARY) . $len . $data;
103 103
         }
104 104
         // String
105 105
         else {
106
-            return chr(self::STRING) . $data . "\xFF" ;
106
+            return chr(self::STRING) . $data . "\xFF";
107 107
         }
108 108
     }
109 109
 
@@ -111,31 +111,31 @@  discard block
 block discarded – undo
111 111
 		while ($this->connection && (($buflen = strlen($this->connection->buf)) >= 2)) {
112 112
 			$frametype = ord(binarySubstr($this->connection->buf, 0, 1)); 
113 113
             if (($frametype & 0x80) === 0x80) {
114
-                $len = 0 ;
115
-                $i = 0 ;
114
+                $len = 0;
115
+                $i = 0;
116 116
 
117 117
                 do {
118 118
                     $b = ord(binarySubstr($this->connection->buf, ++$i, 1));
119
-                    $n = $b & 0x7F ;
120
-                    $len *= 0x80 ;
121
-                    $len += $n ;
122
-                } while ($b > 0x80) ;
119
+                    $n = $b & 0x7F;
120
+                    $len *= 0x80;
121
+                    $len += $n;
122
+                } while ($b > 0x80);
123 123
 
124 124
                 if ($this->connection->pool->maxAllowedPacket <= $len)
125 125
                 {
126 126
                     // Too big packet
127
-                    $this->connection->finish() ;
128
-                    return FALSE ;
127
+                    $this->connection->finish();
128
+                    return FALSE;
129 129
                 }
130 130
 
131 131
                 if ($buflen < $len + 2)
132 132
                 {
133 133
                     // not enough data yet
134
-                    return FALSE ;
134
+                    return FALSE;
135 135
                 } 
136 136
                     
137
-                $decodedData = binarySubstr($this->connection->buf, 2, $len) ;
138
-                $this->connection->buf = binarySubstr($this->connection->buf, 2 + $len) ;
137
+                $decodedData = binarySubstr($this->connection->buf, 2, $len);
138
+                $this->connection->buf = binarySubstr($this->connection->buf, 2 + $len);
139 139
                   
140 140
                 $this->connection->onFrame($decodedData, $frametype);
141 141
             }
@@ -143,12 +143,12 @@  discard block
 block discarded – undo
143 143
             	if (($p = strpos($this->connection->buf, "\xFF")) !== FALSE) {
144 144
                     if ($this->connection->pool->maxAllowedPacket <= $p - 1) {                   {
145 145
                         // Too big packet
146
-                        $this->connection->finish() ;
147
-                        return FALSE ;
146
+                        $this->connection->finish();
147
+                        return FALSE;
148 148
                     }
149 149
                         
150
-                    $decodedData = binarySubstr($this->connection->buf, 1, $p - 1) ;                    
151
-                    $this->connection->buf = binarySubstr($this->connection->buf, $p + 1) ;                    
150
+                    $decodedData = binarySubstr($this->connection->buf, 1, $p - 1);                    
151
+                    $this->connection->buf = binarySubstr($this->connection->buf, $p + 1);                    
152 152
                     $this->connection->onFrame($decodedData, $frametype);
153 153
                     
154 154
                 }
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
                     if ($this->connection->pool->maxAllowedPacket <= strlen($this->connection->buf))
157 157
                     {
158 158
                         // Too big packet
159
-                        $this->connection->finish() ;
160
-                        return FALSE ;
159
+                        $this->connection->finish();
160
+                        return FALSE;
161 161
                     }
162 162
                 }
163 163
             }
Please login to merge, or discard this patch.
lib/NetworkClientConnection.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 	public $busy = false;
12 12
 	public $timeout = 60;
13 13
 	
14
-	public $onResponse;  // stack of onResponse callbacks
14
+	public $onResponse; // stack of onResponse callbacks
15 15
 	
16 16
 	public $alive = true;
17 17
 
Please login to merge, or discard this patch.
lib/ConnectionPool.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 class ConnectionPool extends ObjectStorage {
11 11
 
12
-	public $allowedClients  = null;
12
+	public $allowedClients = null;
13 13
 	public $connectionClass;
14 14
 	public $name;
15 15
 	public $config;
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 			if (isset(self::$instances[$key])) {
104 104
 				return self::$instances[$key];
105 105
 			}
106
-			$k = 'Pool:' . $class . ($arg !== '' ? ':' . $arg : '' );
106
+			$k = 'Pool:' . $class . ($arg !== '' ? ':' . $arg : '');
107 107
 			
108 108
 			$config = (isset(Daemon::$config->{$k}) && Daemon::$config->{$k} instanceof Daemon_ConfigSection) ? Daemon::$config->{$k}: new Daemon_ConfigSection;			
109 109
 			$obj = self::$instances[$key] = new $class($config);
@@ -129,16 +129,16 @@  discard block
 block discarded – undo
129 129
 			$k = strtolower(str_replace('-', '', $k));
130 130
 
131 131
 			if (!isset($this->config->{$k})) {
132
-			  if (is_scalar($v))	{
132
+			  if (is_scalar($v)) {
133 133
 					$this->config->{$k} = new Daemon_ConfigEntry($v);
134 134
 				} else {
135 135
 					$this->config->{$k} = $v;
136 136
 				}
137 137
 			} elseif ($v instanceof Daemon_ConfigSection) {
138 138
 			// @todo
139
-			}	else {
139
+			} else {
140 140
 				$current = $this->config->{$k};
141
-			  if (is_scalar($v))	{
141
+			  if (is_scalar($v)) {
142 142
 					$this->config->{$k} = new Daemon_ConfigEntry($v);
143 143
 				} else {
144 144
 					$this->config->{$k} = $v;
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
 					$socket->setDefaultPort($this->config->port->value);
267 267
 				}
268 268
 			} else {
269
-				if (stripos($addr,'tcp://') === 0) {
269
+				if (stripos($addr, 'tcp://') === 0) {
270 270
 					$addr = substr($addr, 6);
271 271
 				}
272
-				elseif (stripos($addr,'tcp:') === 0) {
272
+				elseif (stripos($addr, 'tcp:') === 0) {
273 273
 					$addr = substr($addr, 4);
274 274
 				}
275 275
 				$socket = new BoundTCPSocket($addr, $reuse);
Please login to merge, or discard this patch.
lib/Daemon.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	const SUPPORT_RUNKIT_SANDBOX         = 0;	
13 13
 	const SUPPORT_RUNKIT_MODIFY          = 1;
14 14
 	const SUPPORT_RUNKIT_INTERNAL_MODIFY = 2;
15
-	const SUPPORT_RUNKIT_IMPORT 		 = 3;
15
+	const SUPPORT_RUNKIT_IMPORT = 3;
16 16
 	const WSTATE_IDLE = 1;
17 17
 	const WSTATE_BUSY = 2;
18 18
 	const WSTATE_SHUTDOWN = 3;
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 		Daemon::$reusePort = 1 === preg_match("~BSD~i", php_uname('s'));
80 80
 		
81 81
 		if (Daemon::$reusePort && !defined("SO_REUSEPORT"))
82
-		    define("SO_REUSEPORT", 0x200);	// FIXME: this is a BSD-only hack
82
+		    define("SO_REUSEPORT", 0x200); // FIXME: this is a BSD-only hack
83 83
 	}
84 84
 
85 85
 	public static function loadModuleIfAbsent($mod) {
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
 
133 133
 	public static function uncaughtExceptionHandler(Exception $e) {
134 134
 		$msg = $e->getMessage();
135
-		Daemon::log('Uncaught '.get_class($e).' (' . $e->getCode() . ')' . (strlen($msg) ? ': ' . $msg : ''). ".\n" . $e->getTraceAsString());
135
+		Daemon::log('Uncaught ' . get_class($e) . ' (' . $e->getCode() . ')' . (strlen($msg) ? ': ' . $msg : '') . ".\n" . $e->getTraceAsString());
136 136
 		if (Daemon::$req) {
137
-			Daemon::$req->out('<b>Uncaught '.get_class($e).' (' . $e->getCode() . ')</b>' . (strlen($msg) ? ': ' . $msg : ''). '.<br />');
137
+			Daemon::$req->out('<b>Uncaught ' . get_class($e) . ' (' . $e->getCode() . ')</b>' . (strlen($msg) ? ': ' . $msg : '') . '.<br />');
138 138
 		}
139 139
 	}
140 140
 
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
 			E_USER_DEPRECATED => 'Deprecated (userland)',
165 165
 		);
166 166
 		$errtype = $errtypes[$errno];
167
-		Daemon::log($errtype . ': '.$errstr.' in ' . $errfile . ':' . $errline . "\n" . Debug::backtrace());
167
+		Daemon::log($errtype . ': ' . $errstr . ' in ' . $errfile . ':' . $errline . "\n" . Debug::backtrace());
168 168
 		if (Daemon::$req) {
169
-			Daemon::$req->out('<strong>' . $errtype . '</strong>: ' . $errstr . ' in ' . basename($errfile) . ':' . $errline.'<br />');
169
+			Daemon::$req->out('<strong>' . $errtype . '</strong>: ' . $errstr . ' in ' . basename($errfile) . ':' . $errline . '<br />');
170 170
 		}
171 171
 	}
172 172
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 		$req->attrs->cookie = $_REQUEST;
291 291
 		$req->attrs->server = $_SERVER;
292 292
 		$req->attrs->files = $_FILES;
293
-		$req->attrs->session = isset($_SESSION)?$_SESSION:NULL;
293
+		$req->attrs->session = isset($_SESSION) ? $_SESSION : NULL;
294 294
 		$req->attrs->connId = 1;
295 295
 		$req->attrs->trole = 'RESPONDER';
296 296
 		$req->attrs->flags = 0;
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 		$apaths = explode(';', $paths);
318 318
 		$found = false;
319 319
 
320
-		foreach($apaths as $path) {
320
+		foreach ($apaths as $path) {
321 321
 			if (is_file($p = realpath($path))) {
322 322
 				$found = true;
323 323
 
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 				chown(Daemon::$config->logstorage->value, Daemon::$config->user->value); // @TODO: rewrite to async I/O
356 356
 			}
357 357
 			if ((Daemon::$process instanceof Daemon_WorkerThread) && FS::$supported) {
358
-				FS::open(Daemon::$config->logstorage->value, 'a!', function ($file) {
358
+				FS::open(Daemon::$config->logstorage->value, 'a!', function($file) {
359 359
 					Daemon::$logpointerAsync = $file;
360 360
 					if (!$file) {
361 361
 						return;
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 		if (is_resource(STDERR)) {
464 464
 			fwrite(STDERR, '[PHPD] ' . $msg . "\n");
465 465
 		}
466
-		$msg = '[' . date('D, j M Y H:i:s', $mt[1]) . '.' . sprintf('%06d', $mt[0]*1000000) . ' ' . date('O') . '] ' . $msg . "\n";
466
+		$msg = '[' . date('D, j M Y H:i:s', $mt[1]) . '.' . sprintf('%06d', $mt[0] * 1000000) . ' ' . date('O') . '] ' . $msg . "\n";
467 467
 		if (Daemon::$logpointerAsync) {
468 468
 			Daemon::$logpointerAsync->write($msg);
469 469
 		} elseif (Daemon::$logpointer) {
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	public static function date_period_text($date_start, $date_finish) {
548 548
 		$result = Daemon::date_period($date_start, $date_finish);
549 549
 
550
-		$str  = '';
550
+		$str = '';
551 551
 
552 552
 		if ($result[5] > 0) {
553 553
 			$str .= $result[5] . ' year. ';
Please login to merge, or discard this patch.
lib/Daemon_ConfigEntryConfigFile.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@
 block discarded – undo
15 15
 		if (Daemon::$process instanceof Daemon_MasterThread) {
16 16
 			if (Daemon::$config->autoreload->value > 0) {
17 17
 				if ($old) {
18
-					$e = explode(';',$old);
18
+					$e = explode(';', $old);
19 19
 					foreach ($e as $path) {
20 20
 						Daemon::$process->fileWatcher->rmWatch($path);
21 21
 					}
22 22
 				}
23
-				$e = explode(';',$this->value);
23
+				$e = explode(';', $this->value);
24 24
 				foreach ($e as $path) {
25 25
 					Daemon::$process->fileWatcher->addWatch($path, array(Daemon::$process, 'sighup'));
26 26
 				}
Please login to merge, or discard this patch.
lib/IRCBouncer.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
 
58 58
 	public function getConnection($url) {
59 59
 		$pool = $this;
60
-		$this->client->getConnection($url, function ($conn) use ($pool, $url) {
60
+		$this->client->getConnection($url, function($conn) use ($pool, $url) {
61 61
 			$pool->conn = $conn;
62 62
 			$conn->attachedClients = new ObjectStorage;
63 63
 			if ($conn->connected) {
64
-				Daemon::log('IRC bot connected at '.$url);
64
+				Daemon::log('IRC bot connected at ' . $url);
65 65
 				$conn->join($pool->config->defaultchannels->value);
66 66
 				$conn->bind('motd', function($conn) {
67 67
 					//Daemon::log($conn->motd);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 					$conn->attachedClients->each('commandArr', $from['orig'], $cmd, $args);
85 85
 				});
86 86
 				$conn->bind('privateMsg', function($conn, $msg) {
87
-					Daemon::log('IRCBouncer: got private message \''.$msg['body'].'\' from \''.$msg['from']['orig'].'\'');
87
+					Daemon::log('IRCBouncer: got private message \'' . $msg['body'] . '\' from \'' . $msg['from']['orig'] . '\'');
88 88
 				});
89 89
 				$conn->bind('msg', function($conn, $msg) use ($pool) {
90 90
 					$msg['ts'] = microtime(true);
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 				});
102 102
 			}
103 103
 			else {
104
-				Daemon::log('IRCBouncer: unable to connect ('.$url.')');
104
+				Daemon::log('IRCBouncer: unable to connect (' . $url . ')');
105 105
 			}
106 106
 		});
107 107
 	}
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
 	public function ping() {
173 173
 		$this->lastPingTS = microtime(true);
174
-		$this->writeln('PING :'.$this->usermask);
174
+		$this->writeln('PING :' . $this->usermask);
175 175
 		Timer::setTimeout($this->keepaliveTimer);
176 176
 	}
177 177
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 		}
193 193
 		$this->writeln($line);
194 194
 		if ($this->pool->protologging && !in_array($cmd, array('PONG'))) {
195
-			Daemon::log('=>=>=>=> '.json_encode($line));
195
+			Daemon::log('=>=>=>=> ' . json_encode($line));
196 196
 		}
197 197
 	}
198 198
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 			$from = $this->pool->config->servername->value;
202 202
 		}
203 203
 		if (is_string($args)) {
204
-			Daemon::log(get_class($this).'->commandArr: args is string');
204
+			Daemon::log(get_class($this) . '->commandArr: args is string');
205 205
 			return;
206 206
 		}
207 207
 		$cmd = IRC::getCodeByCommand($cmd);
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		}
217 217
 		$this->writeln($line);
218 218
 		if ($this->pool->protologging && !in_array($cmd, array('PONG'))) {
219
-			Daemon::log('=>=>=>=> '.json_encode($line));
219
+			Daemon::log('=>=>=>=> ' . json_encode($line));
220 220
 		}
221 221
 	}
222 222
 
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		} else {
235 235
 			return;
236 236
 		}
237
-		$this->msgFromBNC('Attached to '.$this->attachedServer->url);
237
+		$this->msgFromBNC('Attached to ' . $this->attachedServer->url);
238 238
 		$this->usermask = $this->attachedServer->nick . '!' . $this->attachedServer->user . '@' . $this->pool->config->servername->value;
239 239
 		$this->command(null, 'RPL_WELCOME', $this->attachedServer->nick, 'Welcome to phpDaemon bouncer -- ' . $this->pool->config->servername->value);
240 240
 		foreach ($this->attachedServer->channels as $chan) {
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 					}
307 307
 
308 308
 				} else {
309
-					$this->msgFromBNC('Unknown command: '.$msg);
309
+					$this->msgFromBNC('Unknown command: ' . $msg);
310 310
 				}
311 311
 				return;
312 312
 			}
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 			$this->attachedServer->commandArr($cmd, $args);
323 323
 		}
324 324
 		if ($this->protologging) {
325
-			Daemon::$process->log('<=<=<=< '.$cmd.': '.json_encode($args));
325
+			Daemon::$process->log('<=<=<=< ' . $cmd . ': ' . json_encode($args));
326 326
 		}
327 327
 	}
328 328
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 		if ($this->usermask === null) {
331 331
 			return;
332 332
 		}
333
-		$this->command('$!@' . $this->pool->config->servername->value, 'PRIVMSG' , $this->usermask, $msg);
333
+		$this->command('$!@' . $this->pool->config->servername->value, 'PRIVMSG', $this->usermask, $msg);
334 334
 	}
335 335
 
336 336
 	/**
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 
369 369
 			if (ctype_digit($cmd)) {
370 370
 				$code = (int) $cmd;
371
-				$cmd = isset(IRC::$codes[$code]) ? IRC::$codes[$code] : 'UNKNOWN-'.$code;
371
+				$cmd = isset(IRC::$codes[$code]) ? IRC::$codes[$code] : 'UNKNOWN-' . $code;
372 372
 			}
373 373
 			$this->onCommand($cmd, $args);
374 374
 		}
Please login to merge, or discard this patch.