| Conditions | 4 |
| Paths | 8 |
| Total Lines | 23 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | 1 | public static function convertToAnonymous($object) |
|
| 25 | { |
||
| 26 | 1 | $reflexion = new \ReflectionClass($object); |
|
| 27 | $class = new class extends DynamicObject { |
||
| 28 | }; |
||
| 29 | |||
| 30 | 1 | foreach ($reflexion->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { |
|
| 31 | 1 | $method->setAccessible(true); |
|
| 32 | 1 | $class::addDynamicMethod($method->name, $method->getClosure($object)); |
|
| 33 | } |
||
| 34 | |||
| 35 | 1 | foreach ($reflexion->getMethods(\ReflectionMethod::IS_PROTECTED | \ReflectionMethod::IS_PRIVATE) as $method) { |
|
| 36 | 1 | $method->setAccessible(false); |
|
| 37 | 1 | $class::addDynamicMethod($method->name, $method->getClosure($object)); |
|
| 38 | } |
||
| 39 | |||
| 40 | 1 | foreach ($reflexion->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { |
|
| 41 | 1 | $property->setAccessible(true); |
|
| 42 | 1 | $class::addDynamicProperty($property->name, $property->getValue($object)); |
|
| 43 | } |
||
| 44 | |||
| 45 | 1 | return $class; |
|
| 46 | } |
||
| 47 | } |
||
| 48 |
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.