Passed
Push — develop ( 25ff30...23fbc2 )
by Hennik
01:03 queued 10s
created
demo/check_status.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(empty($argv[1])) {
2
+if (empty($argv[1])) {
3 3
 	die('Specify the ID of a job to monitor the status of.');
4 4
 }
5 5
 
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
 //Resque::setBackend('redis://user:[email protected]:3432/2');
13 13
 
14 14
 $status = new Resque_Job_Status($argv[1]);
15
-if(!$status->isTracking()) {
15
+if (!$status->isTracking()) {
16 16
 	die("Resque is not tracking the status of this job.\n");
17 17
 }
18 18
 
19
-echo "Tracking status of ".$argv[1].". Press [break] to stop.\n\n";
20
-while(true) {
21
-	fwrite(STDOUT, "Status of ".$argv[1]." is: ".$status->get()."\n");
19
+echo "Tracking status of " . $argv[1] . ". Press [break] to stop.\n\n";
20
+while (true) {
21
+	fwrite(STDOUT, "Status of " . $argv[1] . " is: " . $status->get() . "\n");
22 22
 	sleep(1);
23 23
 }
24 24
\ No newline at end of file
Please login to merge, or discard this patch.
demo/queue.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(empty($argv[1])) {
2
+if (empty($argv[1])) {
3 3
 	die('Specify the name of a job to add. e.g, php queue.php PHP_Job');
4 4
 }
5 5
 
@@ -23,4 +23,4 @@  discard block
 block discarded – undo
23 23
         $jobId = Resque::enqueue($argv[1], $argv[2], $args, true);	
24 24
 }
25 25
 
26
-echo "Queued job ".$jobId."\n\n";
26
+echo "Queued job " . $jobId . "\n\n";
Please login to merge, or discard this patch.
lib/Resque/Redis.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
 				$this->driver = new Credis_Client($host, $port, $timeout, $persistent);
132 132
 				$this->driver->setMaxConnectRetries($maxRetries);
133
-				if ($password){
133
+				if ($password) {
134 134
 					$this->driver->auth($password);
135 135
 				}
136 136
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 				$this->driver->select($database);
146 146
 			}
147 147
 		}
148
-		catch(CredisException $e) {
148
+		catch (CredisException $e) {
149 149
 			throw new Resque_RedisException('Error communicating with Redis: ' . $e->getMessage(), 0, $e);
150 150
 		}
151 151
 	}
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 			// Use a sensible default for an empty DNS string
171 171
 			$dsn = 'redis://' . self::DEFAULT_HOST;
172 172
 		}
173
-		if(substr($dsn, 0, 7) === 'unix://') {
173
+		if (substr($dsn, 0, 7) === 'unix://') {
174 174
 			return array(
175 175
 				$dsn,
176 176
 				null,
@@ -184,12 +184,12 @@  discard block
 block discarded – undo
184 184
 
185 185
 		// Check the URI scheme
186 186
 		$validSchemes = array('redis', 'tcp');
187
-		if (isset($parts['scheme']) && ! in_array($parts['scheme'], $validSchemes)) {
187
+		if (isset($parts['scheme']) && !in_array($parts['scheme'], $validSchemes)) {
188 188
 			throw new \InvalidArgumentException("Invalid DSN. Supported schemes are " . implode(', ', $validSchemes));
189 189
 		}
190 190
 
191 191
 		// Allow simple 'hostname' format, which `parse_url` treats as a path, not host.
192
-		if ( ! isset($parts['host']) && isset($parts['path'])) {
192
+		if (!isset($parts['host']) && isset($parts['path'])) {
193 193
 			$parts['host'] = $parts['path'];
194 194
 			unset($parts['path']);
195 195
 		}
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 
261 261
 	public static function removePrefix($string)
262 262
 	{
263
-	    $prefix=self::getPrefix();
263
+	    $prefix = self::getPrefix();
264 264
 
265 265
 	    if (substr($string, 0, strlen($prefix)) == $prefix) {
266
-	        $string = substr($string, strlen($prefix), strlen($string) );
266
+	        $string = substr($string, strlen($prefix), strlen($string));
267 267
 	    }
268 268
 	    return $string;
269 269
 	}
Please login to merge, or discard this patch.
lib/Resque/Failure.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 	 */
36 36
 	public static function getBackend()
37 37
 	{
38
-		if(self::$backend === null) {
38
+		if (self::$backend === null) {
39 39
 			self::$backend = 'Resque_Failure_Redis';
40 40
 		}
41 41
 
Please login to merge, or discard this patch.
lib/Resque.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	public static function fork()
89 89
 	{
90
-		if(!function_exists('pcntl_fork')) {
90
+		if (!function_exists('pcntl_fork')) {
91 91
 			return false;
92 92
 		}
93 93
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		self::$redis = null;
97 97
 
98 98
 		$pid = pcntl_fork();
99
-		if($pid === -1) {
99
+		if ($pid === -1) {
100 100
 			throw new RuntimeException('Unable to fork child worker.');
101 101
 		}
102 102
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	{
136 136
         $item = self::redis()->lpop('queue:' . $queue);
137 137
 
138
-		if(!$item) {
138
+		if (!$item) {
139 139
 			return;
140 140
 		}
141 141
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 */
152 152
 	public static function dequeue($queue, $items = Array())
153 153
 	{
154
-	    if(count($items) > 0) {
154
+	    if (count($items) > 0) {
155 155
 			return self::removeItems($queue, $items);
156 156
 	    } else {
157 157
 			return self::removeList($queue);
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
 	public static function blpop(array $queues, $timeout)
183 183
 	{
184 184
 	    $list = array();
185
-	    foreach($queues AS $queue) {
185
+	    foreach ($queues AS $queue) {
186 186
 		$list[] = 'queue:' . $queue;
187 187
 	    }
188 188
 
189 189
 	    $item = self::redis()->blpop($list, (int)$timeout);
190 190
 
191
-	    if(!$item) {
191
+	    if (!$item) {
192 192
 		return;
193 193
 	    }
194 194
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 		try {
241 241
 			Resque_Event::trigger('beforeEnqueue', $hookParams);
242 242
 		}
243
-		catch(Resque_Job_DontCreate $e) {
243
+		catch (Resque_Job_DontCreate $e) {
244 244
 			return false;
245 245
 		}
246 246
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	public static function queues()
270 270
 	{
271 271
 		$queues = self::redis()->smembers('queues');
272
-		if(!is_array($queues)) {
272
+		if (!is_array($queues)) {
273 273
 			$queues = array();
274 274
 		}
275 275
 		return $queues;
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	public static function items($queue, $start = 0, $stop = -1)
284 284
 	{
285 285
 		$list = self::redis()->lrange('queue:' . $queue, $start, $stop);
286
-		if(!is_array($list)) {
286
+		if (!is_array($list)) {
287 287
 			$list = array();
288 288
 		}
289 289
 		return $list;
@@ -304,9 +304,9 @@  discard block
 block discarded – undo
304 304
 	private static function removeItems($queue, $items = Array())
305 305
 	{
306 306
 		$counter = 0;
307
-		$originalQueue = 'queue:'. $queue;
308
-		$tempQueue = $originalQueue. ':temp:'. time();
309
-		$requeueQueue = $tempQueue. ':requeue';
307
+		$originalQueue = 'queue:' . $queue;
308
+		$tempQueue = $originalQueue . ':temp:' . time();
309
+		$requeueQueue = $tempQueue . ':requeue';
310 310
 
311 311
 		// move each item from original queue to temp queue and process it
312 312
 		$finished = false;
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 			$string = self::redis()->rpoplpush($originalQueue, self::redis()->getPrefix() . $tempQueue);
315 315
 
316 316
 			if (!empty($string)) {
317
-				if(self::matchItem($string, $items)) {
317
+				if (self::matchItem($string, $items)) {
318 318
 					self::redis()->rpop($tempQueue);
319 319
 					$counter++;
320 320
 				} else {
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 		// move back from temp queue to original queue
329 329
 		$finished = false;
330 330
 		while (!$finished) {
331
-			$string = self::redis()->rpoplpush($requeueQueue, self::redis()->getPrefix() .$originalQueue);
331
+			$string = self::redis()->rpoplpush($requeueQueue, self::redis()->getPrefix() . $originalQueue);
332 332
 			if (empty($string)) {
333 333
 			    $finished = true;
334 334
 			}
@@ -355,10 +355,10 @@  discard block
 block discarded – undo
355 355
 	{
356 356
 	    $decoded = json_decode($string, true);
357 357
 
358
-	    foreach($items as $key => $val) {
358
+	    foreach ($items as $key => $val) {
359 359
 			# class name only  ex: item[0] = ['class']
360 360
 			if (is_numeric($key)) {
361
-			    if($decoded['class'] == $val) {
361
+			    if ($decoded['class'] == $val) {
362 362
 					return true;
363 363
 			    }
364 364
 			# class name with args , example: item[0] = ['class' => {'foo' => 1, 'bar' => 2}]
Please login to merge, or discard this patch.
lib/Resque/Job.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 			$id = Resque::generateJobId();
65 65
 		}
66 66
 
67
-		if($args !== null && !is_array($args)) {
67
+		if ($args !== null && !is_array($args)) {
68 68
 			throw new InvalidArgumentException(
69 69
 				'Supplied $args must be an array.'
70 70
 			);
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			'queue_time' => microtime(true),
78 78
 		));
79 79
 
80
-		if($monitor) {
80
+		if ($monitor) {
81 81
 			Resque_Job_Status::create($id, $prefix);
82 82
 		}
83 83
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	public static function reserve($queue)
95 95
 	{
96 96
 		$payload = Resque::pop($queue);
97
-		if(!is_array($payload)) {
97
+		if (!is_array($payload)) {
98 98
 			return false;
99 99
 		}
100 100
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	{
114 114
 		$item = Resque::blpop($queues, $timeout);
115 115
 
116
-		if(!is_array($item)) {
116
+		if (!is_array($item)) {
117 117
 			return false;
118 118
 		}
119 119
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	public function updateStatus($status, $result = null)
129 129
 	{
130
-		if(empty($this->payload['id'])) {
130
+		if (empty($this->payload['id'])) {
131 131
 			return;
132 132
 		}
133 133
 
@@ -190,20 +190,20 @@  discard block
 block discarded – undo
190 190
 			Resque_Event::trigger('beforePerform', $this);
191 191
 
192 192
 			$instance = $this->getInstance();
193
-			if(is_callable([$instance, 'setUp'])) {
193
+			if (is_callable([$instance, 'setUp'])) {
194 194
 				$instance->setUp();
195 195
 			}
196 196
 
197 197
 			$result = $instance->perform();
198 198
 
199
-			if(is_callable([$instance, 'tearDown'])) {
199
+			if (is_callable([$instance, 'tearDown'])) {
200 200
 				$instance->tearDown();
201 201
 			}
202 202
 
203 203
 			Resque_Event::trigger('afterPerform', $this);
204 204
 		}
205 205
 		// beforePerform/setUp have said don't perform this job. Return.
206
-		catch(Resque_Job_DontPerform $e) {
206
+		catch (Resque_Job_DontPerform $e) {
207 207
 			$result = false;
208 208
 		}
209 209
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	{
251 251
 		$status = new Resque_Job_Status($this->payload['id'], $this->payload['prefix']);
252 252
 		$monitor = false;
253
-		if($status->isTracking()) {
253
+		if ($status->isTracking()) {
254 254
 			$monitor = true;
255 255
 		}
256 256
 
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
 	public function __toString()
266 266
 	{
267 267
 		$name = array(
268
-			'Job{' . $this->queue .'}'
268
+			'Job{' . $this->queue . '}'
269 269
 		);
270
-		if(!empty($this->payload['id'])) {
270
+		if (!empty($this->payload['id'])) {
271 271
 			$name[] = 'ID: ' . $this->payload['id'];
272 272
 		}
273 273
 		$name[] = $this->payload['class'];
274
-		if(!empty($this->payload['args'])) {
274
+		if (!empty($this->payload['args'])) {
275 275
 			$name[] = json_encode($this->payload['args']);
276 276
 		}
277 277
 		return '(' . implode(' | ', $name) . ')';
Please login to merge, or discard this patch.
lib/Resque/Worker.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(ticks = 1);
2
+declare(ticks=1);
3 3
 
4 4
 /**
5 5
  * Resque worker that handles checking queues for jobs, fetching them
@@ -76,14 +76,14 @@  discard block
 block discarded – undo
76 76
     {
77 77
         $this->logger = new Resque_Log();
78 78
 
79
-        if(!is_array($queues)) {
79
+        if (!is_array($queues)) {
80 80
             $queues = array($queues);
81 81
         }
82 82
 
83 83
         $this->queues = $queues;
84 84
         $this->hostname = php_uname('n');
85 85
 
86
-        $this->id = $this->hostname . ':'.getmypid() . ':' . implode(',', $this->queues);
86
+        $this->id = $this->hostname . ':' . getmypid() . ':' . implode(',', $this->queues);
87 87
     }
88 88
 
89 89
 	/**
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 	public static function all()
103 103
 	{
104 104
 		$workers = Resque::redis()->smembers('workers');
105
-		if(!is_array($workers)) {
105
+		if (!is_array($workers)) {
106 106
 			$workers = array();
107 107
 		}
108 108
 
109 109
 		$instances = array();
110
-		foreach($workers as $workerId) {
110
+		foreach ($workers as $workerId) {
111 111
 			$instances[] = self::find($workerId);
112 112
 		}
113 113
 		return $instances;
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 */
133 133
 	public static function find($workerId)
134 134
 	{
135
-		if(!self::exists($workerId) || false === strpos($workerId, ":")) {
135
+		if (!self::exists($workerId) || false === strpos($workerId, ":")) {
136 136
 			return false;
137 137
 		}
138 138
 
@@ -166,12 +166,12 @@  discard block
 block discarded – undo
166 166
 		$this->updateProcLine('Starting');
167 167
 		$this->startup();
168 168
 
169
-        if(function_exists('pcntl_signal_dispatch')) {
169
+        if (function_exists('pcntl_signal_dispatch')) {
170 170
             pcntl_signal_dispatch();
171 171
         }
172 172
 
173
-		while(true) {
174
-			if($this->shutdown) {
173
+		while (true) {
174
+			if ($this->shutdown) {
175 175
 				break;
176 176
 			}
177 177
 
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
 
190 190
 			// Attempt to find and reserve a job
191 191
 			$job = false;
192
-			if(!$this->paused) {
193
-				if($blocking === true) {
192
+			if (!$this->paused) {
193
+				if ($blocking === true) {
194 194
 					$this->logger->log(Psr\Log\LogLevel::INFO, 'Starting blocking with timeout of {interval}', array('interval' => $interval));
195 195
 					$this->updateProcLine('Waiting with blocking timeout ' . $interval);
196 196
 				} else {
@@ -200,17 +200,17 @@  discard block
 block discarded – undo
200 200
 				$job = $this->reserve($blocking, $interval);
201 201
 			}
202 202
 
203
-			if(!$job) {
203
+			if (!$job) {
204 204
 				// For an interval of 0, break now - helps with unit testing etc
205
-				if($interval == 0) {
205
+				if ($interval == 0) {
206 206
 					break;
207 207
 				}
208 208
 
209
-				if($blocking === false)
209
+				if ($blocking === false)
210 210
 				{
211 211
 					// If no job was found, we sleep for $interval before continuing and checking again
212 212
 					$this->logger->log(Psr\Log\LogLevel::INFO, 'Sleeping for {interval}', array('interval' => $interval));
213
-					if($this->paused) {
213
+					if ($this->paused) {
214 214
 						$this->updateProcLine('Paused');
215 215
 					}
216 216
 					else {
@@ -235,13 +235,13 @@  discard block
 block discarded – undo
235 235
 				$this->updateProcLine($status);
236 236
 				$this->logger->log(Psr\Log\LogLevel::INFO, $status);
237 237
 
238
-				if(!empty($job->payload['id'])) {
238
+				if (!empty($job->payload['id'])) {
239 239
 					Resque_Job_PID::create($job->payload['id']);
240 240
 				}
241 241
 
242 242
 				$this->perform($job);
243 243
 
244
-				if(!empty($job->payload['id'])) {
244
+				if (!empty($job->payload['id'])) {
245 245
 					Resque_Job_PID::del($job->payload['id']);
246 246
 				}
247 247
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 				}
251 251
 			}
252 252
 
253
-			if($this->child > 0) {
253
+			if ($this->child > 0) {
254 254
 				// Parent process, sit and wait
255 255
 				$status = 'Forked ' . $this->child . ' at ' . strftime('%F %T');
256 256
 				$this->updateProcLine($status);
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 
259 259
 				// Wait until the child process finishes before continuing
260 260
 				while (pcntl_wait($status, WNOHANG) === 0) {
261
-					if(function_exists('pcntl_signal_dispatch')) {
261
+					if (function_exists('pcntl_signal_dispatch')) {
262 262
 			            pcntl_signal_dispatch();
263 263
 			        }
264 264
 
@@ -302,12 +302,12 @@  discard block
 block discarded – undo
302 302
 			Resque_Event::trigger('afterFork', $job);
303 303
 			$result = $job->perform();
304 304
 		}
305
-		catch(Exception $e) {
305
+		catch (Exception $e) {
306 306
 			$this->logger->log(Psr\Log\LogLevel::CRITICAL, '{job} has failed {exception}', array('job' => $job, 'exception' => $e));
307 307
 			$job->fail($e);
308 308
 			return;
309 309
 		}
310
-		catch(Error $e) {
310
+		catch (Error $e) {
311 311
 			$this->logger->log(Psr\Log\LogLevel::CRITICAL, '{job} has failed {exception}', array('job' => $job, 'exception' => $e));
312 312
 			$job->fail($e);
313 313
 			return;
@@ -331,26 +331,26 @@  discard block
 block discarded – undo
331 331
 		}
332 332
 
333 333
 		$queues = $this->queues();
334
-		if(!is_array($queues)) {
334
+		if (!is_array($queues)) {
335 335
 			return;
336 336
 		}
337 337
 
338
-		if($blocking === true) {
339
-		    if(empty($queues)){
338
+		if ($blocking === true) {
339
+		    if (empty($queues)) {
340 340
                 $this->logger->log(Psr\Log\LogLevel::INFO, 'No queue was found, sleeping for {interval}', array('interval' => $timeout));
341 341
                 usleep($timeout * 1000000);
342 342
                 return false;
343 343
             }
344 344
 			$job = Resque_Job::reserveBlocking($queues, $timeout);
345
-			if($job) {
345
+			if ($job) {
346 346
 				$this->logger->log(Psr\Log\LogLevel::INFO, 'Found job on {queue}', array('queue' => $job->queue));
347 347
 				return $job;
348 348
 			}
349 349
 		} else {
350
-			foreach($queues as $queue) {
350
+			foreach ($queues as $queue) {
351 351
 				$this->logger->log(Psr\Log\LogLevel::INFO, 'Checking {queue} for jobs', array('queue' => $queue));
352 352
 				$job = Resque_Job::reserve($queue);
353
-				if($job) {
353
+				if ($job) {
354 354
 					$this->logger->log(Psr\Log\LogLevel::INFO, 'Found job on {queue}', array('queue' => $job->queue));
355 355
 					return $job;
356 356
 				}
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 	 */
374 374
 	public function queues($fetch = true)
375 375
 	{
376
-		if(!in_array('*', $this->queues) || $fetch == false) {
376
+		if (!in_array('*', $this->queues) || $fetch == false) {
377 377
 			return $this->queues;
378 378
 		}
379 379
 
@@ -403,10 +403,10 @@  discard block
 block discarded – undo
403 403
 	private function updateProcLine($status)
404 404
 	{
405 405
 		$processTitle = static::$processPrefix . '-' . Resque::VERSION . ' (' . implode(',', $this->queues) . '): ' . $status;
406
-		if(function_exists('cli_set_process_title') && PHP_OS !== 'Darwin') {
406
+		if (function_exists('cli_set_process_title') && PHP_OS !== 'Darwin') {
407 407
 			cli_set_process_title($processTitle);
408 408
 		}
409
-		else if(function_exists('setproctitle')) {
409
+		else if (function_exists('setproctitle')) {
410 410
 			setproctitle($processTitle);
411 411
 		}
412 412
 	}
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 	 */
422 422
 	private function registerSigHandlers()
423 423
 	{
424
-		if(!function_exists('pcntl_signal')) {
424
+		if (!function_exists('pcntl_signal')) {
425 425
 			return;
426 426
 		}
427 427
 
@@ -486,13 +486,13 @@  discard block
 block discarded – undo
486 486
 	 */
487 487
 	public function killChild()
488 488
 	{
489
-		if(!$this->child) {
489
+		if (!$this->child) {
490 490
 			$this->logger->log(Psr\Log\LogLevel::DEBUG, 'No child to kill.');
491 491
 			return;
492 492
 		}
493 493
 
494 494
 		$this->logger->log(Psr\Log\LogLevel::INFO, 'Killing child at {child}', array('child' => $this->child));
495
-		if(exec('ps -o pid,s -p ' . $this->child, $output, $returnCode) && $returnCode != 1) {
495
+		if (exec('ps -o pid,s -p ' . $this->child, $output, $returnCode) && $returnCode != 1) {
496 496
 			$this->logger->log(Psr\Log\LogLevel::DEBUG, 'Child {child} found, killing.', array('child' => $this->child));
497 497
 			posix_kill($this->child, SIGKILL);
498 498
 			$this->child = null;
@@ -515,10 +515,10 @@  discard block
 block discarded – undo
515 515
 	{
516 516
 		$workerPids = $this->workerPids();
517 517
 		$workers = self::all();
518
-		foreach($workers as $worker) {
518
+		foreach ($workers as $worker) {
519 519
 			if (is_object($worker)) {
520 520
 				list($host, $pid, $queues) = explode(':', (string)$worker, 3);
521
-				if($host != $this->hostname || in_array($pid, $workerPids) || $pid == getmypid()) {
521
+				if ($host != $this->hostname || in_array($pid, $workerPids) || $pid == getmypid()) {
522 522
 					continue;
523 523
 				}
524 524
 				$this->logger->log(Psr\Log\LogLevel::INFO, 'Pruning dead worker: {worker}', array('worker' => (string)$worker));
@@ -538,14 +538,14 @@  discard block
 block discarded – undo
538 538
 		$pids = array();
539 539
 		if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
540 540
 			exec('WMIC path win32_process get Processid,Commandline | findstr resque | findstr /V findstr', $cmdOutput);
541
-			foreach($cmdOutput as $line) {
541
+			foreach ($cmdOutput as $line) {
542 542
 				$line = preg_replace('/\s+/m', ' ', $line);
543
-				list(,,$pids[]) = explode(' ', trim($line), 3);
543
+				list(,, $pids[]) = explode(' ', trim($line), 3);
544 544
 			}
545 545
 		}
546 546
 		else {
547 547
 			exec('ps -A -o pid,args | grep [r]esque', $cmdOutput);
548
-			foreach($cmdOutput as $line) {
548
+			foreach ($cmdOutput as $line) {
549 549
 				list($pids[],) = explode(' ', trim($line), 2);
550 550
 			}
551 551
 		}
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	 */
567 567
 	public function unregisterWorker()
568 568
 	{
569
-		if(is_object($this->currentJob)) {
569
+		if (is_object($this->currentJob)) {
570 570
 			$this->currentJob->fail(new Resque_Job_DirtyExitException);
571 571
 		}
572 572
 
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 	public function job()
627 627
 	{
628 628
 		$job = Resque::redis()->get('worker:' . $this);
629
-		if(!$job) {
629
+		if (!$job) {
630 630
 			return array();
631 631
 		}
632 632
 		else {
Please login to merge, or discard this patch.
lib/Resque/Job/Status.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 			'started' => time(),
64 64
 			'result'  => null,
65 65
 		);
66
-		Resque::redis()->set((string) $status, json_encode($statusPacket));
66
+		Resque::redis()->set((string)$status, json_encode($statusPacket));
67 67
 
68 68
 		return $status;
69 69
 	}
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function isTracking()
78 78
 	{
79
-		if($this->isTracking === false) {
79
+		if ($this->isTracking === false) {
80 80
 			return false;
81 81
 		}
82 82
 
83
-		if(!Resque::redis()->exists((string)$this)) {
83
+		if (!Resque::redis()->exists((string)$this)) {
84 84
 			$this->isTracking = false;
85 85
 			return false;
86 86
 		}
@@ -96,13 +96,13 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public function update($status, $result = null)
98 98
 	{
99
-		$status = (int) $status;
99
+		$status = (int)$status;
100 100
 
101
-		if(!$this->isTracking()) {
101
+		if (!$this->isTracking()) {
102 102
 			return;
103 103
 		}
104 104
 
105
-		if($status < self::STATUS_WAITING || $status > self::STATUS_COMPLETE) {
105
+		if ($status < self::STATUS_WAITING || $status > self::STATUS_COMPLETE) {
106 106
 			return;
107 107
 		}
108 108
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 		Resque::redis()->set((string)$this, json_encode($statusPacket));
116 116
 
117 117
 		// Expire the status for completed jobs after 24 hours
118
-		if(in_array($status, self::$completeStatuses)) {
118
+		if (in_array($status, self::$completeStatuses)) {
119 119
 			Resque::redis()->expire((string)$this, 86400);
120 120
 		}
121 121
 	}
@@ -201,19 +201,19 @@  discard block
 block discarded – undo
201 201
 	*/
202 202
 	protected function fetch($value = null)
203 203
 	{
204
-		if(!$this->isTracking()) {
204
+		if (!$this->isTracking()) {
205 205
 			return false;
206 206
 		}
207 207
 
208 208
 		$statusPacket = json_decode(Resque::redis()->get((string)$this), true);
209
-		if(!$statusPacket) {
209
+		if (!$statusPacket) {
210 210
 			return false;
211 211
 		}
212 212
 
213
-		if(empty($value)) {
213
+		if (empty($value)) {
214 214
 			return $statusPacket;
215 215
 		} else {
216
-			if(isset($statusPacket[$value])) {
216
+			if (isset($statusPacket[$value])) {
217 217
 				return $statusPacket[$value];
218 218
 			} else {
219 219
 				return null;
Please login to merge, or discard this patch.
lib/ResqueScheduler.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -108,14 +108,14 @@
 block discarded – undo
108 108
      */
109 109
     public static function removeDelayed($queue, $class, $args)
110 110
     {
111
-       $destroyed=0;
112
-       $item=json_encode(self::jobToHash($queue, $class, $args));
113
-       $redis=Resque::redis();
111
+       $destroyed = 0;
112
+       $item = json_encode(self::jobToHash($queue, $class, $args));
113
+       $redis = Resque::redis();
114 114
 
115
-       foreach($redis->keys('delayed:*') as $key)
115
+       foreach ($redis->keys('delayed:*') as $key)
116 116
        {
117
-           $key=$redis->removePrefix($key);
118
-           $destroyed+=$redis->lrem($key,0,$item);
117
+           $key = $redis->removePrefix($key);
118
+           $destroyed += $redis->lrem($key, 0, $item);
119 119
        }
120 120
 
121 121
        return $destroyed;
Please login to merge, or discard this patch.