| Conditions | 7 |
| Paths | 32 |
| Total Lines | 33 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | protected static function doGenerate(\ReflectionMethod $method): string |
||
| 33 | { |
||
| 34 | $static = $method->isStatic() ? 'static' : ''; |
||
| 35 | |||
| 36 | $parameters = $method->getParameters(); |
||
| 37 | $parametersCode = []; |
||
| 38 | if ($parameters) { |
||
| 39 | foreach ($parameters as $parameter) { |
||
| 40 | $parametersCode[] = ProxyParameterTemplate::generate($parameter); |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 | $originalReturnType = $method->getReturnType(); |
||
| 45 | $returnType = $originalReturnType |
||
| 46 | ? ProxyReturnTypeTemplate::generate($method) |
||
| 47 | : ''; |
||
| 48 | |||
| 49 | $returnStatement = null === $originalReturnType || 'void' !== (string)$originalReturnType |
||
| 50 | ? 'return' |
||
| 51 | : ''; |
||
| 52 | |||
| 53 | $methodName = $method->getName(); |
||
| 54 | |||
| 55 | return sprintf( |
||
| 56 | self::TEMPLATE, |
||
| 57 | $static, |
||
| 58 | $methodName, |
||
| 59 | implode(',', $parametersCode), |
||
| 60 | $returnType, |
||
| 61 | $returnStatement, |
||
| 62 | $methodName |
||
| 63 | ); |
||
| 64 | } |
||
| 65 | } |
||
| 66 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.