Conditions | 12 |
Paths | 13 |
Total Lines | 47 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
90 | public function loadMetadataForClassService($serviceClassName, $serviceMethod) |
||
91 | { |
||
92 | $key = $serviceClassName . '_' . $serviceMethod; |
||
93 | if (array_key_exists($key, $this->classAnnotations)) { |
||
94 | return $this->classAnnotations[$key]; |
||
95 | } |
||
96 | |||
97 | $r = new ReflectionClass($serviceClassName); |
||
98 | $rMethod = $r->getMethod($serviceMethod); |
||
99 | |||
100 | $metadata = new Metadata(); |
||
101 | |||
102 | /** @var Annotation\ArgumentsMap|null $argumentsMapAnnotation */ |
||
103 | $argumentsMapAnnotation = $this->getReader()->getMethodAnnotation($rMethod, Annotation\ArgumentsMap::class); |
||
104 | |||
105 | if (null !== $argumentsMapAnnotation && is_array($argumentsMapAnnotation->argumentsMap)) { |
||
106 | foreach ($argumentsMapAnnotation->argumentsMap as $map) { |
||
107 | if ($map instanceof Map) { |
||
108 | $metadata->addArgumentMap($map->to, $map->fromArgName); |
||
109 | } |
||
110 | } |
||
111 | } |
||
112 | |||
113 | |||
114 | /** @var Annotation\ResultVariable|null $resultVariableAnnotation */ |
||
115 | $resultVariableAnnotation = $this->getReader()->getMethodAnnotation($rMethod, Annotation\ResultVariable::class); |
||
116 | if (null !== $resultVariableAnnotation) { |
||
117 | $metadata->setResultVariableName($resultVariableAnnotation->name); |
||
118 | $metadata->setAllowOverrideResult($resultVariableAnnotation->override); |
||
|
|||
119 | } |
||
120 | |||
121 | /** @var Annotation\ResultsMap|null $resultsMapAnnotation */ |
||
122 | $resultsMapAnnotation = $this->getReader()->getMethodAnnotation($rMethod, Annotation\ResultsMap::class); |
||
123 | if (null !== $resultsMapAnnotation && is_array($resultsMapAnnotation->map) && count($resultsMapAnnotation->map) > 0) { |
||
124 | foreach ($resultsMapAnnotation->map as $resultMap) { |
||
125 | if (!$resultMap instanceof Annotation\ResultMap) { |
||
126 | $errMsg = sprintf('Result map not implements %s', Annotation\ResultMap::class); |
||
127 | throw new Exception\InvalidMetadataException($errMsg); |
||
128 | } |
||
129 | |||
130 | $resultMap = new ResultMapMetadata($resultMap->from, $resultMap->to, $resultMap->override); |
||
131 | $metadata->addResultMap($resultMap); |
||
132 | } |
||
133 | } |
||
134 | |||
135 | return $metadata; |
||
136 | } |
||
137 | |||
201 |
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: