@@ -103,11 +103,11 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function __construct(array $processes) |
| 105 | 105 | { |
| 106 | - $filtered_processes = array_filter($processes, function ($process) { |
|
| 106 | + $filtered_processes = array_filter($processes, function($process) { |
|
| 107 | 107 | return ($process instanceof Process) && !$process->isRunning(); |
| 108 | 108 | }); |
| 109 | 109 | |
| 110 | - if ( count($filtered_processes) !== count($processes) ) { |
|
| 110 | + if (count($filtered_processes) !== count($processes)) { |
|
| 111 | 111 | throw new \InvalidArgumentException(sprintf( |
| 112 | 112 | 'The $processes argument must be an array of non-running instances of "%s" class.', |
| 113 | 113 | '\Symfony\Component\Process\Process' |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function runAll() |
| 126 | 126 | { |
| 127 | - foreach ( $this as $process ) { |
|
| 127 | + foreach ($this as $process) { |
|
| 128 | 128 | $process->wait(); |
| 129 | 129 | } |
| 130 | 130 | |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | public function addProcess(Process $process, $key = null) |
| 146 | 146 | { |
| 147 | - if ( $key === null ) { |
|
| 147 | + if ($key === null) { |
|
| 148 | 148 | $this->processes[] = $process; |
| 149 | 149 | end($this->processes); |
| 150 | 150 | $this->waitingQueue[] = key($this->processes); |
| 151 | 151 | } |
| 152 | 152 | else { |
| 153 | - if ( !isset($this->processes[$key]) ) { |
|
| 153 | + if (!isset($this->processes[$key])) { |
|
| 154 | 154 | $this->processes[$key] = $process; |
| 155 | 155 | $this->waitingQueue[] = $key; |
| 156 | 156 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | { |
| 235 | 235 | $this->key = null; |
| 236 | 236 | |
| 237 | - if ( !count($this->waitingQueue) ) { |
|
| 237 | + if (!count($this->waitingQueue)) { |
|
| 238 | 238 | return; |
| 239 | 239 | } |
| 240 | 240 | |
@@ -245,33 +245,33 @@ discard block |
||
| 245 | 245 | $executed_index = null; |
| 246 | 246 | |
| 247 | 247 | do { |
| 248 | - foreach ( $this->runningQueue as $index => $process_key ) { |
|
| 248 | + foreach ($this->runningQueue as $index => $process_key) { |
|
| 249 | 249 | $process = $this->processes[$process_key]; |
| 250 | 250 | |
| 251 | 251 | try { |
| 252 | 252 | $process->checkTimeout(); |
| 253 | 253 | |
| 254 | - if ( $process->isTerminated() ) { |
|
| 255 | - if ( $executed_index === null ) { |
|
| 254 | + if ($process->isTerminated()) { |
|
| 255 | + if ($executed_index === null) { |
|
| 256 | 256 | $executed_index = $index; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | continue; |
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | - catch ( \Exception $exception ) { |
|
| 262 | + catch (\Exception $exception) { |
|
| 263 | 263 | $this->setProcessException($process_key, $exception); |
| 264 | 264 | $executed_index = $index; |
| 265 | 265 | break; |
| 266 | 266 | } |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - if ( $executed_index === null ) { |
|
| 269 | + if ($executed_index === null) { |
|
| 270 | 270 | // Check for a setUpdateInterval() timeout. |
| 271 | - if ( $timeout !== null ) { |
|
| 271 | + if ($timeout !== null) { |
|
| 272 | 272 | $elapsed = microtime(true) - $start; |
| 273 | 273 | |
| 274 | - if ( $elapsed > $timeout ) { |
|
| 274 | + if ($elapsed > $timeout) { |
|
| 275 | 275 | $this->isTimeout = true; |
| 276 | 276 | |
| 277 | 277 | return; |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | |
| 281 | 281 | usleep(1000); |
| 282 | 282 | } |
| 283 | - } while ( $executed_index === null ); |
|
| 283 | + } while ($executed_index === null); |
|
| 284 | 284 | |
| 285 | 285 | $this->key = $this->waitingQueue[$executed_index]; |
| 286 | 286 | unset($this->waitingQueue[$executed_index]); |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | */ |
| 320 | 320 | public function current() |
| 321 | 321 | { |
| 322 | - if ( $this->isTimeout ) { |
|
| 322 | + if ($this->isTimeout) { |
|
| 323 | 323 | return null; |
| 324 | 324 | } |
| 325 | 325 | |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | */ |
| 334 | 334 | public function key() |
| 335 | 335 | { |
| 336 | - if ( $this->isTimeout ) { |
|
| 336 | + if ($this->isTimeout) { |
|
| 337 | 337 | // Returning "null" only works since PHP 5.5, so return empty string instead. |
| 338 | 338 | return ''; |
| 339 | 339 | } |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | */ |
| 349 | 349 | public function valid() |
| 350 | 350 | { |
| 351 | - if ( $this->isTimeout ) { |
|
| 351 | + if ($this->isTimeout) { |
|
| 352 | 352 | return true; |
| 353 | 353 | } |
| 354 | 354 | |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | { |
| 365 | 365 | $old_running_queue = $this->runningQueue; |
| 366 | 366 | |
| 367 | - if ( $this->limit ) { |
|
| 367 | + if ($this->limit) { |
|
| 368 | 368 | $this->runningQueue = array_slice($this->waitingQueue, 0, $this->limit, true); |
| 369 | 369 | } |
| 370 | 370 | else { |
@@ -372,8 +372,8 @@ discard block |
||
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | // Start processes, that were just added to the running queue. |
| 375 | - foreach ( $this->runningQueue as $index => $process_key ) { |
|
| 376 | - if ( !isset($old_running_queue[$index]) ) { |
|
| 375 | + foreach ($this->runningQueue as $index => $process_key) { |
|
| 376 | + if (!isset($old_running_queue[$index])) { |
|
| 377 | 377 | $this->processes[$process_key]->start(); |
| 378 | 378 | } |
| 379 | 379 | } |