@@ -23,21 +23,21 @@ |
||
23 | 23 | public function __invoke(EntityContainer $container, $ann, EntityContainerBuilder $builder) |
24 | 24 | { |
25 | 25 | $params = new AnnotationParams($ann->description, 3); |
26 | - if($params->count()){ |
|
26 | + if ($params->count()) { |
|
27 | 27 | $type = $params->getParam(0); |
28 | 28 | //TODO 校验type类型 |
29 | 29 | $target = $ann->parent->name; |
30 | 30 | $property = $container->getProperty($target); |
31 | 31 | $property or \PhpBoot\abort($container->getClassName()." property $target not exist "); |
32 | - if($type == null || $type == 'mixed'){ |
|
32 | + if ($type == null || $type == 'mixed') { |
|
33 | 33 | $property->container = new MixedTypeContainer(); |
34 | - } else{ |
|
34 | + }else { |
|
35 | 35 | // TODO 判断$type是否匹配 |
36 | 36 | $property->type = TypeHint::normalize($type, $container->getClassName()); |
37 | 37 | // TODO 防止递归死循环 |
38 | 38 | $property->container = ContainerFactory::create($builder, $property->type); |
39 | 39 | } |
40 | - }else{ |
|
40 | + }else { |
|
41 | 41 | \PhpBoot\abort(new AnnotationSyntaxException( |
42 | 42 | "The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()}::{$ann->parent->name} require 1 param, 0 given" |
43 | 43 | )); |
@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | TypeHint::isArray($type) or \PhpBoot\abort(new \InvalidArgumentException("type $type is not array")); |
18 | 18 | $elementType = $type; |
19 | 19 | $loops = 0; |
20 | - while(TypeHint::isArray($elementType)){ |
|
20 | + while (TypeHint::isArray($elementType)) { |
|
21 | 21 | $elementType = TypeHint::getArrayType($elementType); |
22 | 22 | $loops++; |
23 | 23 | } |
24 | 24 | $container = $getElementContainer($elementType); |
25 | 25 | |
26 | - while($loops--){ |
|
26 | + while ($loops--) { |
|
27 | 27 | $container = new self($container); |
28 | 28 | } |
29 | 29 | return $container; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | { |
43 | 43 | is_array($data) or \PhpBoot\abort(new \InvalidArgumentException('the first param is required to be array')); |
44 | 44 | $res = []; |
45 | - foreach ($data as $k=>$v){ |
|
45 | + foreach ($data as $k=>$v) { |
|
46 | 46 | $res[$k] = $this->container->make($v, $validate); |
47 | 47 | } |
48 | 48 | return $res; |
@@ -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 |
@@ -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 |
@@ -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; |
@@ -16,7 +16,7 @@ |
||
16 | 16 | |
17 | 17 | class ModelContainerBuilder extends EntityContainerBuilder |
18 | 18 | { |
19 | - static $DEFAULT_ANNOTATIONS=[ |
|
19 | + static $DEFAULT_ANNOTATIONS = [ |
|
20 | 20 | [ClassAnnotationHandler::class, 'class'], |
21 | 21 | [PKAnnotationHandler::class, "class.children[?name=='pk']"], |
22 | 22 | [TableAnnotationHandler::class, "class.children[?name=='table']"], |
@@ -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 |