@@ -10,7 +10,7 @@ |
||
10 | 10 | |
11 | 11 | class DIMetaLoader extends ContainerBuilder |
12 | 12 | { |
13 | - static $DEFAULT_ANNOTATIONS=[ |
|
13 | + static $DEFAULT_ANNOTATIONS = [ |
|
14 | 14 | [VarAnnotationHandler::class, "properties.*.children[?name=='var'][]"], |
15 | 15 | [InjectAnnotationHandler::class, "properties.*.children[?name=='inject'][]"] |
16 | 16 | ]; |
@@ -22,11 +22,11 @@ |
||
22 | 22 | } |
23 | 23 | |
24 | 24 | $class = new \ReflectionClass($name); |
25 | - if(isset($name::$__enableDIAnnotations__) && $name::$__enableDIAnnotations__){ |
|
25 | + if (isset($name::$__enableDIAnnotations__) && $name::$__enableDIAnnotations__) { |
|
26 | 26 | $context = $this->loader->build($name); |
27 | 27 | /**@var $context ObjectDefinitionContext */ |
28 | 28 | $definition = $context->definition; |
29 | - }else{ |
|
29 | + }else { |
|
30 | 30 | $definition = new ObjectDefinition($name); |
31 | 31 | } |
32 | 32 |
@@ -26,7 +26,7 @@ |
||
26 | 26 | $context = $this->loader->build($name); |
27 | 27 | /**@var $context ObjectDefinitionContext */ |
28 | 28 | $definition = $context->definition; |
29 | - }else{ |
|
29 | + } else{ |
|
30 | 30 | $definition = new ObjectDefinition($name); |
31 | 31 | } |
32 | 32 |
@@ -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; |
@@ -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 | } |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | public function create() |
29 | 29 | { |
30 | 30 | $data = []; |
31 | - foreach ($this->getColumns() as $column){ |
|
32 | - if(isset($this->object->$column)){ |
|
33 | - if(is_array($this->object->$column) || is_object($this->object->$column)){ |
|
31 | + foreach ($this->getColumns() as $column) { |
|
32 | + if (isset($this->object->$column)) { |
|
33 | + if (is_array($this->object->$column) || is_object($this->object->$column)) { |
|
34 | 34 | $data[$column] = json_encode($this->object->$column); |
35 | - }else{ |
|
35 | + }else { |
|
36 | 36 | $data[$column] = $this->object->$column; |
37 | 37 | } |
38 | 38 | |
@@ -48,18 +48,18 @@ discard block |
||
48 | 48 | * @param array $columns columns to update. if columns is empty array, update all of the columns |
49 | 49 | * @return int rows updated |
50 | 50 | */ |
51 | - public function update(array $columns=[]) |
|
51 | + public function update(array $columns = []) |
|
52 | 52 | { |
53 | 53 | $data = []; |
54 | 54 | $pk = $this->entity->getPK(); |
55 | - foreach ($this->getColumns() as $column){ |
|
56 | - if(count($columns) && !in_array($column, $columns)){ |
|
55 | + foreach ($this->getColumns() as $column) { |
|
56 | + if (count($columns) && !in_array($column, $columns)) { |
|
57 | 57 | continue; |
58 | 58 | } |
59 | - if($pk != $column && isset($this->object->$column)){ |
|
60 | - if(is_array($this->object->$column) || is_object($this->object->$column)){ |
|
59 | + if ($pk != $column && isset($this->object->$column)) { |
|
60 | + if (is_array($this->object->$column) || is_object($this->object->$column)) { |
|
61 | 61 | $data[$column] = json_encode($this->object->$column); |
62 | - }else{ |
|
62 | + }else { |
|
63 | 63 | $data[$column] = $this->object->$column; |
64 | 64 | } |
65 | 65 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | protected function getColumns() |
86 | 86 | { |
87 | 87 | $columns = []; |
88 | - foreach ($this->entity->getProperties() as $p){ |
|
88 | + foreach ($this->entity->getProperties() as $p) { |
|
89 | 89 | $columns[] = $p->name; |
90 | 90 | } |
91 | 91 | 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 | } |
@@ -49,7 +49,6 @@ discard block |
||
49 | 49 | |
50 | 50 | /** |
51 | 51 | * where 语法见 @see WhereRule |
52 | - * @param array|string $expr |
|
53 | 52 | * @param mixed|null $_ |
54 | 53 | * @return \PhpBoot\DB\rules\basic\WhereRule |
55 | 54 | */ |
@@ -91,7 +90,7 @@ discard block |
||
91 | 90 | /** |
92 | 91 | * @param int|string $id |
93 | 92 | * @param array $values |
94 | - * @return int updated row count |
|
93 | + * @return \PhpBoot\DB\impls\ExecResult updated row count |
|
95 | 94 | */ |
96 | 95 | public function update($id, $values) |
97 | 96 | { |
@@ -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 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param mixed|null $_ |
54 | 54 | * @return \PhpBoot\DB\rules\basic\WhereRule |
55 | 55 | */ |
56 | - public function deleteWhere($conditions, $_=null) |
|
56 | + public function deleteWhere($conditions, $_ = null) |
|
57 | 57 | { |
58 | 58 | $query = $this->db->deleteFrom($this->entity->getTable()); |
59 | 59 | return call_user_func_array([$query, 'where'], func_get_args()); |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | * @param string $_ |
76 | 76 | * @return \PhpBoot\DB\rules\select\WhereRule |
77 | 77 | */ |
78 | - public function findWhere($conditions=null, $_=null) |
|
78 | + public function findWhere($conditions = null, $_ = null) |
|
79 | 79 | { |
80 | - $query = $this->db->select($this->getColumns()) |
|
80 | + $query = $this->db->select($this->getColumns()) |
|
81 | 81 | ->from($this->entity->getTable()); |
82 | - $query->context->resultHandler = function ($result){ |
|
83 | - foreach ($result as &$i){ |
|
82 | + $query->context->resultHandler = function($result) { |
|
83 | + foreach ($result as &$i) { |
|
84 | 84 | $i = $this->entity->make($i, false); |
85 | 85 | } |
86 | 86 | return $result; |
@@ -107,16 +107,16 @@ discard block |
||
107 | 107 | * @param string $_ |
108 | 108 | * @return \PhpBoot\DB\rules\basic\WhereRule |
109 | 109 | */ |
110 | - public function updateWhere($values, $conditions, $_=null) |
|
110 | + public function updateWhere($values, $conditions, $_ = null) |
|
111 | 111 | { |
112 | - $query = $this->db->update($this->entity->getTable())->set($values); |
|
113 | - return call_user_func_array([$query, 'where'], array_slice(func_get_args(),1)); |
|
112 | + $query = $this->db->update($this->entity->getTable())->set($values); |
|
113 | + return call_user_func_array([$query, 'where'], array_slice(func_get_args(), 1)); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | protected function getColumns() |
117 | 117 | { |
118 | 118 | $columns = []; |
119 | - foreach ($this->entity->getProperties() as $p){ |
|
119 | + foreach ($this->entity->getProperties() as $p) { |
|
120 | 120 | $columns[] = $p->name; |
121 | 121 | } |
122 | 122 | return $columns; |
@@ -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 | } |