@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | return $this->loader; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - $path = __DIR__ . '/../../vendor/autoload.php'; |
|
| 42 | + $path = __DIR__.'/../../vendor/autoload.php'; |
|
| 43 | 43 | if (!file_exists($path)) { |
| 44 | - $path = __DIR__ . '/../../../../autoload.php'; |
|
| 44 | + $path = __DIR__.'/../../../../autoload.php'; |
|
| 45 | 45 | if (!file_exists($path)) { |
| 46 | 46 | throw new \RuntimeException("Autoload path '$path' not found"); |
| 47 | 47 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | public function getResult() |
| 89 | 89 | { |
| 90 | - if ($this->hasError && ( $this->hasError['type'] == E_ERROR || $this->hasError['type'] == E_USER_ERROR )) { |
|
| 90 | + if ($this->hasError && ($this->hasError['type'] == E_ERROR || $this->hasError['type'] == E_USER_ERROR)) { |
|
| 91 | 91 | throw new \RuntimeException( |
| 92 | 92 | sprintf( |
| 93 | 93 | 'Thread error: "%s", in "%s" at line %d. <<--- ', |
@@ -5,13 +5,13 @@ discard block |
||
| 5 | 5 | // Method to be executed in a thread |
| 6 | 6 | function Foo($t) |
| 7 | 7 | { |
| 8 | - echo "Starting thread #$t" . PHP_EOL;; |
|
| 8 | + echo "Starting thread #$t".PHP_EOL; ; |
|
| 9 | 9 | sleep(1 * rand(1, 5)); |
| 10 | 10 | for ($i = 0; $i < 10; $i++) { |
| 11 | - echo "Hello from thread #$t, i=$i" . PHP_EOL; |
|
| 11 | + echo "Hello from thread #$t, i=$i".PHP_EOL; |
|
| 12 | 12 | sleep(1); |
| 13 | 13 | } |
| 14 | - echo "Ending thread #$t" . PHP_EOL; |
|
| 14 | + echo "Ending thread #$t".PHP_EOL; |
|
| 15 | 15 | |
| 16 | 16 | return uniqid("Thread_{$t}_"); |
| 17 | 17 | } |
@@ -33,18 +33,18 @@ discard block |
||
| 33 | 33 | // Wait until there is no more active workers |
| 34 | 34 | // You can use $threadPool->waitWorkers() instead the loop below |
| 35 | 35 | while ($threadPool->activeWorkers() > 0) { |
| 36 | - echo "Active Workers : " . $threadPool->activeWorkers() . "\n"; |
|
| 36 | + echo "Active Workers : ".$threadPool->activeWorkers()."\n"; |
|
| 37 | 37 | sleep(1); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | // Get the return value from the thread. |
| 41 | 41 | foreach ($threadPool->getThreads() as $thid) { |
| 42 | - echo 'Result: ' . $threadPool->getThreadResult($thid) . "\n"; |
|
| 42 | + echo 'Result: '.$threadPool->getThreadResult($thid)."\n"; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | echo "\n\nEnded!\n"; |
| 46 | 46 | |
| 47 | 47 | } catch (Exception $e) { |
| 48 | - echo 'Exception: ' . $e . PHP_EOL; |
|
| 48 | + echo 'Exception: '.$e.PHP_EOL; |
|
| 49 | 49 | } |
| 50 | 50 | |