@@ -1,5 +1,5 @@ discard block |
||
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 |
||
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 |
@@ -1,5 +1,5 @@ discard block |
||
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 |
||
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"; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public static function fork() |
78 | 78 | { |
79 | - if(!function_exists('pcntl_fork')) { |
|
79 | + if (!function_exists('pcntl_fork')) { |
|
80 | 80 | return false; |
81 | 81 | } |
82 | 82 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | self::$redis = null; |
86 | 86 | |
87 | 87 | $pid = pcntl_fork(); |
88 | - if($pid === -1) { |
|
88 | + if ($pid === -1) { |
|
89 | 89 | throw new RuntimeException('Unable to fork child worker.'); |
90 | 90 | } |
91 | 91 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | { |
125 | 125 | $item = self::redis()->lpop('queue:' . $queue); |
126 | 126 | |
127 | - if(!$item) { |
|
127 | + if (!$item) { |
|
128 | 128 | return; |
129 | 129 | } |
130 | 130 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public static function dequeue($queue, $items = Array()) |
142 | 142 | { |
143 | - if(count($items) > 0) { |
|
143 | + if (count($items) > 0) { |
|
144 | 144 | return self::removeItems($queue, $items); |
145 | 145 | } else { |
146 | 146 | return self::removeList($queue); |
@@ -171,13 +171,13 @@ discard block |
||
171 | 171 | public static function blpop(array $queues, $timeout) |
172 | 172 | { |
173 | 173 | $list = array(); |
174 | - foreach($queues AS $queue) { |
|
174 | + foreach ($queues AS $queue) { |
|
175 | 175 | $list[] = 'queue:' . $queue; |
176 | 176 | } |
177 | 177 | |
178 | 178 | $item = self::redis()->blpop($list, (int)$timeout); |
179 | 179 | |
180 | - if(!$item) { |
|
180 | + if (!$item) { |
|
181 | 181 | return; |
182 | 182 | } |
183 | 183 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | try { |
229 | 229 | Resque_Event::trigger('beforeEnqueue', $hookParams); |
230 | 230 | } |
231 | - catch(Resque_Job_DontCreate $e) { |
|
231 | + catch (Resque_Job_DontCreate $e) { |
|
232 | 232 | return false; |
233 | 233 | } |
234 | 234 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | public static function queues() |
258 | 258 | { |
259 | 259 | $queues = self::redis()->smembers('queues'); |
260 | - if(!is_array($queues)) { |
|
260 | + if (!is_array($queues)) { |
|
261 | 261 | $queues = array(); |
262 | 262 | } |
263 | 263 | return $queues; |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | private static function removeItems($queue, $items = Array()) |
279 | 279 | { |
280 | 280 | $counter = 0; |
281 | - $originalQueue = 'queue:'. $queue; |
|
282 | - $tempQueue = $originalQueue. ':temp:'. time(); |
|
283 | - $requeueQueue = $tempQueue. ':requeue'; |
|
281 | + $originalQueue = 'queue:' . $queue; |
|
282 | + $tempQueue = $originalQueue . ':temp:' . time(); |
|
283 | + $requeueQueue = $tempQueue . ':requeue'; |
|
284 | 284 | |
285 | 285 | // move each item from original queue to temp queue and process it |
286 | 286 | $finished = false; |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | $string = self::redis()->rpoplpush($originalQueue, self::redis()->getPrefix() . $tempQueue); |
289 | 289 | |
290 | 290 | if (!empty($string)) { |
291 | - if(self::matchItem($string, $items)) { |
|
291 | + if (self::matchItem($string, $items)) { |
|
292 | 292 | self::redis()->rpop($tempQueue); |
293 | 293 | $counter++; |
294 | 294 | } else { |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | // move back from temp queue to original queue |
303 | 303 | $finished = false; |
304 | 304 | while (!$finished) { |
305 | - $string = self::redis()->rpoplpush($requeueQueue, self::redis()->getPrefix() .$originalQueue); |
|
305 | + $string = self::redis()->rpoplpush($requeueQueue, self::redis()->getPrefix() . $originalQueue); |
|
306 | 306 | if (empty($string)) { |
307 | 307 | $finished = true; |
308 | 308 | } |
@@ -329,10 +329,10 @@ discard block |
||
329 | 329 | { |
330 | 330 | $decoded = json_decode($string, true); |
331 | 331 | |
332 | - foreach($items as $key => $val) { |
|
332 | + foreach ($items as $key => $val) { |
|
333 | 333 | # class name only ex: item[0] = ['class'] |
334 | 334 | if (is_numeric($key)) { |
335 | - if($decoded['class'] == $val) { |
|
335 | + if ($decoded['class'] == $val) { |
|
336 | 336 | return true; |
337 | 337 | } |
338 | 338 | # class name with args , example: item[0] = ['class' => {'foo' => 1, 'bar' => 2}] |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $id = Resque::generateJobId(); |
64 | 64 | } |
65 | 65 | |
66 | - if($args !== null && !is_array($args)) { |
|
66 | + if ($args !== null && !is_array($args)) { |
|
67 | 67 | throw new InvalidArgumentException( |
68 | 68 | 'Supplied $args must be an array.' |
69 | 69 | ); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | 'queue_time' => microtime(true), |
76 | 76 | )); |
77 | 77 | |
78 | - if($monitor) { |
|
78 | + if ($monitor) { |
|
79 | 79 | Resque_Job_Status::create($id); |
80 | 80 | } |
81 | 81 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | public static function reserve($queue) |
93 | 93 | { |
94 | 94 | $payload = Resque::pop($queue); |
95 | - if(!is_array($payload)) { |
|
95 | + if (!is_array($payload)) { |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | { |
112 | 112 | $item = Resque::blpop($queues, $timeout); |
113 | 113 | |
114 | - if(!is_array($item)) { |
|
114 | + if (!is_array($item)) { |
|
115 | 115 | return false; |
116 | 116 | } |
117 | 117 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function updateStatus($status) |
127 | 127 | { |
128 | - if(empty($this->payload['id'])) { |
|
128 | + if (empty($this->payload['id'])) { |
|
129 | 129 | return; |
130 | 130 | } |
131 | 131 | |
@@ -187,20 +187,20 @@ discard block |
||
187 | 187 | Resque_Event::trigger('beforePerform', $this); |
188 | 188 | |
189 | 189 | $instance = $this->getInstance(); |
190 | - if(method_exists($instance, 'setUp')) { |
|
190 | + if (method_exists($instance, 'setUp')) { |
|
191 | 191 | $instance->setUp(); |
192 | 192 | } |
193 | 193 | |
194 | 194 | $instance->perform(); |
195 | 195 | |
196 | - if(method_exists($instance, 'tearDown')) { |
|
196 | + if (method_exists($instance, 'tearDown')) { |
|
197 | 197 | $instance->tearDown(); |
198 | 198 | } |
199 | 199 | |
200 | 200 | Resque_Event::trigger('afterPerform', $this); |
201 | 201 | } |
202 | 202 | // beforePerform/setUp have said don't perform this job. Return. |
203 | - catch(Resque_Job_DontPerform $e) { |
|
203 | + catch (Resque_Job_DontPerform $e) { |
|
204 | 204 | return false; |
205 | 205 | } |
206 | 206 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | { |
239 | 239 | $status = new Resque_Job_Status($this->payload['id']); |
240 | 240 | $monitor = false; |
241 | - if($status->isTracking()) { |
|
241 | + if ($status->isTracking()) { |
|
242 | 242 | $monitor = true; |
243 | 243 | } |
244 | 244 | |
@@ -253,13 +253,13 @@ discard block |
||
253 | 253 | public function __toString() |
254 | 254 | { |
255 | 255 | $name = array( |
256 | - 'Job{' . $this->queue .'}' |
|
256 | + 'Job{' . $this->queue . '}' |
|
257 | 257 | ); |
258 | - if(!empty($this->payload['id'])) { |
|
258 | + if (!empty($this->payload['id'])) { |
|
259 | 259 | $name[] = 'ID: ' . $this->payload['id']; |
260 | 260 | } |
261 | 261 | $name[] = $this->payload['class']; |
262 | - if(!empty($this->payload['args'])) { |
|
262 | + if (!empty($this->payload['args'])) { |
|
263 | 263 | $name[] = json_encode($this->payload['args']); |
264 | 264 | } |
265 | 265 | return '(' . implode(' | ', $name) . ')'; |
@@ -1,5 +1,5 @@ discard block |
||
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 |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | { |
72 | 72 | $this->logger = new Resque_Log(); |
73 | 73 | |
74 | - if(!is_array($queues)) { |
|
74 | + if (!is_array($queues)) { |
|
75 | 75 | $queues = array($queues); |
76 | 76 | } |
77 | 77 | |
78 | 78 | $this->queues = $queues; |
79 | 79 | $this->hostname = php_uname('n'); |
80 | 80 | |
81 | - $this->id = $this->hostname . ':'.getmypid() . ':' . implode(',', $this->queues); |
|
81 | + $this->id = $this->hostname . ':' . getmypid() . ':' . implode(',', $this->queues); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | public static function all() |
89 | 89 | { |
90 | 90 | $workers = Resque::redis()->smembers('workers'); |
91 | - if(!is_array($workers)) { |
|
91 | + if (!is_array($workers)) { |
|
92 | 92 | $workers = array(); |
93 | 93 | } |
94 | 94 | |
95 | 95 | $instances = array(); |
96 | - foreach($workers as $workerId) { |
|
96 | + foreach ($workers as $workerId) { |
|
97 | 97 | $instances[] = self::find($workerId); |
98 | 98 | } |
99 | 99 | return $instances; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public static function find($workerId) |
120 | 120 | { |
121 | - if(!self::exists($workerId) || false === strpos($workerId, ":")) { |
|
121 | + if (!self::exists($workerId) || false === strpos($workerId, ":")) { |
|
122 | 122 | return false; |
123 | 123 | } |
124 | 124 | |
@@ -152,15 +152,15 @@ discard block |
||
152 | 152 | $this->updateProcLine('Starting'); |
153 | 153 | $this->startup(); |
154 | 154 | |
155 | - while(true) { |
|
156 | - if($this->shutdown) { |
|
155 | + while (true) { |
|
156 | + if ($this->shutdown) { |
|
157 | 157 | break; |
158 | 158 | } |
159 | 159 | |
160 | 160 | // Attempt to find and reserve a job |
161 | 161 | $job = false; |
162 | - if(!$this->paused) { |
|
163 | - if($blocking === true) { |
|
162 | + if (!$this->paused) { |
|
163 | + if ($blocking === true) { |
|
164 | 164 | $this->logger->log(Psr\Log\LogLevel::INFO, 'Starting blocking with timeout of {interval}', array('interval' => $interval)); |
165 | 165 | $this->updateProcLine('Waiting for ' . implode(',', $this->queues) . ' with blocking timeout ' . $interval); |
166 | 166 | } else { |
@@ -170,17 +170,17 @@ discard block |
||
170 | 170 | $job = $this->reserve($blocking, $interval); |
171 | 171 | } |
172 | 172 | |
173 | - if(!$job) { |
|
173 | + if (!$job) { |
|
174 | 174 | // For an interval of 0, break now - helps with unit testing etc |
175 | - if($interval == 0) { |
|
175 | + if ($interval == 0) { |
|
176 | 176 | break; |
177 | 177 | } |
178 | 178 | |
179 | - if($blocking === false) |
|
179 | + if ($blocking === false) |
|
180 | 180 | { |
181 | 181 | // If no job was found, we sleep for $interval before continuing and checking again |
182 | 182 | $this->logger->log(Psr\Log\LogLevel::INFO, 'Sleeping for {interval}', array('interval' => $interval)); |
183 | - if($this->paused) { |
|
183 | + if ($this->paused) { |
|
184 | 184 | $this->updateProcLine('Paused'); |
185 | 185 | } |
186 | 186 | else { |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | } |
211 | 211 | } |
212 | 212 | |
213 | - if($this->child > 0) { |
|
213 | + if ($this->child > 0) { |
|
214 | 214 | // Parent process, sit and wait |
215 | 215 | $status = 'Forked ' . $this->child . ' at ' . strftime('%F %T'); |
216 | 216 | $this->updateProcLine($status); |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | Resque_Event::trigger('afterFork', $job); |
255 | 255 | $job->perform(); |
256 | 256 | } |
257 | - catch(Exception $e) { |
|
257 | + catch (Exception $e) { |
|
258 | 258 | $this->logger->log(Psr\Log\LogLevel::CRITICAL, '{job} has failed {stack}', array('job' => $job, 'stack' => $e)); |
259 | 259 | $job->fail($e); |
260 | 260 | return; |
@@ -278,21 +278,21 @@ discard block |
||
278 | 278 | } |
279 | 279 | |
280 | 280 | $queues = $this->queues(); |
281 | - if(!is_array($queues)) { |
|
281 | + if (!is_array($queues)) { |
|
282 | 282 | return; |
283 | 283 | } |
284 | 284 | |
285 | - if($blocking === true) { |
|
285 | + if ($blocking === true) { |
|
286 | 286 | $job = Resque_Job::reserveBlocking($queues, $timeout); |
287 | - if($job) { |
|
287 | + if ($job) { |
|
288 | 288 | $this->logger->log(Psr\Log\LogLevel::INFO, 'Found job on {queue}', array('queue' => $job->queue)); |
289 | 289 | return $job; |
290 | 290 | } |
291 | 291 | } else { |
292 | - foreach($queues as $queue) { |
|
292 | + foreach ($queues as $queue) { |
|
293 | 293 | $this->logger->log(Psr\Log\LogLevel::INFO, 'Checking {queue} for jobs', array('queue' => $queue)); |
294 | 294 | $job = Resque_Job::reserve($queue); |
295 | - if($job) { |
|
295 | + if ($job) { |
|
296 | 296 | $this->logger->log(Psr\Log\LogLevel::INFO, 'Found job on {queue}', array('queue' => $job->queue)); |
297 | 297 | return $job; |
298 | 298 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | */ |
316 | 316 | public function queues($fetch = true) |
317 | 317 | { |
318 | - if(!in_array('*', $this->queues) || $fetch == false) { |
|
318 | + if (!in_array('*', $this->queues) || $fetch == false) { |
|
319 | 319 | return $this->queues; |
320 | 320 | } |
321 | 321 | |
@@ -345,10 +345,10 @@ discard block |
||
345 | 345 | private function updateProcLine($status) |
346 | 346 | { |
347 | 347 | $processTitle = 'resque-' . Resque::VERSION . ': ' . $status; |
348 | - if(function_exists('cli_set_process_title') && PHP_OS !== 'Darwin') { |
|
348 | + if (function_exists('cli_set_process_title') && PHP_OS !== 'Darwin') { |
|
349 | 349 | cli_set_process_title($processTitle); |
350 | 350 | } |
351 | - else if(function_exists('setproctitle')) { |
|
351 | + else if (function_exists('setproctitle')) { |
|
352 | 352 | setproctitle($processTitle); |
353 | 353 | } |
354 | 354 | } |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | */ |
364 | 364 | private function registerSigHandlers() |
365 | 365 | { |
366 | - if(!function_exists('pcntl_signal')) { |
|
366 | + if (!function_exists('pcntl_signal')) { |
|
367 | 367 | return; |
368 | 368 | } |
369 | 369 | |
@@ -421,13 +421,13 @@ discard block |
||
421 | 421 | */ |
422 | 422 | public function killChild() |
423 | 423 | { |
424 | - if(!$this->child) { |
|
424 | + if (!$this->child) { |
|
425 | 425 | $this->logger->log(Psr\Log\LogLevel::DEBUG, 'No child to kill.'); |
426 | 426 | return; |
427 | 427 | } |
428 | 428 | |
429 | 429 | $this->logger->log(Psr\Log\LogLevel::INFO, 'Killing child at {child}', array('child' => $this->child)); |
430 | - if(exec('ps -o pid,state -p ' . $this->child, $output, $returnCode) && $returnCode != 1) { |
|
430 | + if (exec('ps -o pid,state -p ' . $this->child, $output, $returnCode) && $returnCode != 1) { |
|
431 | 431 | $this->logger->log(Psr\Log\LogLevel::DEBUG, 'Child {child} found, killing.', array('child' => $this->child)); |
432 | 432 | posix_kill($this->child, SIGKILL); |
433 | 433 | $this->child = null; |
@@ -450,10 +450,10 @@ discard block |
||
450 | 450 | { |
451 | 451 | $workerPids = $this->workerPids(); |
452 | 452 | $workers = self::all(); |
453 | - foreach($workers as $worker) { |
|
453 | + foreach ($workers as $worker) { |
|
454 | 454 | if (is_object($worker)) { |
455 | 455 | list($host, $pid, $queues) = explode(':', (string)$worker, 3); |
456 | - if($host != $this->hostname || in_array($pid, $workerPids) || $pid == getmypid()) { |
|
456 | + if ($host != $this->hostname || in_array($pid, $workerPids) || $pid == getmypid()) { |
|
457 | 457 | continue; |
458 | 458 | } |
459 | 459 | $this->logger->log(Psr\Log\LogLevel::INFO, 'Pruning dead worker: {worker}', array('worker' => (string)$worker)); |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | { |
473 | 473 | $pids = array(); |
474 | 474 | exec('ps -A -o pid,command | grep [r]esque', $cmdOutput); |
475 | - foreach($cmdOutput as $line) { |
|
475 | + foreach ($cmdOutput as $line) { |
|
476 | 476 | list($pids[],) = explode(' ', trim($line), 2); |
477 | 477 | } |
478 | 478 | return $pids; |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | */ |
493 | 493 | public function unregisterWorker() |
494 | 494 | { |
495 | - if(is_object($this->currentJob)) { |
|
495 | + if (is_object($this->currentJob)) { |
|
496 | 496 | $this->currentJob->fail(new Resque_Job_DirtyExitException); |
497 | 497 | } |
498 | 498 | |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | public function job() |
553 | 553 | { |
554 | 554 | $job = Resque::redis()->get('worker:' . $this); |
555 | - if(!$job) { |
|
555 | + if (!$job) { |
|
556 | 556 | return array(); |
557 | 557 | } |
558 | 558 | else { |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function isTracking() |
68 | 68 | { |
69 | - if($this->isTracking === false) { |
|
69 | + if ($this->isTracking === false) { |
|
70 | 70 | return false; |
71 | 71 | } |
72 | 72 | |
73 | - if(!Resque::redis()->exists((string)$this)) { |
|
73 | + if (!Resque::redis()->exists((string)$this)) { |
|
74 | 74 | $this->isTracking = false; |
75 | 75 | return false; |
76 | 76 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function update($status) |
88 | 88 | { |
89 | - if(!$this->isTracking()) { |
|
89 | + if (!$this->isTracking()) { |
|
90 | 90 | return; |
91 | 91 | } |
92 | 92 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | Resque::redis()->set((string)$this, json_encode($statusPacket)); |
98 | 98 | |
99 | 99 | // Expire the status for completed jobs after 24 hours |
100 | - if(in_array($status, self::$completeStatuses)) { |
|
100 | + if (in_array($status, self::$completeStatuses)) { |
|
101 | 101 | Resque::redis()->expire((string)$this, 86400); |
102 | 102 | } |
103 | 103 | } |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function get() |
112 | 112 | { |
113 | - if(!$this->isTracking()) { |
|
113 | + if (!$this->isTracking()) { |
|
114 | 114 | return false; |
115 | 115 | } |
116 | 116 | |
117 | 117 | $statusPacket = json_decode(Resque::redis()->get((string)$this), true); |
118 | - if(!$statusPacket) { |
|
118 | + if (!$statusPacket) { |
|
119 | 119 | return false; |
120 | 120 | } |
121 | 121 |
@@ -130,7 +130,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -35,7 +35,7 @@ |
||
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 |