@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | $paramType = null; |
23 | 23 | $paramName = null; |
24 | 24 | $paramDoc = ''; |
25 | - if(substr($text, 0, 1) == '$'){ //带$前缀的是变量 |
|
25 | + if (substr($text, 0, 1) == '$') { //带$前缀的是变量 |
|
26 | 26 | $params = new AnnotationParams($text, 2); |
27 | 27 | $paramName = substr($params->getParam(0), 1); |
28 | 28 | $paramDoc = $params->getRawParam(1, ''); |
29 | - }else{ |
|
29 | + }else { |
|
30 | 30 | $params = new AnnotationParams($text, 3); |
31 | - if ($params->count() >=2 && substr($params->getParam(1), 0, 1) == '$'){ |
|
31 | + if ($params->count()>=2 && substr($params->getParam(1), 0, 1) == '$') { |
|
32 | 32 | $paramType = $params->getParam(0); //TODO 检测类型是否合法 |
33 | 33 | $paramName = substr($params->getParam(1), 1); |
34 | 34 | $paramDoc = $params->getRawParam(2, ''); |
35 | - }else{ |
|
35 | + }else { |
|
36 | 36 | \PhpBoot\abort(new AnnotationSyntaxException("@param $text syntax error")); |
37 | 37 | } |
38 | 38 | } |
@@ -45,15 +45,15 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function __invoke(ConsoleContainer $container, $ann, EntityContainerBuilder $entityBuilder) |
47 | 47 | { |
48 | - if(!$ann->parent){ |
|
48 | + if (!$ann->parent) { |
|
49 | 49 | //Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()} should be used with parent route"); |
50 | 50 | return; |
51 | 51 | } |
52 | 52 | $target = $ann->parent->name; |
53 | 53 | $command = $container->getCommand($target); |
54 | - if(!$command){ |
|
54 | + if (!$command) { |
|
55 | 55 | //Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()}::$target should be used with parent route"); |
56 | - return ; |
|
56 | + return; |
|
57 | 57 | } |
58 | 58 | $className = $container->getClassName(); |
59 | 59 | |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | $paramMeta = $command->getParamMeta($paramName); |
63 | 63 | $paramMeta or \PhpBoot\abort(new AnnotationSyntaxException("$className::$target param $paramName not exist ")); |
64 | 64 | //TODO 检测声明的类型和注释的类型是否匹配 |
65 | - if($paramType){ |
|
66 | - $paramMeta->type = TypeHint::normalize($paramType, $className);//or \PhpBoot\abort(new AnnotationSyntaxException("{$container->getClassName()}::{$ann->parent->name} @{$ann->name} syntax error, param $paramName unknown type:$paramType ")); |
|
65 | + if ($paramType) { |
|
66 | + $paramMeta->type = TypeHint::normalize($paramType, $className); //or \PhpBoot\abort(new AnnotationSyntaxException("{$container->getClassName()}::{$ann->parent->name} @{$ann->name} syntax error, param $paramName unknown type:$paramType ")); |
|
67 | 67 | $container = ContainerFactory::create($entityBuilder, $paramMeta->type); |
68 | 68 | $paramMeta->container = $container; |
69 | 69 | } |
@@ -25,13 +25,13 @@ |
||
25 | 25 | $params = new AnnotationParams($text, 2); |
26 | 26 | $paramName = substr($params->getParam(0), 1); |
27 | 27 | $paramDoc = $params->getRawParam(1, ''); |
28 | - }else{ |
|
28 | + } else{ |
|
29 | 29 | $params = new AnnotationParams($text, 3); |
30 | 30 | if ($params->count() >=2 && substr($params->getParam(1), 0, 1) == '$'){ |
31 | 31 | $paramType = $params->getParam(0); //TODO 检测类型是否合法 |
32 | 32 | $paramName = substr($params->getParam(1), 1); |
33 | 33 | $paramDoc = $params->getRawParam(2, ''); |
34 | - }else{ |
|
34 | + } else{ |
|
35 | 35 | \PhpBoot\abort(new AnnotationSyntaxException("@param $text syntax error")); |
36 | 36 | } |
37 | 37 | } |
@@ -18,29 +18,29 @@ |
||
18 | 18 | */ |
19 | 19 | public function __invoke(ConsoleContainer $container, $ann) |
20 | 20 | { |
21 | - if(!$ann->parent || !$ann->parent->parent){ |
|
21 | + if (!$ann->parent || !$ann->parent->parent) { |
|
22 | 22 | Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()} should be used with parent parent"); |
23 | 23 | return; |
24 | 24 | } |
25 | 25 | $target = $ann->parent->parent->name; |
26 | 26 | $command = $container->getCommand($target); |
27 | - if(!$command){ |
|
27 | + if (!$command) { |
|
28 | 28 | Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()}::$target should be used with parent parent"); |
29 | - return ; |
|
29 | + return; |
|
30 | 30 | } |
31 | 31 | $params = new AnnotationParams($ann->description, 2); |
32 | 32 | |
33 | 33 | count($params)>0 or \PhpBoot\abort(new AnnotationSyntaxException("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()}::$target require 1 param, {$params->count()} given")); |
34 | 34 | |
35 | - if($ann->parent->name == 'param'){ |
|
35 | + if ($ann->parent->name == 'param') { |
|
36 | 36 | list($paramType, $paramName, $paramDoc) = ParamAnnotationHandler::getParamInfo($ann->parent->description); |
37 | 37 | |
38 | 38 | $paramMeta = $command->getParamMeta($paramName); |
39 | - if($params->count()>1){ |
|
39 | + if ($params->count()>1) { |
|
40 | 40 | $paramMeta->validation = [$params[0], $params[1]]; |
41 | - }else{ |
|
41 | + }else { |
|
42 | 42 | $paramMeta->validation = $params[0]; |
43 | - if($paramMeta->validation) { |
|
43 | + if ($paramMeta->validation) { |
|
44 | 44 | $v = new Validator(); |
45 | 45 | $v->rule($paramMeta->validation, $paramMeta->name); |
46 | 46 | if ($v->hasRule('optional', $paramMeta->name)) { |
@@ -38,7 +38,7 @@ |
||
38 | 38 | $paramMeta = $command->getParamMeta($paramName); |
39 | 39 | if($params->count()>1){ |
40 | 40 | $paramMeta->validation = [$params[0], $params[1]]; |
41 | - }else{ |
|
41 | + } else{ |
|
42 | 42 | $paramMeta->validation = $params[0]; |
43 | 43 | if($paramMeta->validation) { |
44 | 44 | $v = new Validator(); |