@@ -48,6 +48,9 @@ |
||
48 | 48 | |
49 | 49 | class OrderByRule extends LimitRule |
50 | 50 | { |
51 | + /** |
|
52 | + * @param Context $context |
|
53 | + */ |
|
51 | 54 | public function __construct($context){ |
52 | 55 | parent::__construct($context); |
53 | 56 | $this->impl = new OrderByImpl(); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | class BasicRule |
13 | 13 | { |
14 | - public function __construct(Context $context){ |
|
14 | + public function __construct(Context $context) { |
|
15 | 15 | $this->context = $context; |
16 | 16 | } |
17 | 17 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | class OrderByRule extends LimitRule |
50 | 50 | { |
51 | - public function __construct($context){ |
|
51 | + public function __construct($context) { |
|
52 | 52 | parent::__construct($context); |
53 | 53 | $this->impl = new OrderByImpl(); |
54 | 54 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return \PhpBoot\DB\rules\basic\LimitRule |
65 | 65 | */ |
66 | - public function orderBy($column, $order=null) { |
|
66 | + public function orderBy($column, $order = null) { |
|
67 | 67 | $this->impl->orderBy($this->context, $column, $order); |
68 | 68 | return new LimitRule($this->context); |
69 | 69 | } |
@@ -95,17 +95,17 @@ discard block |
||
95 | 95 | * @param mixed $_ |
96 | 96 | * @return WhereRule |
97 | 97 | */ |
98 | - public function where($conditions=null, $_=null) { |
|
99 | - if(is_callable($conditions)){ |
|
100 | - $callback = function ($context)use($conditions){ |
|
98 | + public function where($conditions = null, $_ = null) { |
|
99 | + if (is_callable($conditions)) { |
|
100 | + $callback = function($context)use($conditions){ |
|
101 | 101 | $rule = new ScopedQuery($context); |
102 | 102 | $conditions($rule); |
103 | 103 | }; |
104 | 104 | $conditions = $callback; |
105 | 105 | } |
106 | - if($this->isTheFirst){ |
|
107 | - WhereImpl::where($this->context, 'WHERE' ,$conditions, array_slice(func_get_args(), 1)); |
|
108 | - }else{ |
|
106 | + if ($this->isTheFirst) { |
|
107 | + WhereImpl::where($this->context, 'WHERE', $conditions, array_slice(func_get_args(), 1)); |
|
108 | + }else { |
|
109 | 109 | WhereImpl::where($this->context, 'AND', $conditions, array_slice(func_get_args(), 1)); |
110 | 110 | } |
111 | 111 | return new WhereRule($this->context, false); |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | * @param mixed $_ |
129 | 129 | * @return WhereRule |
130 | 130 | */ |
131 | - public function orWhere($conditions=null, $_=null) { |
|
132 | - if(is_callable($conditions)){ |
|
133 | - $callback = function ($context)use($conditions){ |
|
131 | + public function orWhere($conditions = null, $_ = null) { |
|
132 | + if (is_callable($conditions)) { |
|
133 | + $callback = function($context)use($conditions){ |
|
134 | 134 | $rule = new ScopedQuery($context); |
135 | 135 | $conditions($rule); |
136 | 136 | }; |
@@ -156,17 +156,17 @@ discard block |
||
156 | 156 | * @param null $_ |
157 | 157 | * @return ScopedQuery |
158 | 158 | */ |
159 | - public function where($expr, $_= null){ |
|
160 | - if(is_callable($expr)){ |
|
161 | - $callback = function ($context)use($expr){ |
|
159 | + public function where($expr, $_ = null) { |
|
160 | + if (is_callable($expr)) { |
|
161 | + $callback = function($context)use($expr){ |
|
162 | 162 | $rule = new ScopedQuery($context, true); |
163 | 163 | $expr($rule); |
164 | 164 | }; |
165 | 165 | $expr = $callback; |
166 | 166 | } |
167 | - if($this->isTheFirst){ |
|
167 | + if ($this->isTheFirst) { |
|
168 | 168 | WhereImpl::where($this->context, '', $expr, array_slice(func_get_args(), 1)); |
169 | - }else{ |
|
169 | + }else { |
|
170 | 170 | WhereImpl::where($this->context, 'AND', $expr, array_slice(func_get_args(), 1)); |
171 | 171 | } |
172 | 172 | return new ScopedQuery($this->context, false); |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | * @param null $_ |
177 | 177 | * @return ScopedQuery |
178 | 178 | */ |
179 | - public function orWhere($expr, $_= null){ |
|
180 | - if(is_callable($expr)){ |
|
181 | - $callback = function ($context)use($expr){ |
|
179 | + public function orWhere($expr, $_ = null) { |
|
180 | + if (is_callable($expr)) { |
|
181 | + $callback = function($context)use($expr){ |
|
182 | 182 | $rule = new ScopedQuery($context, true); |
183 | 183 | $expr($rule); |
184 | 184 | }; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | } |
106 | 106 | if($this->isTheFirst){ |
107 | 107 | WhereImpl::where($this->context, 'WHERE' ,$conditions, array_slice(func_get_args(), 1)); |
108 | - }else{ |
|
108 | + } else{ |
|
109 | 109 | WhereImpl::where($this->context, 'AND', $conditions, array_slice(func_get_args(), 1)); |
110 | 110 | } |
111 | 111 | return new WhereRule($this->context, false); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | } |
167 | 167 | if($this->isTheFirst){ |
168 | 168 | WhereImpl::where($this->context, '', $expr, array_slice(func_get_args(), 1)); |
169 | - }else{ |
|
169 | + } else{ |
|
170 | 170 | WhereImpl::where($this->context, 'AND', $expr, array_slice(func_get_args(), 1)); |
171 | 171 | } |
172 | 172 | return new ScopedQuery($this->context, false); |
@@ -113,6 +113,9 @@ discard block |
||
113 | 113 | |
114 | 114 | class OrderByRule extends LimitRule |
115 | 115 | { |
116 | + /** |
|
117 | + * @param Context $context |
|
118 | + */ |
|
116 | 119 | public function __construct($context){ |
117 | 120 | parent::__construct($context); |
118 | 121 | $this->order = new OrderByImpl(); |
@@ -260,7 +263,7 @@ discard block |
||
260 | 263 | * "WHERE a=1 AND b IN(1,2) AND c BETWEEN 1 AND 2 AND d<>1" |
261 | 264 | * |
262 | 265 | * @param string|array|callable $conditions |
263 | - * @param mixed $_ |
|
266 | + * @param string $_ |
|
264 | 267 | * @return \PhpBoot\DB\rules\select\WhereRule |
265 | 268 | */ |
266 | 269 | public function where($conditions=null, $_=null) { |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | } |
185 | 185 | if($this->isTheFirst){ |
186 | 186 | WhereImpl::where($this->context, 'HAVING', $expr, array_slice(func_get_args(), 1)); |
187 | - }else{ |
|
187 | + } else{ |
|
188 | 188 | WhereImpl::where($this->context, 'AND', $expr, array_slice(func_get_args(), 1)); |
189 | 189 | } |
190 | 190 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | } |
274 | 274 | if($this->isTheFirst){ |
275 | 275 | WhereImpl::where($this->context, 'WHERE' ,$conditions, array_slice(func_get_args(), 1)); |
276 | - }else{ |
|
276 | + } else{ |
|
277 | 277 | WhereImpl::where($this->context, 'AND', $conditions, array_slice(func_get_args(), 1)); |
278 | 278 | } |
279 | 279 | return new WhereRule($this->context, false); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param string|false $asDict |
40 | 40 | * @return array |
41 | 41 | */ |
42 | - public function get($asDict=false) { |
|
42 | + public function get($asDict = false) { |
|
43 | 43 | return ExecImpl::get($this->context, $asDict); |
44 | 44 | } |
45 | 45 | |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | * Execute sql and get one response |
54 | 54 | * @return null |
55 | 55 | */ |
56 | - public function getFirst(){ |
|
56 | + public function getFirst() { |
|
57 | 57 | $res = ExecImpl::get($this->context); |
58 | - if(count($res)){ |
|
58 | + if (count($res)) { |
|
59 | 59 | return $res[0]; |
60 | 60 | } |
61 | 61 | return null; |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * @param string $table |
69 | 69 | * @return \PhpBoot\DB\rules\select\JoinRule |
70 | 70 | */ |
71 | - public function from($table, $as=null){ |
|
72 | - FromImpl::from($this->context, $table,$as); |
|
71 | + public function from($table, $as = null) { |
|
72 | + FromImpl::from($this->context, $table, $as); |
|
73 | 73 | return new JoinRule($this->context); |
74 | 74 | } |
75 | 75 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param string $column |
81 | 81 | * @return \PhpBoot\DB\rules\select\GetRule |
82 | 82 | */ |
83 | - public function of($column){ |
|
83 | + public function of($column) { |
|
84 | 84 | ForUpdateOfImpl::of($this->context, $column); |
85 | 85 | return new GetRule($this->context); |
86 | 86 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * forUpdate() => 'FOR UPDATE' |
92 | 92 | * @return \PhpBoot\DB\rules\select\ForUpdateOfRule |
93 | 93 | */ |
94 | - public function forUpdate(){ |
|
94 | + public function forUpdate() { |
|
95 | 95 | ForUpdateImpl::forUpdate($this->context); |
96 | 96 | return new ForUpdateOfRule($this->context); |
97 | 97 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | class OrderByRule extends LimitRule |
115 | 115 | { |
116 | - public function __construct($context){ |
|
116 | + public function __construct($context) { |
|
117 | 117 | parent::__construct($context); |
118 | 118 | $this->order = new OrderByImpl(); |
119 | 119 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @param string $order Sql::ORDER_BY_ASC or Sql::ORDER_BY_DESC |
129 | 129 | * @return \PhpBoot\DB\rules\select\OrderByRule |
130 | 130 | */ |
131 | - public function orderBy($column, $order=null) { |
|
131 | + public function orderBy($column, $order = null) { |
|
132 | 132 | $this->order->orderBy($this->context, $column, $order); |
133 | 133 | return $this; |
134 | 134 | } |
@@ -174,17 +174,17 @@ discard block |
||
174 | 174 | * @param string $_ |
175 | 175 | * @return \PhpBoot\DB\rules\select\HavingRule |
176 | 176 | */ |
177 | - public function having($expr, $_=null) { |
|
178 | - if(is_callable($expr)){ |
|
179 | - $callback = function ($context)use($expr){ |
|
177 | + public function having($expr, $_ = null) { |
|
178 | + if (is_callable($expr)) { |
|
179 | + $callback = function($context)use($expr){ |
|
180 | 180 | $rule = new ScopedQuery($context); |
181 | 181 | $expr($rule); |
182 | 182 | }; |
183 | 183 | $expr = $callback; |
184 | 184 | } |
185 | - if($this->isTheFirst){ |
|
185 | + if ($this->isTheFirst) { |
|
186 | 186 | WhereImpl::where($this->context, 'HAVING', $expr, array_slice(func_get_args(), 1)); |
187 | - }else{ |
|
187 | + }else { |
|
188 | 188 | WhereImpl::where($this->context, 'AND', $expr, array_slice(func_get_args(), 1)); |
189 | 189 | } |
190 | 190 | |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | * @param string $_ |
212 | 212 | * @return \PhpBoot\DB\rules\select\HavingRule |
213 | 213 | */ |
214 | - public function orHaving($expr, $_=null) { |
|
215 | - if(is_callable($expr)){ |
|
216 | - $callback = function ($context)use($expr){ |
|
214 | + public function orHaving($expr, $_ = null) { |
|
215 | + if (is_callable($expr)) { |
|
216 | + $callback = function($context)use($expr){ |
|
217 | 217 | $rule = new ScopedQuery($context); |
218 | 218 | $expr($rule); |
219 | 219 | }; |
@@ -263,17 +263,17 @@ discard block |
||
263 | 263 | * @param mixed $_ |
264 | 264 | * @return \PhpBoot\DB\rules\select\WhereRule |
265 | 265 | */ |
266 | - public function where($conditions=null, $_=null) { |
|
267 | - if(is_callable($conditions)){ |
|
268 | - $callback = function ($context)use($conditions){ |
|
266 | + public function where($conditions = null, $_ = null) { |
|
267 | + if (is_callable($conditions)) { |
|
268 | + $callback = function($context)use($conditions){ |
|
269 | 269 | $rule = new ScopedQuery($context); |
270 | 270 | $conditions($rule); |
271 | 271 | }; |
272 | 272 | $conditions = $callback; |
273 | 273 | } |
274 | - if($this->isTheFirst){ |
|
275 | - WhereImpl::where($this->context, 'WHERE' ,$conditions, array_slice(func_get_args(), 1)); |
|
276 | - }else{ |
|
274 | + if ($this->isTheFirst) { |
|
275 | + WhereImpl::where($this->context, 'WHERE', $conditions, array_slice(func_get_args(), 1)); |
|
276 | + }else { |
|
277 | 277 | WhereImpl::where($this->context, 'AND', $conditions, array_slice(func_get_args(), 1)); |
278 | 278 | } |
279 | 279 | return new WhereRule($this->context, false); |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | * @param mixed $_ |
297 | 297 | * @return \PhpBoot\DB\rules\select\WhereRule |
298 | 298 | */ |
299 | - public function orWhere($conditions=null, $_=null) { |
|
300 | - if(is_callable($conditions)){ |
|
301 | - $callback = function ($context)use($conditions){ |
|
299 | + public function orWhere($conditions = null, $_ = null) { |
|
300 | + if (is_callable($conditions)) { |
|
301 | + $callback = function($context)use($conditions){ |
|
302 | 302 | $rule = new ScopedQuery($context); |
303 | 303 | $conditions($rule); |
304 | 304 | }; |
@@ -317,8 +317,8 @@ discard block |
||
317 | 317 | * @param string $table |
318 | 318 | * @return \PhpBoot\DB\rules\select\JoinOnRule |
319 | 319 | */ |
320 | - public function join($table){ |
|
321 | - JoinImpl::join($this->context,null, $table); |
|
320 | + public function join($table) { |
|
321 | + JoinImpl::join($this->context, null, $table); |
|
322 | 322 | return new JoinOnRule($this->context); |
323 | 323 | } |
324 | 324 | /** |
@@ -326,8 +326,8 @@ discard block |
||
326 | 326 | * @param string $table |
327 | 327 | * @return \PhpBoot\DB\rules\select\JoinOnRule |
328 | 328 | */ |
329 | - public function leftJoin($table){ |
|
330 | - JoinImpl::join($this->context,'LEFT', $table); |
|
329 | + public function leftJoin($table) { |
|
330 | + JoinImpl::join($this->context, 'LEFT', $table); |
|
331 | 331 | return new JoinOnRule($this->context); |
332 | 332 | } |
333 | 333 | /** |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | * @return \PhpBoot\DB\rules\select\JoinOnRule |
337 | 337 | */ |
338 | 338 | public function rightJoin($table) { |
339 | - JoinImpl::join($this->context,'RIGHT', $table); |
|
339 | + JoinImpl::join($this->context, 'RIGHT', $table); |
|
340 | 340 | return new JoinOnRule($this->context); |
341 | 341 | } |
342 | 342 | /** |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * @return \PhpBoot\DB\rules\select\JoinOnRule |
346 | 346 | */ |
347 | 347 | public function innerJoin($table) { |
348 | - JoinImpl::join($this->context,'INNER', $table); |
|
348 | + JoinImpl::join($this->context, 'INNER', $table); |
|
349 | 349 | return new JoinOnRule($this->context); |
350 | 350 | } |
351 | 351 | } |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | * @param string $condition |
358 | 358 | * @return \PhpBoot\DB\rules\select\JoinRule |
359 | 359 | */ |
360 | - public function on($condition){ |
|
360 | + public function on($condition) { |
|
361 | 361 | JoinOnImpl::on($this->context, $condition); |
362 | 362 | return new JoinRule($this->context); |
363 | 363 | } |
@@ -24,6 +24,9 @@ |
||
24 | 24 | |
25 | 25 | class UpdateSetRule extends BasicRule |
26 | 26 | { |
27 | + /** |
|
28 | + * @param \PhpBoot\DB\Context $context |
|
29 | + */ |
|
27 | 30 | public function __construct($context){ |
28 | 31 | parent::__construct($context); |
29 | 32 | $this->impl = new UpdateSetImpl(); |
@@ -30,7 +30,6 @@ |
||
30 | 30 | } |
31 | 31 | /** |
32 | 32 | * update('table')->set(['a'=>1]) => "UPDATE table SET a=1" |
33 | - |
|
34 | 33 | * update('table')->set('a=?',1) => "UPDATE table SET a=1" |
35 | 34 | * @param array|string $expr |
36 | 35 | * @param mixed $_ |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | class UpdateSetRule extends BasicRule |
26 | 26 | { |
27 | - public function __construct($context){ |
|
27 | + public function __construct($context) { |
|
28 | 28 | parent::__construct($context); |
29 | 29 | $this->impl = new UpdateSetImpl(); |
30 | 30 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param mixed $_ |
37 | 37 | * @return WhereRule |
38 | 38 | */ |
39 | - public function set($expr, $_=null) { |
|
39 | + public function set($expr, $_ = null) { |
|
40 | 40 | $this->impl->set($this->context, $expr, array_slice(func_get_args(), 1)); |
41 | 41 | return new WhereRule($this->context); |
42 | 42 | } |
@@ -21,20 +21,20 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function __invoke(ControllerContainer $container, $ann, EntityContainerBuilder $entityBuilder) |
23 | 23 | { |
24 | - if(!$ann->parent){ |
|
24 | + if (!$ann->parent) { |
|
25 | 25 | //Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()} should be used with parent route"); |
26 | 26 | return; |
27 | 27 | } |
28 | 28 | $target = $ann->parent->name; |
29 | 29 | $route = $container->getRoute($target); |
30 | - if(!$route){ |
|
30 | + if (!$route) { |
|
31 | 31 | //Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()}::$target should be used with parent route"); |
32 | - return ; |
|
32 | + return; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | $params = new AnnotationParams($ann->description, 2); |
36 | 36 | $type = $doc = null; |
37 | - if(count($params)>0){ |
|
37 | + if (count($params)>0) { |
|
38 | 38 | $type = TypeHint::normalize($params[0], $container->getClassName()); |
39 | 39 | } |
40 | 40 | $doc = $params->getRawParam(1, ''); |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | list($_, $meta) = $route |
43 | 43 | ->getResponseHandler() |
44 | 44 | ->getMappingBySource('return'); |
45 | - if($meta){ |
|
45 | + if ($meta) { |
|
46 | 46 | $meta->description = $doc; |
47 | 47 | $meta->type = $type; |
48 | - $meta->container = $type == 'void'?null:ContainerFactory::create($entityBuilder, $type); |
|
48 | + $meta->container = $type == 'void' ?null:ContainerFactory::create($entityBuilder, $type); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | } |
52 | 52 | \ No newline at end of file |
@@ -55,12 +55,12 @@ |
||
55 | 55 | */ |
56 | 56 | public function rule($rule, $fields) |
57 | 57 | { |
58 | - if(is_string($rule)){ |
|
58 | + if (is_string($rule)) { |
|
59 | 59 | $rules = explode('|', $rule); |
60 | - foreach ($rules as $r){ |
|
60 | + foreach ($rules as $r) { |
|
61 | 61 | $params = explode(':', trim($r)); |
62 | 62 | $rule = $params[0]; |
63 | - $params = isset($params[1])?explode(',', $params[1]):[]; |
|
63 | + $params = isset($params[1]) ?explode(',', $params[1]) : []; |
|
64 | 64 | |
65 | 65 | call_user_func_array([$this, 'parent::rule'], array_merge([$rule, $fields], $params)); |
66 | 66 |