Conditions | 6 |
Paths | 9 |
Total Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Tests | 17 |
CRAP Score | 6.4227 |
Changes | 0 |
1 | <?php |
||
19 | 3 | public function __invoke(EntityContainer $container, $ann) |
|
20 | { |
||
21 | 3 | $params = new AnnotationParams($ann->description, 3); |
|
22 | 3 | if($params->count()){ |
|
23 | |||
24 | 3 | $target = $ann->parent->name; |
|
25 | 3 | $property = $container->getProperty($target); |
|
26 | 3 | $property or \PhpBoot\abort($container->getClassName()." property $target not exist "); |
|
27 | 3 | if($params->count()>1){ |
|
28 | 1 | $property->validation = [$params->getParam(0), $params->getParam(1)]; |
|
29 | 1 | }else{ |
|
30 | 2 | $property->validation = $params->getParam(0); |
|
31 | 2 | if($property->validation){ |
|
32 | 2 | $v = new Validator(); |
|
33 | 2 | $v->rule($property->validation, $property->name); |
|
|
|||
34 | 2 | if($v->hasRule('optional', $property->name)){ |
|
35 | $property->isOptional = true; |
||
36 | } |
||
37 | 2 | } |
|
38 | } |
||
39 | |||
40 | 3 | }else{ |
|
41 | \PhpBoot\abort(new AnnotationSyntaxException( |
||
42 | "The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()}::{$ann->parent->name} require 1 param, 0 given" |
||
43 | )); |
||
44 | } |
||
45 | } |
||
46 | } |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: