@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function __invoke(ControllerContainer $container, $ann, EntityContainerBuilder $entityBuilder) |
23 | 23 | { |
24 | - if(!$ann->parent || !$ann->parent->parent){ |
|
24 | + if (!$ann->parent || !$ann->parent->parent) { |
|
25 | 25 | Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()} should be used with parent param/return"); |
26 | 26 | return; |
27 | 27 | } |
28 | 28 | $target = $ann->parent->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 param/return"); |
32 | - return ; |
|
32 | + return; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | $params = new AnnotationParams($ann->description, 2); |
@@ -38,20 +38,20 @@ discard block |
||
38 | 38 | |
39 | 39 | $handler = $route->getResponseHandler(); |
40 | 40 | |
41 | - if ($ann->parent->name == 'return'){ |
|
41 | + if ($ann->parent->name == 'return') { |
|
42 | 42 | list($target, $return) = $handler->getMappingBySource('return'); |
43 | - if($return){ |
|
43 | + if ($return) { |
|
44 | 44 | $handler->eraseMapping($target); |
45 | 45 | $handler->setMapping($params[0], $return); |
46 | 46 | } |
47 | 47 | |
48 | - }elseif($ann->parent->name == 'param'){ |
|
48 | + }elseif ($ann->parent->name == 'param') { |
|
49 | 49 | list($paramType, $paramName, $paramDoc) = ParamAnnotationHandler::getParamInfo($ann->parent->description); |
50 | 50 | |
51 | 51 | $paramMeta = $route->getRequestHandler()->getParamMeta($paramName); |
52 | - if($paramMeta->isPassedByReference){ |
|
52 | + if ($paramMeta->isPassedByReference) { |
|
53 | 53 | list($target, $ori) = $handler->getMappingBySource('params.'.$paramName); |
54 | - if($ori){ |
|
54 | + if ($ori) { |
|
55 | 55 | $handler->eraseMapping($target); |
56 | 56 | } |
57 | 57 | //输出绑定 |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | ContainerFactory::create($entityBuilder, $paramMeta->type) |
64 | 64 | ) |
65 | 65 | ); |
66 | - }else{ |
|
66 | + }else { |
|
67 | 67 | $paramMeta->source = $params[0]; |
68 | 68 | } |
69 | 69 | } |
@@ -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 |
@@ -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\OrderByRule |
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\GroupByRule |
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\OrderByRule |
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; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @author caoym <[email protected]> |
58 | 58 | */ |
59 | -class DB{ |
|
59 | +class DB { |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * DB constructor. |
@@ -97,18 +97,18 @@ discard block |
||
97 | 97 | * @param string $column0 |
98 | 98 | * @return \PhpBoot\DB\rules\select\FromRule |
99 | 99 | */ |
100 | - function select($column0=null, $_=null){ |
|
100 | + function select($column0 = null, $_ = null) { |
|
101 | 101 | $obj = new SelectRule(new Context($this->connection)); |
102 | - if($column0 == null){ |
|
102 | + if ($column0 == null) { |
|
103 | 103 | $args = ['*']; |
104 | - }elseif(is_array($column0)){ |
|
104 | + }elseif (is_array($column0)) { |
|
105 | 105 | $args = $column0; |
106 | - }else{ |
|
106 | + }else { |
|
107 | 107 | $args = func_get_args(); |
108 | 108 | } |
109 | - foreach ($args as &$arg){ |
|
109 | + foreach ($args as &$arg) { |
|
110 | 110 | $arg = DB::wrap($arg); |
111 | - if($arg == '*'){ |
|
111 | + if ($arg == '*') { |
|
112 | 112 | continue; |
113 | 113 | } |
114 | 114 | |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | * @param string $table |
141 | 141 | * @return \PhpBoot\DB\rules\basic\WhereRule |
142 | 142 | */ |
143 | - public function deleteFrom($table){ |
|
144 | - $obj = new DeleteRule(new Context($this->connection)); |
|
143 | + public function deleteFrom($table) { |
|
144 | + $obj = new DeleteRule(new Context($this->connection)); |
|
145 | 145 | return $obj->deleteFrom($table); |
146 | 146 | } |
147 | 147 | /** |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | * @param string $table |
150 | 150 | * @return \PhpBoot\DB\rules\replace\ValuesRule |
151 | 151 | */ |
152 | - public function replaceInto($table){ |
|
153 | - $obj = new ReplaceIntoRule(new Context($this->connection)); |
|
152 | + public function replaceInto($table) { |
|
153 | + $obj = new ReplaceIntoRule(new Context($this->connection)); |
|
154 | 154 | return $obj->replaceInto($table); |
155 | 155 | } |
156 | 156 | |
@@ -161,16 +161,16 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function transaction(callable $callback) |
163 | 163 | { |
164 | - if($this->inTransaction){ |
|
164 | + if ($this->inTransaction) { |
|
165 | 165 | return $callback($this); |
166 | 166 | } |
167 | 167 | $this->getConnection()->beginTransaction() or \PhpBoot\abort('beginTransaction failed'); |
168 | 168 | $this->inTransaction = true; |
169 | - try{ |
|
169 | + try { |
|
170 | 170 | $res = $callback($this); |
171 | 171 | $this->getConnection()->commit() or \PhpBoot\abort('commit failed'); |
172 | 172 | return $res; |
173 | - }catch (\Exception $e){ |
|
173 | + }catch (\Exception $e) { |
|
174 | 174 | $this->getConnection()->rollBack(); |
175 | 175 | Logger::warning('commit failed with '.get_class($e).' '.$e->getMessage()); |
176 | 176 | throw $e; |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @param string $str |
192 | 192 | * @return Raw |
193 | 193 | */ |
194 | - static public function raw($str){ |
|
194 | + static public function raw($str) { |
|
195 | 195 | return new Raw($str); |
196 | 196 | } |
197 | 197 | static public function wrap($value) |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | if ($value === '*') { |
200 | 200 | return $value; |
201 | 201 | } |
202 | - if($value instanceof Raw){ |
|
202 | + if ($value instanceof Raw) { |
|
203 | 203 | return $value->get(); |
204 | 204 | } |
205 | 205 | return '`'.str_replace('`', '``', $value).'`'; |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | { |
213 | 213 | return $this->app; |
214 | 214 | } |
215 | - const ORDER_BY_ASC ='ASC'; |
|
216 | - const ORDER_BY_DESC ='DESC'; |
|
215 | + const ORDER_BY_ASC = 'ASC'; |
|
216 | + const ORDER_BY_DESC = 'DESC'; |
|
217 | 217 | |
218 | 218 | /** |
219 | 219 | * @var \PDO |
@@ -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 | } |
@@ -140,21 +140,21 @@ discard block |
||
140 | 140 | //TODO status 重复怎么办 |
141 | 141 | if ($ins instanceof HttpException) { |
142 | 142 | $status = $ins->getStatusCode(); |
143 | - } else { |
|
143 | + }else { |
|
144 | 144 | |
145 | 145 | $status = 500; |
146 | 146 | } |
147 | 147 | if (isset($schemas[$status])) { |
148 | 148 | //$this->warnings[] = "status response $status has been used for $name, $desc"; |
149 | 149 | $res = $schemas[$status]; |
150 | - } else { |
|
150 | + }else { |
|
151 | 151 | $res = new ResponseObject(); |
152 | 152 | } |
153 | 153 | $shortName = self::getShortClassName($name); |
154 | 154 | $desc = "$shortName: $desc"; |
155 | 155 | $res->description = self::implode("\n", [$res->description, $desc]); |
156 | 156 | $error = $app->get(ExceptionRenderer::class)->render($ins)->getContent(); |
157 | - if($error){ |
|
157 | + if ($error) { |
|
158 | 158 | $res->examples = [$shortName => $error]; |
159 | 159 | } |
160 | 160 | //$res->schema = new RefSchemaObject("#/definitions/$name"); |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | { |
214 | 214 | if ($content instanceof ReturnMeta || $content instanceof ParamMeta) { |
215 | 215 | return $this->makeExample($content->container); |
216 | - }elseif ($content instanceof TypeContainerInterface){ |
|
216 | + }elseif ($content instanceof TypeContainerInterface) { |
|
217 | 217 | return $content->makeExample(); |
218 | - }elseif(is_array($content)) { |
|
218 | + }elseif (is_array($content)) { |
|
219 | 219 | $res = []; |
220 | 220 | foreach ($content as $k => $v) { |
221 | 221 | $res[$k] = $this->makeExample($v); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | array $arr, $suffix) |
241 | 241 | { |
242 | 242 | $className = self::getShortClassName($controller->getClassName()); |
243 | - $name = $className . ucfirst($action) . $suffix; |
|
243 | + $name = $className.ucfirst($action).$suffix; |
|
244 | 244 | |
245 | 245 | $schema = new SimpleModelSchemaObject(); |
246 | 246 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | } elseif ($v->container instanceof EntityContainer) { |
259 | 259 | $sub = $this->getRefSchema($app, $controller, $action, $route, $v->container); |
260 | 260 | //TODO array for validation |
261 | - } else { |
|
261 | + }else { |
|
262 | 262 | $sub = new PrimitiveSchemaObject(); |
263 | 263 | $sub->type = self::mapType($v->type); |
264 | 264 | self::mapValidation($v->validation, $sub); |
@@ -270,14 +270,14 @@ discard block |
||
270 | 270 | $schema->required[] = $k; |
271 | 271 | } |
272 | 272 | $schema->properties[$k] = $sub; |
273 | - } else { |
|
273 | + }else { |
|
274 | 274 | //TODO how to do? |
275 | 275 | } |
276 | 276 | } |
277 | 277 | $unused = $name; |
278 | 278 | $tempId = 0; |
279 | 279 | while (isset($this->definitions[$unused])) { |
280 | - $unused = $name . $tempId; |
|
280 | + $unused = $name.$tempId; |
|
281 | 281 | $tempId++; |
282 | 282 | } |
283 | 283 | $this->definitions[$unused] = $schema; |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | $in = 'query'; |
317 | 317 | |
318 | 318 | $bodyType = 'body'; // 当有文件上传时, 必须是formData方式 |
319 | - if($this->hasFileParam($route)){ |
|
319 | + if ($this->hasFileParam($route)) { |
|
320 | 320 | $bodyType = 'formData'; |
321 | 321 | } |
322 | 322 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | || $route->getMethod() == 'PATCH' |
356 | 356 | ) { |
357 | 357 | $in = $bodyType; |
358 | - } else { |
|
358 | + }else { |
|
359 | 359 | $in = 'query'; |
360 | 360 | } |
361 | 361 | } |
@@ -366,11 +366,11 @@ discard block |
||
366 | 366 | } elseif ($param->container instanceof EntityContainer) { |
367 | 367 | $paramSchema = $this->getRefSchema($app, $controller, $action, $route, $param->container); |
368 | 368 | //TODO array for validation |
369 | - } else { |
|
369 | + }else { |
|
370 | 370 | $paramSchema = new PrimitiveSchemaObject(); |
371 | - if($isFile){ |
|
371 | + if ($isFile) { |
|
372 | 372 | $paramSchema->type = 'file'; |
373 | - }else{ |
|
373 | + }else { |
|
374 | 374 | $paramSchema->type = self::mapType($param->type); |
375 | 375 | self::mapValidation($param->validation, $paramSchema); |
376 | 376 | } |
@@ -382,10 +382,10 @@ discard block |
||
382 | 382 | $paramSchema->default = $param->default; |
383 | 383 | $paramSchema->required = !$param->isOptional; |
384 | 384 | $parameters[] = $paramSchema; |
385 | - } else { |
|
385 | + }else { |
|
386 | 386 | if (!$name) { |
387 | 387 | $body = $param; |
388 | - } else { |
|
388 | + }else { |
|
389 | 389 | ArrayHelper::set($body, $name, $param); |
390 | 390 | } |
391 | 391 | |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | $paramSchema->in = 'body'; |
399 | 399 | if (is_array($body)) { |
400 | 400 | $paramSchema->schema = $this->makeTempSchema($app, $controller, $action, $route, $body, 'Req'); |
401 | - } else { |
|
401 | + }else { |
|
402 | 402 | $paramSchema->schema = $this->getAnySchema($app, $controller, $action, $route, $body->container); |
403 | 403 | } |
404 | 404 | |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | } elseif ($container instanceof ScalarTypeContainer) { |
426 | 426 | $schema = new PrimitiveSchemaObject(); |
427 | 427 | $schema->type = self::mapType($container->getType()); |
428 | - } elseif($container == null){ |
|
429 | - $schema = null ;//new PrimitiveSchemaObject(); |
|
428 | + } elseif ($container == null) { |
|
429 | + $schema = null; //new PrimitiveSchemaObject(); |
|
430 | 430 | //$schema->type = null; |
431 | 431 | }else { |
432 | 432 | $schema = new PrimitiveSchemaObject(); |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | } elseif ($itemContainer instanceof ScalarTypeContainer) { |
459 | 459 | $itemSchema = new PrimitiveSchemaObject(); |
460 | 460 | $itemSchema->type = self::mapType($itemContainer->getType()); |
461 | - } else { |
|
461 | + }else { |
|
462 | 462 | $itemSchema = new PrimitiveSchemaObject(); |
463 | 463 | //$itemSchema->type = 'mixed'; |
464 | 464 | } |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | $propertySchema = $this->getRefSchema($app, $controller, $action, $route, $property->container); |
485 | 485 | } elseif ($property->container instanceof ArrayContainer) { |
486 | 486 | $propertySchema = $this->getArraySchema($app, $controller, $action, $route, $property->container); |
487 | - } else { |
|
487 | + }else { |
|
488 | 488 | $propertySchema = new PrimitiveSchemaObject(); |
489 | 489 | $propertySchema->type = self::mapType($property->type); |
490 | 490 | $propertySchema->description = self::implode("\n", [$property->summary, $property->description]); |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | { |
502 | 502 | $params = $route->getRequestHandler()->getParamMetas(); |
503 | 503 | foreach ($params as $name => $param) { |
504 | - if(strpos($param->source, 'request.files.')===0){ |
|
504 | + if (strpos($param->source, 'request.files.') === 0) { |
|
505 | 505 | return true; |
506 | 506 | } |
507 | 507 | } |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | */ |
515 | 515 | static public function mapValidation($v, PrimitiveSchemaObject $schemaObject) |
516 | 516 | { |
517 | - if(!$v){ |
|
517 | + if (!$v) { |
|
518 | 518 | return $schemaObject; |
519 | 519 | } |
520 | 520 | $rules = explode('|', $v); |
@@ -530,15 +530,15 @@ discard block |
||
530 | 530 | } elseif ($rule == 'lengthBetween' && isset($params[0]) && isset($params[1])) { |
531 | 531 | $schemaObject->minLength = intval($params[0]); |
532 | 532 | $schemaObject->maxLength = intval($params[1]); |
533 | - } elseif ($rule == 'lengthMin'&& isset($params[0])) { |
|
533 | + } elseif ($rule == 'lengthMin' && isset($params[0])) { |
|
534 | 534 | $schemaObject->minLength = intval($params[0]); |
535 | - } elseif ($rule == 'lengthMax'&& isset($params[0])) { |
|
535 | + } elseif ($rule == 'lengthMax' && isset($params[0])) { |
|
536 | 536 | $schemaObject->maxLength = intval($params[0]); |
537 | - } elseif ($rule == 'min'&& isset($params[0])) { |
|
537 | + } elseif ($rule == 'min' && isset($params[0])) { |
|
538 | 538 | $schemaObject->minimum = floatval($params[0]); |
539 | - } elseif ($rule == 'max'&& isset($params[0])) { |
|
539 | + } elseif ($rule == 'max' && isset($params[0])) { |
|
540 | 540 | $schemaObject->maximum = floatval($params[0]); |
541 | - } elseif ($rule == 'regex'&& isset($params[0])) { |
|
541 | + } elseif ($rule == 'regex' && isset($params[0])) { |
|
542 | 542 | $schemaObject->pattern = $params[0]; |
543 | 543 | } elseif ($rule == 'optional') { |
544 | 544 | $schemaObject->required = false; |
@@ -577,9 +577,9 @@ discard block |
||
577 | 577 | return $className; |
578 | 578 | } |
579 | 579 | |
580 | - static public function implode($glue , array $pieces ) |
|
580 | + static public function implode($glue, array $pieces) |
|
581 | 581 | { |
582 | - $pieces = array_filter($pieces, function($i){return trim($i) !== '';}); |
|
582 | + $pieces = array_filter($pieces, function($i) {return trim($i) !== ''; }); |
|
583 | 583 | return implode($glue, $pieces); |
584 | 584 | } |
585 | 585 | } |
586 | 586 | \ No newline at end of file |