@@ -10,25 +10,25 @@ discard block |
||
| 10 | 10 | /** |
| 11 | 11 | * @param string|array $fileName 文件的绝对路径 |
| 12 | 12 | */ |
| 13 | - function __construct($fileName){ |
|
| 13 | + function __construct($fileName) { |
|
| 14 | 14 | $fileNames = array(); |
| 15 | - if(is_string($fileName)){ |
|
| 16 | - $fileNames[]=$fileName; |
|
| 17 | - }else{ |
|
| 15 | + if (is_string($fileName)) { |
|
| 16 | + $fileNames[] = $fileName; |
|
| 17 | + }else { |
|
| 18 | 18 | is_array($fileName) or \PhpBoot\abort(new \InvalidArgumentException("string or array is required by param 0")); |
| 19 | 19 | $fileNames = $fileName; |
| 20 | 20 | } |
| 21 | - foreach ($fileNames as $fileName){ |
|
| 22 | - if(is_file($fileName)){ |
|
| 21 | + foreach ($fileNames as $fileName) { |
|
| 22 | + if (is_file($fileName)) { |
|
| 23 | 23 | $this->fileName[$fileName] = @filemtime($fileName); |
| 24 | 24 | }else { |
| 25 | 25 | $this->fileName[$fileName] = @filemtime($fileName); |
| 26 | - if(!is_dir($fileName)){ |
|
| 26 | + if (!is_dir($fileName)) { |
|
| 27 | 27 | continue; |
| 28 | 28 | } |
| 29 | 29 | $files = @dir($fileName) or \PhpBoot\abort("open dir $fileName failed"); |
| 30 | - while (!!($file = $files->read())){ |
|
| 31 | - if($file == '.' || $file == '..') { |
|
| 30 | + while (!!($file = $files->read())) { |
|
| 31 | + if ($file == '.' || $file == '..') { |
|
| 32 | 32 | continue; |
| 33 | 33 | } |
| 34 | 34 | $this->fileName[$fileName.'/'.$file] = @filemtime($fileName.'/'.$file); |
@@ -43,13 +43,13 @@ discard block |
||
| 43 | 43 | * @param int $createdTime |
| 44 | 44 | * @return boolean |
| 45 | 45 | */ |
| 46 | - public function __invoke($data, $createdTime){ |
|
| 47 | - foreach ($this->fileName as $name => $time){ |
|
| 48 | - if(@filemtime($name) != $time){ |
|
| 46 | + public function __invoke($data, $createdTime) { |
|
| 47 | + foreach ($this->fileName as $name => $time) { |
|
| 48 | + if (@filemtime($name) != $time) { |
|
| 49 | 49 | return false; |
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | return true; |
| 53 | 53 | } |
| 54 | - private $fileName=[]; //文件全路径 |
|
| 54 | + private $fileName = []; //文件全路径 |
|
| 55 | 55 | } |
@@ -14,14 +14,14 @@ |
||
| 14 | 14 | $fileNames = array(); |
| 15 | 15 | if(is_string($fileName)){ |
| 16 | 16 | $fileNames[]=$fileName; |
| 17 | - }else{ |
|
| 17 | + } else{ |
|
| 18 | 18 | is_array($fileName) or \PhpBoot\abort(new \InvalidArgumentException("string or array is required by param 0")); |
| 19 | 19 | $fileNames = $fileName; |
| 20 | 20 | } |
| 21 | 21 | foreach ($fileNames as $fileName){ |
| 22 | 22 | if(is_file($fileName)){ |
| 23 | 23 | $this->fileName[$fileName] = @filemtime($fileName); |
| 24 | - }else { |
|
| 24 | + } else { |
|
| 25 | 25 | $this->fileName[$fileName] = @filemtime($fileName); |
| 26 | 26 | if(!is_dir($fileName)){ |
| 27 | 27 | continue; |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | $line = $e->getLine(); |
| 36 | 36 | } |
| 37 | 37 | if($level){ |
| 38 | - Logger::$level($message, $context +['@file'=>$file, '@line'=>$line]); |
|
| 38 | + Logger::$level($message, $context +['@file'=>$file, '@line'=>$line]); |
|
| 39 | 39 | } |
| 40 | 40 | throw $e; |
| 41 | 41 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | if($error instanceof \Exception){ |
| 22 | 22 | $e = $error; |
| 23 | 23 | $message = "exception '".get_class($error)."' with message {$error->getMessage()}"; |
| 24 | - }else{ |
|
| 24 | + } else{ |
|
| 25 | 25 | $e = new \RuntimeException($error); |
| 26 | 26 | $message = $error; |
| 27 | 27 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | if($e->getFile() == __FILE__){ |
| 31 | 31 | $file = $trace[0]['file']; |
| 32 | 32 | $line = $trace[0]['line']; |
| 33 | - }else{ |
|
| 33 | + } else{ |
|
| 34 | 34 | $file = $e->getFile(); |
| 35 | 35 | $line = $e->getLine(); |
| 36 | 36 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | { |
| 54 | 54 | if(is_object($entity)){ |
| 55 | 55 | return $db->getApp()->make(ModelWithObject::class, ['db'=>$db, 'entity'=>$entity]); |
| 56 | - }else{ |
|
| 56 | + } else{ |
|
| 57 | 57 | return $db->getApp()->make(ModelWithClass::class, ['db'=>$db, 'entityName'=>$entity]); |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | use PhpBoot\ORM\ModelWithObject; |
| 6 | 6 | use PhpBoot\Utils\Logger; |
| 7 | 7 | |
| 8 | -if (! function_exists('PhpBoot\abort')) { |
|
| 8 | +if (!function_exists('PhpBoot\abort')) { |
|
| 9 | 9 | /** |
| 10 | 10 | * 抛出异常, 并记录日志 |
| 11 | 11 | * @param string|\Exception $error |
@@ -13,29 +13,29 @@ discard block |
||
| 13 | 13 | * @param string $level "error"|"warning"|"info"|"debug"|null |
| 14 | 14 | * @throws \Exception |
| 15 | 15 | */ |
| 16 | - function abort($error = '', $context=[], $level='warning') |
|
| 16 | + function abort($error = '', $context = [], $level = 'warning') |
|
| 17 | 17 | { |
| 18 | - if(is_object($context)){ |
|
| 18 | + if (is_object($context)) { |
|
| 19 | 19 | $context = get_object_vars($context); |
| 20 | 20 | } |
| 21 | - if($error instanceof \Exception){ |
|
| 21 | + if ($error instanceof \Exception) { |
|
| 22 | 22 | $e = $error; |
| 23 | 23 | $message = "exception '".get_class($error)."' with message {$error->getMessage()}"; |
| 24 | - }else{ |
|
| 24 | + }else { |
|
| 25 | 25 | $e = new \RuntimeException($error); |
| 26 | 26 | $message = $error; |
| 27 | 27 | } |
| 28 | 28 | $trace = $e->getTrace(); |
| 29 | 29 | |
| 30 | - if($e->getFile() == __FILE__){ |
|
| 30 | + if ($e->getFile() == __FILE__) { |
|
| 31 | 31 | $file = $trace[0]['file']; |
| 32 | 32 | $line = $trace[0]['line']; |
| 33 | - }else{ |
|
| 33 | + }else { |
|
| 34 | 34 | $file = $e->getFile(); |
| 35 | 35 | $line = $e->getLine(); |
| 36 | 36 | } |
| 37 | - if($level){ |
|
| 38 | - Logger::$level($message, $context +['@file'=>$file, '@line'=>$line]); |
|
| 37 | + if ($level) { |
|
| 38 | + Logger::$level($message, $context + ['@file'=>$file, '@line'=>$line]); |
|
| 39 | 39 | } |
| 40 | 40 | throw $e; |
| 41 | 41 | } |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | function models(DB $db, $entity) |
| 63 | 63 | { |
| 64 | - if(is_object($entity)){ |
|
| 64 | + if (is_object($entity)) { |
|
| 65 | 65 | return $db->getApp()->make(ModelWithObject::class, ['db'=>$db, 'entity'=>$entity]); |
| 66 | - }else{ |
|
| 66 | + }else { |
|
| 67 | 67 | return $db->getApp()->make(ModelWithClass::class, ['db'=>$db, 'entityName'=>$entity]); |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | /** |
| 4 | 4 | * @author caoym |
| 5 | 5 | */ |
| 6 | -class Context{ |
|
| 6 | +class Context { |
|
| 7 | 7 | |
| 8 | 8 | public function __construct($connection) |
| 9 | 9 | { |
@@ -14,13 +14,13 @@ discard block |
||
| 14 | 14 | * 拼接sql语句,并自动插入空格 |
| 15 | 15 | * @param string $sql 表达式 |
| 16 | 16 | */ |
| 17 | - public function appendSql($sql, $addSpace=true){ |
|
| 18 | - if($this->sql == ''){ |
|
| 17 | + public function appendSql($sql, $addSpace = true) { |
|
| 18 | + if ($this->sql == '') { |
|
| 19 | 19 | $this->sql = $sql; |
| 20 | - }else{ |
|
| 21 | - if($addSpace){ |
|
| 20 | + }else { |
|
| 21 | + if ($addSpace) { |
|
| 22 | 22 | $this->sql = $this->sql.' '.$sql; |
| 23 | - }else{ |
|
| 23 | + }else { |
|
| 24 | 24 | $this->sql = $this->sql.$sql; |
| 25 | 25 | } |
| 26 | 26 | } |
@@ -29,15 +29,15 @@ discard block |
||
| 29 | 29 | * 增加绑定变量值 |
| 30 | 30 | * @param array $params 变量 |
| 31 | 31 | */ |
| 32 | - public function appendParams($params){ |
|
| 32 | + public function appendParams($params) { |
|
| 33 | 33 | $this->params = array_merge($this->params, $params); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | public function handleResult($result) |
| 37 | 37 | { |
| 38 | - if($resultHandler = $this->resultHandler){ |
|
| 38 | + if ($resultHandler = $this->resultHandler) { |
|
| 39 | 39 | return $resultHandler($result); |
| 40 | - }else{ |
|
| 40 | + }else { |
|
| 41 | 41 | return $result; |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | * @var callable |
| 46 | 46 | */ |
| 47 | 47 | public $resultHandler; |
| 48 | - public $sql=''; |
|
| 49 | - public $params=[]; |
|
| 48 | + public $sql = ''; |
|
| 49 | + public $params = []; |
|
| 50 | 50 | /** |
| 51 | 51 | * @var \PDO |
| 52 | 52 | */ |
@@ -17,10 +17,10 @@ discard block |
||
| 17 | 17 | public function appendSql($sql, $addSpace=true){ |
| 18 | 18 | if($this->sql == ''){ |
| 19 | 19 | $this->sql = $sql; |
| 20 | - }else{ |
|
| 20 | + } else{ |
|
| 21 | 21 | if($addSpace){ |
| 22 | 22 | $this->sql = $this->sql.' '.$sql; |
| 23 | - }else{ |
|
| 23 | + } else{ |
|
| 24 | 24 | $this->sql = $this->sql.$sql; |
| 25 | 25 | } |
| 26 | 26 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | { |
| 38 | 38 | if($resultHandler = $this->resultHandler){ |
| 39 | 39 | return $resultHandler($result); |
| 40 | - }else{ |
|
| 40 | + } else{ |
|
| 41 | 41 | return $result; |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -7,26 +7,26 @@ discard block |
||
| 7 | 7 | * 既从aaa"bb\"b"ccc中, 取出"bb\"b" |
| 8 | 8 | * @author caoym |
| 9 | 9 | */ |
| 10 | -class NestedStringCut{ |
|
| 10 | +class NestedStringCut { |
|
| 11 | 11 | |
| 12 | - public function __construct($str){ |
|
| 12 | + public function __construct($str) { |
|
| 13 | 13 | |
| 14 | 14 | $pos = 0; |
| 15 | 15 | $state = 'stateNormal'; |
| 16 | - while (true){ |
|
| 16 | + while (true) { |
|
| 17 | 17 | $pos = $this->$state($str, $pos, $state); |
| 18 | - if($pos === false){ |
|
| 18 | + if ($pos === false) { |
|
| 19 | 19 | break; |
| 20 | 20 | } |
| 21 | 21 | }; |
| 22 | 22 | return false; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function getSnippets(){ |
|
| 25 | + public function getSnippets() { |
|
| 26 | 26 | return $this->snippets; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - public function getText(){ |
|
| 29 | + public function getText() { |
|
| 30 | 30 | return implode('', $this->snippets); |
| 31 | 31 | } |
| 32 | 32 | /** |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | * @param int $pos |
| 35 | 35 | * @param int |
| 36 | 36 | */ |
| 37 | - public function mapPos($pos){ |
|
| 37 | + public function mapPos($pos) { |
|
| 38 | 38 | |
| 39 | - foreach ($this->snippets as $k => $v){ |
|
| 39 | + foreach ($this->snippets as $k => $v) { |
|
| 40 | 40 | $pos += $k; |
| 41 | - if($pos < $k + strlen($v)){ |
|
| 41 | + if ($pos<$k + strlen($v)) { |
|
| 42 | 42 | break; |
| 43 | 43 | } |
| 44 | 44 | $pos -= ($k + strlen($v)); |
@@ -49,21 +49,21 @@ discard block |
||
| 49 | 49 | /** |
| 50 | 50 | * 普通状态 |
| 51 | 51 | */ |
| 52 | - private function stateNormal($str, $pos, &$next){ |
|
| 52 | + private function stateNormal($str, $pos, &$next) { |
|
| 53 | 53 | $ori = $pos; |
| 54 | 54 | $posSQ = strpos($str, '\'', $pos); |
| 55 | 55 | $posDQ = strpos($str, '"', $pos); |
| 56 | 56 | $pos = $posSQ; |
| 57 | 57 | $this->subStateQ = '\''; |
| 58 | 58 | $next = 'stateQ'; |
| 59 | - if($posDQ !== false && (($posDQ < $pos) || ($pos === false)) ){ |
|
| 59 | + if ($posDQ !== false && (($posDQ<$pos) || ($pos === false))) { |
|
| 60 | 60 | $pos = $posDQ; |
| 61 | 61 | $this->subStateQ = '"'; |
| 62 | 62 | } |
| 63 | - if($pos !== false){ |
|
| 64 | - $this->snippets[$ori] = substr($str, $ori, $pos-$ori); |
|
| 65 | - $pos ++; |
|
| 66 | - }else{ |
|
| 63 | + if ($pos !== false) { |
|
| 64 | + $this->snippets[$ori] = substr($str, $ori, $pos - $ori); |
|
| 65 | + $pos++; |
|
| 66 | + }else { |
|
| 67 | 67 | $this->snippets[$ori] = substr($str, $ori); |
| 68 | 68 | } |
| 69 | 69 | return $pos; |
@@ -72,27 +72,27 @@ discard block |
||
| 72 | 72 | /** |
| 73 | 73 | * 进入引号状态 |
| 74 | 74 | */ |
| 75 | - private function stateQ($str, $pos, &$next){ |
|
| 75 | + private function stateQ($str, $pos, &$next) { |
|
| 76 | 76 | $posESC = strpos($str, '\\', $pos); |
| 77 | 77 | $posQ = strpos($str, $this->subStateQ, $pos); |
| 78 | 78 | $pos = $posESC; |
| 79 | 79 | $next = 'stateESC'; |
| 80 | 80 | |
| 81 | - if($posQ !== false && (($posQ<$posESC) || ($posESC === false))){ |
|
| 81 | + if ($posQ !== false && (($posQ<$posESC) || ($posESC === false))) { |
|
| 82 | 82 | $pos = $posQ; |
| 83 | 83 | $next = 'stateNormal'; |
| 84 | 84 | } |
| 85 | - if($pos !== false){ |
|
| 86 | - $pos ++; |
|
| 85 | + if ($pos !== false) { |
|
| 86 | + $pos++; |
|
| 87 | 87 | } |
| 88 | 88 | return $pos; |
| 89 | 89 | } |
| 90 | 90 | /** |
| 91 | 91 | * 进入转义状态 |
| 92 | 92 | */ |
| 93 | - private function stateESC($str, $pos, &$next){ |
|
| 93 | + private function stateESC($str, $pos, &$next) { |
|
| 94 | 94 | $pos++; |
| 95 | - if($pos >= strlen($str)){ |
|
| 95 | + if ($pos>=strlen($str)) { |
|
| 96 | 96 | return false; |
| 97 | 97 | } |
| 98 | 98 | $next = 'stateQ'; |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * 去掉嵌套字符串后的内容 |
| 103 | 103 | * @var array |
| 104 | 104 | */ |
| 105 | - private $snippets=array(); |
|
| 105 | + private $snippets = array(); |
|
| 106 | 106 | |
| 107 | 107 | private $subStateQ; |
| 108 | 108 | } |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | if($pos !== false){ |
| 64 | 64 | $this->snippets[$ori] = substr($str, $ori, $pos-$ori); |
| 65 | 65 | $pos ++; |
| 66 | - }else{ |
|
| 66 | + } else{ |
|
| 67 | 67 | $this->snippets[$ori] = substr($str, $ori); |
| 68 | 68 | } |
| 69 | 69 | return $pos; |
@@ -2,30 +2,30 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace PhpBoot\DB; |
| 4 | 4 | |
| 5 | -if(!function_exists("array_column")) |
|
| 5 | +if (!function_exists("array_column")) |
|
| 6 | 6 | { |
| 7 | 7 | |
| 8 | 8 | function array_column($array, $column_name) |
| 9 | 9 | { |
| 10 | 10 | |
| 11 | - return array_map(function($element) use($column_name){return $element[$column_name];}, $array); |
|
| 11 | + return array_map(function($element) use($column_name){return $element[$column_name]; }, $array); |
|
| 12 | 12 | |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | } |
| 16 | 16 | class Rows |
| 17 | 17 | { |
| 18 | - static function column($array,$column_name) |
|
| 18 | + static function column($array, $column_name) |
|
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - return array_map(function($element) use($column_name){return $element[$column_name];}, $array); |
|
| 21 | + return array_map(function($element) use($column_name){return $element[$column_name]; }, $array); |
|
| 22 | 22 | |
| 23 | 23 | } |
| 24 | - static public function leftJoin(&$lh, $rh, $lKey, $rkey, $destKey){ |
|
| 25 | - $map = array_combine(self::column($rh,$rkey),$rh); |
|
| 24 | + static public function leftJoin(&$lh, $rh, $lKey, $rkey, $destKey) { |
|
| 25 | + $map = array_combine(self::column($rh, $rkey), $rh); |
|
| 26 | 26 | |
| 27 | - foreach ($lh as &$v){ |
|
| 28 | - $v[$destKey]=$map[$v[$lKey]]; |
|
| 27 | + foreach ($lh as &$v) { |
|
| 28 | + $v[$destKey] = $map[$v[$lKey]]; |
|
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | \ No newline at end of file |
@@ -13,10 +13,10 @@ |
||
| 13 | 13 | function __construct($str) { |
| 14 | 14 | $this->str = $str; |
| 15 | 15 | } |
| 16 | - public function __toString(){ |
|
| 16 | + public function __toString() { |
|
| 17 | 17 | return $this->str; |
| 18 | 18 | } |
| 19 | - public function get(){ |
|
| 19 | + public function get() { |
|
| 20 | 20 | return $this->str; |
| 21 | 21 | } |
| 22 | 22 | private $str; |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | |
| 55 | 55 | $res = array_pop($this->waitResults); |
| 56 | 56 | if(isset($res[1])){ |
| 57 | - \PhpBoot\abort(new RpcException($res['reason'])); |
|
| 57 | + \PhpBoot\abort(new RpcException($res['reason'])); |
|
| 58 | 58 | }else{ |
| 59 | 59 | return $res[0]; |
| 60 | 60 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | $this->threads[] = function ()use($thread, $pos){ |
| 20 | 20 | try{ |
| 21 | 21 | $this->threadResults[$pos][0] = $thread(); |
| 22 | - }catch (\Exception $e){ |
|
| 22 | + } catch (\Exception $e){ |
|
| 23 | 23 | $this->threadResults[$pos][1] = $e; |
| 24 | 24 | } |
| 25 | 25 | }; |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $res = array_pop($this->waitResults); |
| 56 | 56 | if(isset($res[1])){ |
| 57 | 57 | \PhpBoot\abort(new RpcException($res['reason'])); |
| 58 | - }else{ |
|
| 58 | + } else{ |
|
| 59 | 59 | return $res[0]; |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -13,13 +13,13 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public function __construct(array $threads, callable $waitAll) |
| 15 | 15 | { |
| 16 | - foreach ($threads as $thread){ |
|
| 16 | + foreach ($threads as $thread) { |
|
| 17 | 17 | $pos = count($this->threadResults); |
| 18 | - $this->threadResults[] = [null,null]; |
|
| 19 | - $this->threads[] = function ()use($thread, $pos){ |
|
| 20 | - try{ |
|
| 18 | + $this->threadResults[] = [null, null]; |
|
| 19 | + $this->threads[] = function()use($thread, $pos){ |
|
| 20 | + try { |
|
| 21 | 21 | $this->threadResults[$pos][0] = $thread(); |
| 22 | - }catch (\Exception $e){ |
|
| 22 | + }catch (\Exception $e) { |
|
| 23 | 23 | $this->threadResults[$pos][1] = $e; |
| 24 | 24 | } |
| 25 | 25 | }; |
@@ -29,25 +29,25 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | public function run() |
| 31 | 31 | { |
| 32 | - while ($thread = array_pop($this->threads)){ |
|
| 32 | + while ($thread = array_pop($this->threads)) { |
|
| 33 | 33 | $thread(); |
| 34 | 34 | }; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function wait($waitAble){ |
|
| 37 | + public function wait($waitAble) { |
|
| 38 | 38 | array_push($this->waits, $waitAble); |
| 39 | 39 | $this->run(); |
| 40 | 40 | |
| 41 | - if(count($this->waits)){ |
|
| 41 | + if (count($this->waits)) { |
|
| 42 | 42 | $waitAll = $this->waitAll; |
| 43 | 43 | $this->waitResults = $waitAll($this->waits); |
| 44 | 44 | $this->waits = []; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - $res = array_pop($this->waitResults); |
|
| 48 | - if(isset($res[1])){ |
|
| 47 | + $res = array_pop($this->waitResults); |
|
| 48 | + if (isset($res[1])) { |
|
| 49 | 49 | \PhpBoot\abort(new RpcException($res['reason'])); |
| 50 | - }else{ |
|
| 50 | + }else { |
|
| 51 | 51 | return $res[0]; |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | return $request->getResults(); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public static function isRunning(){ |
|
| 23 | + public static function isRunning() { |
|
| 24 | 24 | return !!self::$currentContext; |
| 25 | 25 | } |
| 26 | 26 | |
@@ -21,12 +21,12 @@ discard block |
||
| 21 | 21 | * ] |
| 22 | 22 | * |
| 23 | 23 | */ |
| 24 | - return MultiRequest::run($threads, function($promises){ |
|
| 24 | + return MultiRequest::run($threads, function($promises) { |
|
| 25 | 25 | $res = []; |
| 26 | - foreach (Promise\settle($promises)->wait() as $i){ |
|
| 27 | - if(isset($i['reason'])){ |
|
| 26 | + foreach (Promise\settle($promises)->wait() as $i) { |
|
| 27 | + if (isset($i['reason'])) { |
|
| 28 | 28 | $res[] = [null, new RpcException($i['reason'])]; |
| 29 | - }else{ |
|
| 29 | + }else { |
|
| 30 | 30 | $res[] = [$i['value'], null]; |
| 31 | 31 | } |
| 32 | 32 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | }); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public static function isRunning(){ |
|
| 37 | + public static function isRunning() { |
|
| 38 | 38 | return MultiRequest::isRunning(); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | foreach (Promise\settle($promises)->wait() as $i){ |
| 27 | 27 | if(isset($i['reason'])){ |
| 28 | 28 | $res[] = [null, new RpcException($i['reason'])]; |
| 29 | - }else{ |
|
| 29 | + } else{ |
|
| 30 | 30 | $res[] = [$i['value'], null]; |
| 31 | 31 | } |
| 32 | 32 | } |