@@ -20,19 +20,19 @@ |
||
20 | 20 | public function __invoke(ObjectDefinitionContext $context, $ann) |
21 | 21 | { |
22 | 22 | $className = $context->definition->getClassName(); |
23 | - if(!$ann->parent){ |
|
23 | + if (!$ann->parent) { |
|
24 | 24 | Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of $className should be used with parent"); |
25 | 25 | } |
26 | 26 | $target = $ann->parent->name; |
27 | 27 | // @inject a.b.c |
28 | 28 | $params = new AnnotationParams($ann->description, 3); |
29 | - if(count($params) == 0){ |
|
29 | + if (count($params) == 0) { |
|
30 | 30 | //查找@var 定义的变量 |
31 | - if(!isset($context->vars[$target])){ |
|
31 | + if (!isset($context->vars[$target])) { |
|
32 | 32 | Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of $className should be used with a param or @var"); |
33 | 33 | } |
34 | 34 | $entryName = $context->vars[$target]; |
35 | - }else{ |
|
35 | + }else { |
|
36 | 36 | $entryName = $params[0]; |
37 | 37 | } |
38 | 38 |
@@ -32,7 +32,7 @@ |
||
32 | 32 | Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of $className should be used with a param or @var"); |
33 | 33 | } |
34 | 34 | $entryName = $context->vars[$target]; |
35 | - }else{ |
|
35 | + } else{ |
|
36 | 36 | $entryName = $params[0]; |
37 | 37 | } |
38 | 38 |
@@ -23,7 +23,7 @@ |
||
23 | 23 | public function __invoke(ObjectDefinitionContext $context, $ann) |
24 | 24 | { |
25 | 25 | $className = $context->definition->getClassName(); |
26 | - if(!$ann->parent){ |
|
26 | + if (!$ann->parent) { |
|
27 | 27 | Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of $className should be used with parent"); |
28 | 28 | } |
29 | 29 | $target = $ann->parent->name; |
@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | public function create() |
25 | 25 | { |
26 | 26 | $data = []; |
27 | - foreach ($this->getColumns() as $column){ |
|
28 | - if(isset($this->object->$column)){ |
|
29 | - if(is_array($this->object->$column) || is_object($this->object->$column)){ |
|
27 | + foreach ($this->getColumns() as $column) { |
|
28 | + if (isset($this->object->$column)) { |
|
29 | + if (is_array($this->object->$column) || is_object($this->object->$column)) { |
|
30 | 30 | $data[$column] = json_encode($this->object->$column); |
31 | - }else{ |
|
31 | + }else { |
|
32 | 32 | $data[$column] = $this->object->$column; |
33 | 33 | } |
34 | 34 | |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | { |
46 | 46 | $data = []; |
47 | 47 | $pk = $this->entity->getPK(); |
48 | - foreach ($this->getColumns() as $column){ |
|
49 | - if($pk != $column && isset($this->object->$column)){ |
|
50 | - if(is_array($this->object->$column) || is_object($this->object->$column)){ |
|
48 | + foreach ($this->getColumns() as $column) { |
|
49 | + if ($pk != $column && isset($this->object->$column)) { |
|
50 | + if (is_array($this->object->$column) || is_object($this->object->$column)) { |
|
51 | 51 | $data[$column] = json_encode($this->object->$column); |
52 | - }else{ |
|
52 | + }else { |
|
53 | 53 | $data[$column] = $this->object->$column; |
54 | 54 | } |
55 | 55 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | if(isset($this->object->$column)){ |
29 | 29 | if(is_array($this->object->$column) || is_object($this->object->$column)){ |
30 | 30 | $data[$column] = json_encode($this->object->$column); |
31 | - }else{ |
|
31 | + } else{ |
|
32 | 32 | $data[$column] = $this->object->$column; |
33 | 33 | } |
34 | 34 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | if($pk != $column && isset($this->object->$column)){ |
50 | 50 | if(is_array($this->object->$column) || is_object($this->object->$column)){ |
51 | 51 | $data[$column] = json_encode($this->object->$column); |
52 | - }else{ |
|
52 | + } else{ |
|
53 | 53 | $data[$column] = $this->object->$column; |
54 | 54 | } |
55 | 55 | } |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | ->from($this->entity->getTable()) |
30 | 30 | ->where("`{$this->entity->getPK()}` = ?", $id) |
31 | 31 | ->getFirst(); |
32 | - if($row){ |
|
32 | + if ($row) { |
|
33 | 33 | return $this->entity->make($row, false); |
34 | - }else{ |
|
34 | + }else { |
|
35 | 35 | return null; |
36 | 36 | } |
37 | 37 | } |
@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | * @param string $_ |
60 | 60 | * @return \PhpBoot\DB\rules\select\GroupByRule |
61 | 61 | */ |
62 | - public function where($conditions, $_=null) |
|
62 | + public function where($conditions, $_ = null) |
|
63 | 63 | { |
64 | - $query = $this->db->select($this->getColumns()) |
|
64 | + $query = $this->db->select($this->getColumns()) |
|
65 | 65 | ->from($this->entity->getTable()); |
66 | - $query->context->resultHandler = function ($result){ |
|
67 | - foreach ($result as &$i){ |
|
66 | + $query->context->resultHandler = function($result) { |
|
67 | + foreach ($result as &$i) { |
|
68 | 68 | $i = $this->entity->make($i, false); |
69 | 69 | } |
70 | 70 | return $result; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | protected function getColumns() |
77 | 77 | { |
78 | 78 | $columns = []; |
79 | - foreach ($this->entity->getProperties() as $p){ |
|
79 | + foreach ($this->entity->getProperties() as $p) { |
|
80 | 80 | $columns[] = $p->name; |
81 | 81 | } |
82 | 82 | return $columns; |
@@ -31,7 +31,7 @@ |
||
31 | 31 | ->getFirst(); |
32 | 32 | if($row){ |
33 | 33 | return $this->entity->make($row, false); |
34 | - }else{ |
|
34 | + } else{ |
|
35 | 35 | return null; |
36 | 36 | } |
37 | 37 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @package Once\route |
13 | 13 | * 函数参数元信息 |
14 | 14 | */ |
15 | -class ParamMeta{ |
|
15 | +class ParamMeta { |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * ParamMeta constructor. |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param string $description |
27 | 27 | * @param TypeContainerInterface|null $container |
28 | 28 | */ |
29 | - public function __construct($name, $source, $type, $isOptional ,$default, $isPassedByReference,$validation, $description="", $container=null){ |
|
29 | + public function __construct($name, $source, $type, $isOptional, $default, $isPassedByReference, $validation, $description = "", $container = null) { |
|
30 | 30 | $this->name = $name; |
31 | 31 | $this->source = $source; |
32 | 32 | $this->type = $type; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @param string $description |
21 | 21 | * @param TypeContainerInterface|null $container |
22 | 22 | */ |
23 | - public function __construct($name, $type=null, $isOptional=false,$default=null, $validation=null, $summary='', $description='', $container = null){ |
|
23 | + public function __construct($name, $type = null, $isOptional = false, $default = null, $validation = null, $summary = '', $description = '', $container = null) { |
|
24 | 24 | $this->name = $name; |
25 | 25 | $this->type = $type; |
26 | 26 | $this->default = $default; |
@@ -54,5 +54,5 @@ discard block |
||
54 | 54 | /** |
55 | 55 | * @var string |
56 | 56 | */ |
57 | - public $description=''; |
|
57 | + public $description = ''; |
|
58 | 58 | } |
59 | 59 | \ No newline at end of file |
@@ -7,17 +7,17 @@ discard block |
||
7 | 7 | * @author caoym |
8 | 8 | * |
9 | 9 | */ |
10 | -class SerializableFunc{ |
|
10 | +class SerializableFunc { |
|
11 | 11 | /** |
12 | 12 | * 方法,绑定参数 |
13 | 13 | * 如 |
14 | 14 | * func,arg1,arg2 |
15 | 15 | * array('a','method1'), arg1,arg2 |
16 | 16 | */ |
17 | - public function __construct(callable $func){ |
|
17 | + public function __construct(callable $func) { |
|
18 | 18 | $args = func_get_args(); |
19 | 19 | $this->func = $func; |
20 | - $this->bind = array_slice($args,1); |
|
20 | + $this->bind = array_slice($args, 1); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -25,15 +25,15 @@ discard block |
||
25 | 25 | * 调用时,将bind参数加在方法的最前面 |
26 | 26 | * @return mixed |
27 | 27 | */ |
28 | - public function __invoke(){ |
|
28 | + public function __invoke() { |
|
29 | 29 | $args = func_get_args(); |
30 | 30 | $params = $this->bind; |
31 | - foreach ($args as $arg){ |
|
31 | + foreach ($args as $arg) { |
|
32 | 32 | array_push($params, $arg); |
33 | 33 | } |
34 | 34 | $res = call_user_func_array($this->func, $params); |
35 | - foreach ($this->next as $next){ |
|
36 | - call_user_func_array($next,$args); |
|
35 | + foreach ($this->next as $next) { |
|
36 | + call_user_func_array($next, $args); |
|
37 | 37 | } |
38 | 38 | return $res; |
39 | 39 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * 串行调用 |
42 | 42 | * @var callable[] |
43 | 43 | */ |
44 | - public $next=array(); |
|
44 | + public $next = array(); |
|
45 | 45 | private $bind; |
46 | 46 | private $func; |
47 | 47 | } |
@@ -15,16 +15,16 @@ |
||
15 | 15 | $keys = explode('.', $key); |
16 | 16 | $keys = array_reverse($keys); |
17 | 17 | $cur = &$arr; |
18 | - while($p = array_pop($keys)){ |
|
18 | + while ($p = array_pop($keys)) { |
|
19 | 19 | $cur instanceof \ArrayAccess || is_array($cur) or \PhpBoot\abort(new \InvalidArgumentException('array or object of ArrayAccess required')); |
20 | - if(!isset($cur[$p])){ |
|
21 | - if(count($keys) == 0){ |
|
20 | + if (!isset($cur[$p])) { |
|
21 | + if (count($keys) == 0) { |
|
22 | 22 | $cur[$p] = $val; |
23 | - }else{ |
|
23 | + }else { |
|
24 | 24 | $cur[$p] = []; |
25 | 25 | } |
26 | - }else{ |
|
27 | - if(count($keys) == 0){ |
|
26 | + }else { |
|
27 | + if (count($keys) == 0) { |
|
28 | 28 | $cur[$p] = $val; |
29 | 29 | } |
30 | 30 | } |
@@ -20,10 +20,10 @@ |
||
20 | 20 | if(!isset($cur[$p])){ |
21 | 21 | if(count($keys) == 0){ |
22 | 22 | $cur[$p] = $val; |
23 | - }else{ |
|
23 | + } else{ |
|
24 | 24 | $cur[$p] = []; |
25 | 25 | } |
26 | - }else{ |
|
26 | + } else{ |
|
27 | 27 | if(count($keys) == 0){ |
28 | 28 | $cur[$p] = $val; |
29 | 29 | } |
@@ -145,7 +145,7 @@ |
||
145 | 145 | */ |
146 | 146 | static public function getDefaultLogger() |
147 | 147 | { |
148 | - if(!self::$defaultLogger){ |
|
148 | + if (!self::$defaultLogger) { |
|
149 | 149 | self::$defaultLogger = new \Monolog\Logger('default'); |
150 | 150 | } |
151 | 151 | return self::$defaultLogger; |