@@ -8,7 +8,6 @@ discard block |
||
8 | 8 | use PhpBoot\Docgen\Swagger\Schemas\ArraySchemaObject; |
9 | 9 | use PhpBoot\Docgen\Swagger\Schemas\BodyParameterObject; |
10 | 10 | use PhpBoot\Docgen\Swagger\Schemas\OperationObject; |
11 | -use PhpBoot\Docgen\Swagger\Schemas\OtherParameterObject; |
|
12 | 11 | use PhpBoot\Docgen\Swagger\Schemas\PrimitiveSchemaObject; |
13 | 12 | use PhpBoot\Docgen\Swagger\Schemas\RefSchemaObject; |
14 | 13 | use PhpBoot\Docgen\Swagger\Schemas\ResponseObject; |
@@ -22,7 +21,6 @@ discard block |
||
22 | 21 | use PhpBoot\Metas\ParamMeta; |
23 | 22 | use PhpBoot\Metas\ReturnMeta; |
24 | 23 | use PhpBoot\Utils\ArrayHelper; |
25 | -use PhpBoot\Validator\Validator; |
|
26 | 24 | use Symfony\Component\HttpKernel\Exception\HttpException; |
27 | 25 | |
28 | 26 | class Swagger extends SwaggerObject |
@@ -234,10 +234,10 @@ discard block |
||
234 | 234 | * @return RefSchemaObject |
235 | 235 | */ |
236 | 236 | public function makeTempSchema(Application $app, |
237 | - ControllerContainer $controller, |
|
238 | - $action, |
|
239 | - Route $route, |
|
240 | - array $arr, $suffix) |
|
237 | + ControllerContainer $controller, |
|
238 | + $action, |
|
239 | + Route $route, |
|
240 | + array $arr, $suffix) |
|
241 | 241 | { |
242 | 242 | $className = self::getShortClassName($controller->getClassName()); |
243 | 243 | $name = $className . ucfirst($action) . $suffix; |
@@ -293,10 +293,10 @@ discard block |
||
293 | 293 | * @return RefSchemaObject |
294 | 294 | */ |
295 | 295 | public function getRefSchema(Application $app, |
296 | - ControllerContainer $controller, |
|
297 | - $action, |
|
298 | - Route $route, |
|
299 | - EntityContainer $container) |
|
296 | + ControllerContainer $controller, |
|
297 | + $action, |
|
298 | + Route $route, |
|
299 | + EntityContainer $container) |
|
300 | 300 | { |
301 | 301 | $name = $container->getClassName(); |
302 | 302 | if (!isset($this->definitions[$name])) { |
@@ -444,10 +444,10 @@ discard block |
||
444 | 444 | * @return ArraySchemaObject |
445 | 445 | */ |
446 | 446 | public function getArraySchema(Application $app, |
447 | - ControllerContainer $controller, |
|
448 | - $action, |
|
449 | - Route $route, |
|
450 | - ArrayContainer $container) |
|
447 | + ControllerContainer $controller, |
|
448 | + $action, |
|
449 | + Route $route, |
|
450 | + ArrayContainer $container) |
|
451 | 451 | { |
452 | 452 | $schema = new ArraySchemaObject(); |
453 | 453 | $itemContainer = $container->getContainer(); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
96 | - * @param $object |
|
96 | + * @param Swagger $object |
|
97 | 97 | * @return array |
98 | 98 | */ |
99 | 99 | static public function objectToArray($object) |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | /** |
119 | 119 | * @param Application $app |
120 | 120 | * @param ControllerContainer $controller |
121 | - * @param $action |
|
121 | + * @param integer $action |
|
122 | 122 | * @param Route $route |
123 | 123 | * @return array |
124 | 124 | */ |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | /** |
168 | 168 | * @param Application $app |
169 | 169 | * @param ControllerContainer $controller |
170 | - * @param $action |
|
170 | + * @param integer $action |
|
171 | 171 | * @param Route $route |
172 | 172 | * @return null|ResponseObject |
173 | 173 | */ |
@@ -305,6 +305,9 @@ discard block |
||
305 | 305 | return new RefSchemaObject("#/definitions/$name"); |
306 | 306 | } |
307 | 307 | |
308 | + /** |
|
309 | + * @param integer $action |
|
310 | + */ |
|
308 | 311 | public function getParamsSchema(Application $app, |
309 | 312 | ControllerContainer $controller, |
310 | 313 | $action, |
@@ -577,6 +580,9 @@ discard block |
||
577 | 580 | return $className; |
578 | 581 | } |
579 | 582 | |
583 | + /** |
|
584 | + * @param string $glue |
|
585 | + */ |
|
580 | 586 | static public function implode($glue , array $pieces ) |
581 | 587 | { |
582 | 588 | $pieces = array_filter($pieces, function($i){return trim($i) !== '';}); |
@@ -138,10 +138,10 @@ discard block |
||
138 | 138 | $ins = null; |
139 | 139 | try{ |
140 | 140 | $ins = $app->make($name); |
141 | - }catch (\Exception $e){ |
|
141 | + } catch (\Exception $e){ |
|
142 | 142 | try{ |
143 | 143 | $ins = new $name(""); |
144 | - }catch (\Exception $e){ |
|
144 | + } catch (\Exception $e){ |
|
145 | 145 | |
146 | 146 | } |
147 | 147 | } |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | { |
224 | 224 | if ($content instanceof ReturnMeta || $content instanceof ParamMeta) { |
225 | 225 | return $this->makeExample($content->container); |
226 | - }elseif ($content instanceof TypeContainerInterface){ |
|
226 | + } elseif ($content instanceof TypeContainerInterface){ |
|
227 | 227 | return $content->makeExample(); |
228 | - }elseif(is_array($content)) { |
|
228 | + } elseif(is_array($content)) { |
|
229 | 229 | $res = []; |
230 | 230 | foreach ($content as $k => $v) { |
231 | 231 | $res[$k] = $this->makeExample($v); |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | $paramSchema = new PrimitiveSchemaObject(); |
385 | 385 | if($isFile){ |
386 | 386 | $paramSchema->type = 'file'; |
387 | - }else{ |
|
387 | + } else{ |
|
388 | 388 | $paramSchema->type = self::mapType($param->type); |
389 | 389 | self::mapValidation($param->validation, $paramSchema); |
390 | 390 | } |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | } elseif($container == null){ |
443 | 443 | $schema = null ;//new PrimitiveSchemaObject(); |
444 | 444 | //$schema->type = null; |
445 | - }else { |
|
445 | + } else { |
|
446 | 446 | $schema = new PrimitiveSchemaObject(); |
447 | 447 | //$schema->type = 'mixed'; |
448 | 448 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $op->description = $route->getDescription(); |
59 | 59 | |
60 | 60 | $op->parameters = $this->getParamsSchema($app, $controller, $action, $route); |
61 | - if($this->hasFileParam($route)){ |
|
61 | + if ($this->hasFileParam($route)) { |
|
62 | 62 | $op->consumes = ['multipart/form-data']; |
63 | 63 | } |
64 | 64 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | } |
109 | 109 | if (is_array($v) || is_object($v)) { |
110 | 110 | $res[$k] = self::objectToArray($v); |
111 | - } else { |
|
111 | + }else { |
|
112 | 112 | $res[$k] = $v; |
113 | 113 | } |
114 | 114 | } |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | list($name, $desc) = $exception; |
137 | 137 | |
138 | 138 | $ins = null; |
139 | - try{ |
|
139 | + try { |
|
140 | 140 | $ins = $app->make($name); |
141 | - }catch (\Exception $e){ |
|
142 | - try{ |
|
141 | + }catch (\Exception $e) { |
|
142 | + try { |
|
143 | 143 | $ins = new $name(""); |
144 | - }catch (\Exception $e){ |
|
144 | + }catch (\Exception $e) { |
|
145 | 145 | |
146 | 146 | } |
147 | 147 | } |
@@ -149,21 +149,21 @@ discard block |
||
149 | 149 | //TODO status 重复怎么办 |
150 | 150 | if ($ins instanceof HttpException) { |
151 | 151 | $status = $ins->getStatusCode(); |
152 | - } else { |
|
152 | + }else { |
|
153 | 153 | $status = 500; |
154 | 154 | } |
155 | 155 | if (isset($schemas[$status])) { |
156 | 156 | //$this->warnings[] = "status response $status has been used for $name, $desc"; |
157 | 157 | $res = $schemas[$status]; |
158 | - } else { |
|
158 | + }else { |
|
159 | 159 | $res = new ResponseObject(); |
160 | 160 | } |
161 | 161 | $shortName = self::getShortClassName($name); |
162 | 162 | $desc = "$shortName: $desc"; |
163 | 163 | $res->description = self::implode("\n", [$res->description, $desc]); |
164 | - if($ins){ |
|
164 | + if ($ins) { |
|
165 | 165 | $error = $app->get(ExceptionRenderer::class)->render($ins)->getContent(); |
166 | - if($error){ |
|
166 | + if ($error) { |
|
167 | 167 | $res->examples = [$shortName => $error]; |
168 | 168 | } |
169 | 169 | } |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | { |
224 | 224 | if ($content instanceof ReturnMeta || $content instanceof ParamMeta) { |
225 | 225 | return $this->makeExample($content->container); |
226 | - }elseif ($content instanceof TypeContainerInterface){ |
|
226 | + }elseif ($content instanceof TypeContainerInterface) { |
|
227 | 227 | return $content->makeExample(); |
228 | - }elseif(is_array($content)) { |
|
228 | + }elseif (is_array($content)) { |
|
229 | 229 | $res = []; |
230 | 230 | foreach ($content as $k => $v) { |
231 | 231 | $res[$k] = $this->makeExample($v); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | array $arr, $suffix) |
251 | 251 | { |
252 | 252 | $className = self::getShortClassName($controller->getClassName()); |
253 | - $name = $className . ucfirst($action) . $suffix; |
|
253 | + $name = $className.ucfirst($action).$suffix; |
|
254 | 254 | |
255 | 255 | $schema = new SimpleModelSchemaObject(); |
256 | 256 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | $schema->properties[$k] = $this->makeTempSchema($app, $controller, $action, $route, $v, $suffix); |
260 | 260 | } elseif ($v instanceof ReturnMeta) { |
261 | 261 | $sub = $this->getAnySchema($app, $controller, $action, $route, $v->container); |
262 | - if($sub){ |
|
262 | + if ($sub) { |
|
263 | 263 | $sub->description = $v->description; |
264 | 264 | } |
265 | 265 | $schema->properties[$k] = $sub; |
@@ -270,13 +270,13 @@ discard block |
||
270 | 270 | } elseif ($v->container instanceof EntityContainer) { |
271 | 271 | $sub = $this->getRefSchema($app, $controller, $action, $route, $v->container); |
272 | 272 | //TODO array for validation |
273 | - } else { |
|
273 | + }else { |
|
274 | 274 | $sub = new PrimitiveSchemaObject(); |
275 | 275 | $sub->type = self::mapType($v->type); |
276 | 276 | self::mapValidation($v->validation, $sub); |
277 | 277 | unset($sub->required); |
278 | 278 | } |
279 | - if($sub){ |
|
279 | + if ($sub) { |
|
280 | 280 | $sub->description = $v->description; |
281 | 281 | $sub->default = $v->default; |
282 | 282 | } |
@@ -284,14 +284,14 @@ discard block |
||
284 | 284 | $schema->required[] = $k; |
285 | 285 | } |
286 | 286 | $schema->properties[$k] = $sub; |
287 | - } else { |
|
287 | + }else { |
|
288 | 288 | //TODO how to do? |
289 | 289 | } |
290 | 290 | } |
291 | 291 | $unused = $name; |
292 | 292 | $tempId = 0; |
293 | 293 | while (isset($this->definitions[$unused])) { |
294 | - $unused = $name . $tempId; |
|
294 | + $unused = $name.$tempId; |
|
295 | 295 | $tempId++; |
296 | 296 | } |
297 | 297 | $this->definitions[$unused] = $schema; |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | $in = 'query'; |
331 | 331 | |
332 | 332 | $bodyType = 'body'; // 当有文件上传时, 必须是formData方式 |
333 | - if($this->hasFileParam($route)){ |
|
333 | + if ($this->hasFileParam($route)) { |
|
334 | 334 | $bodyType = 'formData'; |
335 | 335 | } |
336 | 336 | |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | || $route->getMethod() == 'PATCH' |
370 | 370 | ) { |
371 | 371 | $in = $bodyType; |
372 | - } else { |
|
372 | + }else { |
|
373 | 373 | $in = 'query'; |
374 | 374 | } |
375 | 375 | } |
@@ -380,11 +380,11 @@ discard block |
||
380 | 380 | } elseif ($param->container instanceof EntityContainer) { |
381 | 381 | $paramSchema = $this->getRefSchema($app, $controller, $action, $route, $param->container); |
382 | 382 | //TODO array for validation |
383 | - } else { |
|
383 | + }else { |
|
384 | 384 | $paramSchema = new PrimitiveSchemaObject(); |
385 | - if($isFile){ |
|
385 | + if ($isFile) { |
|
386 | 386 | $paramSchema->type = 'file'; |
387 | - }else{ |
|
387 | + }else { |
|
388 | 388 | $paramSchema->type = self::mapType($param->type); |
389 | 389 | self::mapValidation($param->validation, $paramSchema); |
390 | 390 | } |
@@ -396,10 +396,10 @@ discard block |
||
396 | 396 | $paramSchema->default = $param->default; |
397 | 397 | $paramSchema->required = !$param->isOptional; |
398 | 398 | $parameters[] = $paramSchema; |
399 | - } else { |
|
399 | + }else { |
|
400 | 400 | if (!$name) { |
401 | 401 | $body = $param; |
402 | - } else { |
|
402 | + }else { |
|
403 | 403 | ArrayHelper::set($body, $name, $param); |
404 | 404 | } |
405 | 405 | |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | $paramSchema->in = 'body'; |
413 | 413 | if (is_array($body)) { |
414 | 414 | $paramSchema->schema = $this->makeTempSchema($app, $controller, $action, $route, $body, 'Req'); |
415 | - } else { |
|
415 | + }else { |
|
416 | 416 | $paramSchema->schema = $this->getAnySchema($app, $controller, $action, $route, $body->container); |
417 | 417 | } |
418 | 418 | |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | } elseif ($container instanceof ScalarTypeContainer) { |
440 | 440 | $schema = new PrimitiveSchemaObject(); |
441 | 441 | $schema->type = self::mapType($container->getType()); |
442 | - } elseif($container == null){ |
|
443 | - $schema = null ;//new PrimitiveSchemaObject(); |
|
442 | + } elseif ($container == null) { |
|
443 | + $schema = null; //new PrimitiveSchemaObject(); |
|
444 | 444 | //$schema->type = null; |
445 | 445 | }else { |
446 | 446 | $schema = new PrimitiveSchemaObject(); |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | } elseif ($itemContainer instanceof ScalarTypeContainer) { |
473 | 473 | $itemSchema = new PrimitiveSchemaObject(); |
474 | 474 | $itemSchema->type = self::mapType($itemContainer->getType()); |
475 | - } else { |
|
475 | + }else { |
|
476 | 476 | $itemSchema = new PrimitiveSchemaObject(); |
477 | 477 | //$itemSchema->type = 'mixed'; |
478 | 478 | } |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | $propertySchema = $this->getRefSchema($app, $controller, $action, $route, $property->container); |
499 | 499 | } elseif ($property->container instanceof ArrayContainer) { |
500 | 500 | $propertySchema = $this->getArraySchema($app, $controller, $action, $route, $property->container); |
501 | - } else { |
|
501 | + }else { |
|
502 | 502 | $propertySchema = new PrimitiveSchemaObject(); |
503 | 503 | $propertySchema->type = self::mapType($property->type); |
504 | 504 | $propertySchema->description = self::implode("\n", [$property->summary, $property->description]); |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | { |
516 | 516 | $params = $route->getRequestHandler()->getParamMetas(); |
517 | 517 | foreach ($params as $name => $param) { |
518 | - if(strpos($param->source, 'request.files.')===0){ |
|
518 | + if (strpos($param->source, 'request.files.') === 0) { |
|
519 | 519 | return true; |
520 | 520 | } |
521 | 521 | } |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | */ |
529 | 529 | static public function mapValidation($v, PrimitiveSchemaObject $schemaObject) |
530 | 530 | { |
531 | - if(!$v){ |
|
531 | + if (!$v) { |
|
532 | 532 | return $schemaObject; |
533 | 533 | } |
534 | 534 | $rules = explode('|', $v); |
@@ -544,15 +544,15 @@ discard block |
||
544 | 544 | } elseif ($rule == 'lengthBetween' && isset($params[0]) && isset($params[1])) { |
545 | 545 | $schemaObject->minLength = intval($params[0]); |
546 | 546 | $schemaObject->maxLength = intval($params[1]); |
547 | - } elseif ($rule == 'lengthMin'&& isset($params[0])) { |
|
547 | + } elseif ($rule == 'lengthMin' && isset($params[0])) { |
|
548 | 548 | $schemaObject->minLength = intval($params[0]); |
549 | - } elseif ($rule == 'lengthMax'&& isset($params[0])) { |
|
549 | + } elseif ($rule == 'lengthMax' && isset($params[0])) { |
|
550 | 550 | $schemaObject->maxLength = intval($params[0]); |
551 | - } elseif ($rule == 'min'&& isset($params[0])) { |
|
551 | + } elseif ($rule == 'min' && isset($params[0])) { |
|
552 | 552 | $schemaObject->minimum = floatval($params[0]); |
553 | - } elseif ($rule == 'max'&& isset($params[0])) { |
|
553 | + } elseif ($rule == 'max' && isset($params[0])) { |
|
554 | 554 | $schemaObject->maximum = floatval($params[0]); |
555 | - } elseif ($rule == 'regex'&& isset($params[0])) { |
|
555 | + } elseif ($rule == 'regex' && isset($params[0])) { |
|
556 | 556 | $schemaObject->pattern = $params[0]; |
557 | 557 | } elseif ($rule == 'optional') { |
558 | 558 | $schemaObject->required = false; |
@@ -591,9 +591,9 @@ discard block |
||
591 | 591 | return $className; |
592 | 592 | } |
593 | 593 | |
594 | - static public function implode($glue , array $pieces ) |
|
594 | + static public function implode($glue, array $pieces) |
|
595 | 595 | { |
596 | - $pieces = array_filter($pieces, function($i){return trim($i) !== '';}); |
|
596 | + $pieces = array_filter($pieces, function($i) {return trim($i) !== ''; }); |
|
597 | 597 | return implode($glue, $pieces); |
598 | 598 | } |
599 | 599 | } |
600 | 600 | \ No newline at end of file |
@@ -15,19 +15,19 @@ |
||
15 | 15 | { |
16 | 16 | $response = new Response(); |
17 | 17 | $response->headers->set('Content-Type', 'application/json'); |
18 | - foreach ($output as $key=>$value){ |
|
18 | + foreach ($output as $key=>$value) { |
|
19 | 19 | //TODO 支持自定义格式输出 |
20 | 20 | //TODO 支持更多的输出目标 |
21 | - if($key == 'content'){ |
|
21 | + if ($key == 'content') { |
|
22 | 22 | //if(is_array($value) || is_object($value)){ |
23 | 23 | $value = json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
24 | 24 | //} |
25 | 25 | $response->setContent($value); |
26 | - }elseif($key == 'headers'){ |
|
27 | - foreach ($value as $k=>$v){ |
|
26 | + }elseif ($key == 'headers') { |
|
27 | + foreach ($value as $k=>$v) { |
|
28 | 28 | $response->headers->set($k, $v); |
29 | 29 | } |
30 | - }else{ |
|
30 | + }else { |
|
31 | 31 | \PhpBoot\abort(new \UnexpectedValueException("Unexpected output target $key")); |
32 | 32 | } |
33 | 33 |
@@ -23,11 +23,11 @@ |
||
23 | 23 | $value = json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
24 | 24 | //} |
25 | 25 | $response->setContent($value); |
26 | - }elseif($key == 'headers'){ |
|
26 | + } elseif($key == 'headers'){ |
|
27 | 27 | foreach ($value as $k=>$v){ |
28 | 28 | $response->headers->set($k, $v); |
29 | 29 | } |
30 | - }else{ |
|
30 | + } else{ |
|
31 | 31 | \PhpBoot\abort(new \UnexpectedValueException("Unexpected output target $key")); |
32 | 32 | } |
33 | 33 |
@@ -41,6 +41,9 @@ discard block |
||
41 | 41 | |
42 | 42 | class OnDuplicateKeyUpdateRule extends ExecRule |
43 | 43 | { |
44 | + /** |
|
45 | + * @param \PhpBoot\DB\Context $context |
|
46 | + */ |
|
44 | 47 | public function __construct($context) |
45 | 48 | { |
46 | 49 | parent::__construct($context); |
@@ -91,8 +94,6 @@ discard block |
||
91 | 94 | * ->onDuplicateKeyUpdate('a=a+1') |
92 | 95 | * => "INSERT INTO table(a,b) VALUES(1,now()) ON DUPLICATE KEY UPDATE a=a+1" |
93 | 96 | * |
94 | - * @param string $column |
|
95 | - * @param mixed $value |
|
96 | 97 | * @return \PhpBoot\DB\rules\basic\ExecRule |
97 | 98 | */ |
98 | 99 | public function onDuplicateKeyUpdate($expr, $_=null) { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param array $values |
45 | 45 | * @return \PhpBoot\DB\rules\insert\OnDuplicateKeyUpdateRule |
46 | 46 | */ |
47 | - public function batchValues(array $values){ |
|
47 | + public function batchValues(array $values) { |
|
48 | 48 | ValuesImpl::batchValues($this->context, $values); |
49 | 49 | return new OnDuplicateKeyUpdateRule($this->context); |
50 | 50 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param mixed $value |
107 | 107 | * @return \PhpBoot\DB\rules\basic\ExecRule |
108 | 108 | */ |
109 | - public function onDuplicateKeyUpdate($expr, $_=null) { |
|
109 | + public function onDuplicateKeyUpdate($expr, $_ = null) { |
|
110 | 110 | $this->impl->set($this->context, $expr, array_slice(func_get_args(), 1)); |
111 | 111 | return new ExecRule($this->context); |
112 | 112 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function eraseMapping($target) |
29 | 29 | { |
30 | - if(!isset($this->mappings[$target])){ |
|
30 | + if (!isset($this->mappings[$target])) { |
|
31 | 31 | return null; |
32 | 32 | } |
33 | 33 | $ori = $this->mappings[$target]; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function getMapping($target) |
43 | 43 | { |
44 | - if(!array_key_exists($target, $this->mappings)){ |
|
44 | + if (!array_key_exists($target, $this->mappings)) { |
|
45 | 45 | return null; |
46 | 46 | } |
47 | 47 | return $this->mappings[$target]; |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function getMappingBySource($source) |
55 | 55 | { |
56 | - foreach ($this->mappings as $k=>$v){ |
|
57 | - if($v->source == $source){ |
|
56 | + foreach ($this->mappings as $k=>$v) { |
|
57 | + if ($v->source == $source) { |
|
58 | 58 | return [$k, $v]; |
59 | 59 | } |
60 | 60 | } |
61 | - return [null,null]; |
|
61 | + return [null, null]; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
@@ -75,15 +75,15 @@ discard block |
||
75 | 75 | 'params'=>$params |
76 | 76 | ]; |
77 | 77 | |
78 | - if($return instanceof Response){ //直接返回Response时, 对return不再做映射 |
|
78 | + if ($return instanceof Response) { //直接返回Response时, 对return不再做映射 |
|
79 | 79 | return $return; |
80 | 80 | } |
81 | 81 | $mappings = $this->getMappings(); |
82 | 82 | |
83 | 83 | $output = []; |
84 | - foreach($mappings as $key=>$map){ |
|
84 | + foreach ($mappings as $key=>$map) { |
|
85 | 85 | $val = \JmesPath\search($map->source, $input); |
86 | - if(substr($key, 0, strlen('response.')) == 'response.'){ |
|
86 | + if (substr($key, 0, strlen('response.')) == 'response.') { |
|
87 | 87 | $key = substr($key, strlen('response.')); |
88 | 88 | } |
89 | 89 | ArrayHelper::set($output, $key, $val); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | 'DELETE' |
44 | 44 | ]) or \PhpBoot\abort(new AnnotationSyntaxException("unknown method http $httpMethod in {$container->getClassName()}::$target")); |
45 | 45 | //获取方法参数信息 |
46 | - $rfl = new \ReflectionClass($container->getClassName()); |
|
46 | + $rfl = new \ReflectionClass($container->getClassName()); |
|
47 | 47 | $method = $rfl->getMethod($target); |
48 | 48 | $methodParams = $method->getParameters(); |
49 | 49 | |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | $routeParser = new Std(); |
69 | 69 | $uri = $params->getParam(1); |
70 | 70 | $info = $routeParser->parse($uri); //0.4和1.0返回值不同, 不兼容 |
71 | - if(isset($info[0])){ |
|
72 | - foreach ($info[0] as $i){ |
|
73 | - if(is_array($i)) { |
|
71 | + if (isset($info[0])) { |
|
72 | + foreach ($info[0] as $i) { |
|
73 | + if (is_array($i)) { |
|
74 | 74 | $route->addPathParam($i[0]); |
75 | 75 | } |
76 | 76 | } |
@@ -79,31 +79,31 @@ discard block |
||
79 | 79 | $hasRefParam = false; |
80 | 80 | //设置参数列表 |
81 | 81 | $paramsMeta = []; |
82 | - foreach ($methodParams as $param){ |
|
82 | + foreach ($methodParams as $param) { |
|
83 | 83 | $paramName = $param->getName(); |
84 | 84 | $source = "request.$paramName"; |
85 | - if($route->hasPathParam($paramName)){ //参数来自路由 |
|
85 | + if ($route->hasPathParam($paramName)) { //参数来自路由 |
|
86 | 86 | $source = "request.$paramName"; |
87 | - }elseif($httpMethod == 'GET'){ |
|
87 | + }elseif ($httpMethod == 'GET') { |
|
88 | 88 | $source = "request.$paramName"; //GET请求显示指定来自query string |
89 | 89 | } |
90 | 90 | $paramClass = $param->getClass(); |
91 | - if($paramClass){ |
|
91 | + if ($paramClass) { |
|
92 | 92 | $paramClass = $paramClass->getName(); |
93 | 93 | } |
94 | 94 | $entityContainer = ContainerFactory::create($entityBuilder, $paramClass); |
95 | 95 | $meta = new ParamMeta($paramName, |
96 | 96 | $source, |
97 | - $paramClass?:'mixed', |
|
97 | + $paramClass ?: 'mixed', |
|
98 | 98 | $param->isOptional(), |
99 | - $param->isOptional()?$param->getDefaultValue():null, |
|
99 | + $param->isOptional() ? $param->getDefaultValue() : null, |
|
100 | 100 | $param->isPassedByReference(), |
101 | 101 | null, |
102 | 102 | '', |
103 | 103 | $entityContainer |
104 | 104 | ); |
105 | 105 | $paramsMeta[] = $meta; |
106 | - if($meta->isPassedByReference){ |
|
106 | + if ($meta->isPassedByReference) { |
|
107 | 107 | $hasRefParam = true; |
108 | 108 | $responseHandler->setMapping('response.content.'.$meta->name, new ReturnMeta( |
109 | 109 | 'params.'.$meta->name, |
@@ -114,16 +114,16 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | $requestHandler->setParamMetas($paramsMeta); |
117 | - if(!$hasRefParam){ |
|
118 | - $responseHandler->setMapping('response.content', new ReturnMeta('return','mixed','', new MixedTypeContainer())); |
|
119 | - }else{ |
|
117 | + if (!$hasRefParam) { |
|
118 | + $responseHandler->setMapping('response.content', new ReturnMeta('return', 'mixed', '', new MixedTypeContainer())); |
|
119 | + }else { |
|
120 | 120 | //当存在引用参数作为输出时, 默认将 return 数据绑定的到 data 下, 以防止和引用参数作为输出重叠 |
121 | - $responseHandler->setMapping($this->returnTarget, new ReturnMeta('return','mixed','', new MixedTypeContainer())); |
|
121 | + $responseHandler->setMapping($this->returnTarget, new ReturnMeta('return', 'mixed', '', new MixedTypeContainer())); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | |
125 | 125 | $container->addRoute($target, $route); |
126 | 126 | } |
127 | 127 | |
128 | - public $returnTarget='response.content.data'; |
|
128 | + public $returnTarget = 'response.content.data'; |
|
129 | 129 | } |
130 | 130 | \ No newline at end of file |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $source = "request.$paramName"; |
85 | 85 | if($route->hasPathParam($paramName)){ //参数来自路由 |
86 | 86 | $source = "request.$paramName"; |
87 | - }elseif($httpMethod == 'GET'){ |
|
87 | + } elseif($httpMethod == 'GET'){ |
|
88 | 88 | $source = "request.$paramName"; //GET请求显示指定来自query string |
89 | 89 | } |
90 | 90 | $paramClass = $param->getClass(); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $requestHandler->setParamMetas($paramsMeta); |
117 | 117 | if(!$hasRefParam){ |
118 | 118 | $responseHandler->setMapping('response.content', new ReturnMeta('return','mixed','', new MixedTypeContainer())); |
119 | - }else{ |
|
119 | + } else{ |
|
120 | 120 | //当存在引用参数作为输出时, 默认将 return 数据绑定的到 data 下, 以防止和引用参数作为输出重叠 |
121 | 121 | $responseHandler->setMapping($this->returnTarget, new ReturnMeta('return','mixed','', new MixedTypeContainer())); |
122 | 122 | } |
@@ -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 NextWhereRule |
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 NextWhereRule($this->context, false); |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | * @param mixed $_ |
134 | 134 | * @return WhereRule |
135 | 135 | */ |
136 | - public function orWhere($conditions=null, $_=null) { |
|
137 | - if(is_callable($conditions)){ |
|
138 | - $callback = function ($context)use($conditions){ |
|
136 | + public function orWhere($conditions = null, $_ = null) { |
|
137 | + if (is_callable($conditions)) { |
|
138 | + $callback = function($context)use($conditions){ |
|
139 | 139 | $rule = new ScopedQuery($context); |
140 | 140 | $conditions($rule); |
141 | 141 | }; |
@@ -160,17 +160,17 @@ discard block |
||
160 | 160 | * @param null $_ |
161 | 161 | * @return NextScopedQuery |
162 | 162 | */ |
163 | - public function where($expr, $_= null){ |
|
164 | - if(is_callable($expr)){ |
|
165 | - $callback = function ($context)use($expr){ |
|
163 | + public function where($expr, $_ = null) { |
|
164 | + if (is_callable($expr)) { |
|
165 | + $callback = function($context)use($expr){ |
|
166 | 166 | $rule = new ScopedQuery($context, true); |
167 | 167 | $expr($rule); |
168 | 168 | }; |
169 | 169 | $expr = $callback; |
170 | 170 | } |
171 | - if($this->isTheFirst){ |
|
171 | + if ($this->isTheFirst) { |
|
172 | 172 | WhereImpl::where($this->context, '', $expr, array_slice(func_get_args(), 1)); |
173 | - }else{ |
|
173 | + }else { |
|
174 | 174 | WhereImpl::where($this->context, 'AND', $expr, array_slice(func_get_args(), 1)); |
175 | 175 | } |
176 | 176 | return new NextScopedQuery($this->context, false); |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | * @param null $_ |
187 | 187 | * @return ScopedQuery |
188 | 188 | */ |
189 | - public function orWhere($expr, $_= null){ |
|
190 | - if(is_callable($expr)){ |
|
191 | - $callback = function ($context)use($expr){ |
|
189 | + public function orWhere($expr, $_ = null) { |
|
190 | + if (is_callable($expr)) { |
|
191 | + $callback = function($context)use($expr){ |
|
192 | 192 | $rule = new ScopedQuery($context, true); |
193 | 193 | $expr($rule); |
194 | 194 | }; |
@@ -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 NextWhereRule($this->context, false); |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | } |
171 | 171 | if($this->isTheFirst){ |
172 | 172 | WhereImpl::where($this->context, '', $expr, array_slice(func_get_args(), 1)); |
173 | - }else{ |
|
173 | + } else{ |
|
174 | 174 | WhereImpl::where($this->context, 'AND', $expr, array_slice(func_get_args(), 1)); |
175 | 175 | } |
176 | 176 | return new NextScopedQuery($this->context, false); |
@@ -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 $_ |
@@ -25,6 +25,9 @@ |
||
25 | 25 | |
26 | 26 | class UpdateSetRule extends BasicRule |
27 | 27 | { |
28 | + /** |
|
29 | + * @param Context $context |
|
30 | + */ |
|
28 | 31 | public function __construct($context){ |
29 | 32 | parent::__construct($context); |
30 | 33 | $this->impl = new UpdateSetImpl(); |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | class UpdateSetRule extends BasicRule |
27 | 27 | { |
28 | - public function __construct($context){ |
|
28 | + public function __construct($context) { |
|
29 | 29 | parent::__construct($context); |
30 | 30 | $this->impl = new UpdateSetImpl(); |
31 | 31 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param mixed $_ |
38 | 38 | * @return UpdateSetWhereRule |
39 | 39 | */ |
40 | - public function set($expr, $_=null) { |
|
40 | + public function set($expr, $_ = null) { |
|
41 | 41 | $this->impl->set($this->context, $expr, array_slice(func_get_args(), 1)); |
42 | 42 | return new UpdateSetWhereRule($this->context, $this->impl); |
43 | 43 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | class UpdateSetWhereRule extends WhereRule |
48 | 48 | { |
49 | - public function __construct(Context $context, UpdateSetImpl $impl){ |
|
49 | + public function __construct(Context $context, UpdateSetImpl $impl) { |
|
50 | 50 | parent::__construct($context); |
51 | 51 | $this->impl = $impl; |
52 | 52 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param mixed $_ |
58 | 58 | * @return UpdateSetWhereRule |
59 | 59 | */ |
60 | - public function set($expr, $_=null) { |
|
60 | + public function set($expr, $_ = null) { |
|
61 | 61 | $this->impl->set($this->context, $expr, array_slice(func_get_args(), 1)); |
62 | 62 | return new UpdateSetWhereRule($this->context, $this->impl); |
63 | 63 | } |
@@ -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 |
@@ -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\NextWhereRule |
265 | 268 | */ |
266 | 269 | public function where($conditions=null, $_=null) { |
@@ -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\NextWhereRule |
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 NextWhereRule($this->context, false); |
@@ -304,9 +304,9 @@ discard block |
||
304 | 304 | * |
305 | 305 | * @TODO orWhere 只能跟在 Where 后 |
306 | 306 | */ |
307 | - public function orWhere($conditions=null, $_=null) { |
|
308 | - if(is_callable($conditions)){ |
|
309 | - $callback = function ($context)use($conditions){ |
|
307 | + public function orWhere($conditions = null, $_ = null) { |
|
308 | + if (is_callable($conditions)) { |
|
309 | + $callback = function($context)use($conditions){ |
|
310 | 310 | $rule = new ScopedQuery($context); |
311 | 311 | $conditions($rule); |
312 | 312 | }; |
@@ -325,8 +325,8 @@ discard block |
||
325 | 325 | * @param string $table |
326 | 326 | * @return \PhpBoot\DB\rules\select\JoinOnRule |
327 | 327 | */ |
328 | - public function join($table){ |
|
329 | - JoinImpl::join($this->context,null, $table); |
|
328 | + public function join($table) { |
|
329 | + JoinImpl::join($this->context, null, $table); |
|
330 | 330 | return new JoinOnRule($this->context); |
331 | 331 | } |
332 | 332 | /** |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | * @param string $table |
335 | 335 | * @return \PhpBoot\DB\rules\select\JoinOnRule |
336 | 336 | */ |
337 | - public function leftJoin($table){ |
|
338 | - JoinImpl::join($this->context,'LEFT', $table); |
|
337 | + public function leftJoin($table) { |
|
338 | + JoinImpl::join($this->context, 'LEFT', $table); |
|
339 | 339 | return new JoinOnRule($this->context); |
340 | 340 | } |
341 | 341 | /** |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @return \PhpBoot\DB\rules\select\JoinOnRule |
345 | 345 | */ |
346 | 346 | public function rightJoin($table) { |
347 | - JoinImpl::join($this->context,'RIGHT', $table); |
|
347 | + JoinImpl::join($this->context, 'RIGHT', $table); |
|
348 | 348 | return new JoinOnRule($this->context); |
349 | 349 | } |
350 | 350 | /** |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * @return \PhpBoot\DB\rules\select\JoinOnRule |
354 | 354 | */ |
355 | 355 | public function innerJoin($table) { |
356 | - JoinImpl::join($this->context,'INNER', $table); |
|
356 | + JoinImpl::join($this->context, 'INNER', $table); |
|
357 | 357 | return new JoinOnRule($this->context); |
358 | 358 | } |
359 | 359 | } |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | * @param string $condition |
366 | 366 | * @return \PhpBoot\DB\rules\select\JoinRule |
367 | 367 | */ |
368 | - public function on($condition){ |
|
368 | + public function on($condition) { |
|
369 | 369 | JoinOnImpl::on($this->context, $condition); |
370 | 370 | return new JoinRule($this->context); |
371 | 371 | } |
@@ -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 NextWhereRule($this->context, false); |