| Conditions | 3 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | public static function getInaccessibleProperty(object $object, string $propertyName, bool $revoke = true): mixed |
||
| 20 | { |
||
| 21 | $class = new ReflectionClass($object); |
||
| 22 | |||
| 23 | while (!$class->hasProperty($propertyName)) { |
||
| 24 | $class = $class->getParentClass(); |
||
| 25 | } |
||
| 26 | |||
| 27 | $property = $class->getProperty($propertyName); |
||
| 28 | |||
| 29 | $property->setAccessible(true); |
||
| 30 | |||
| 31 | $result = $property->getValue($object); |
||
| 32 | |||
| 33 | if ($revoke) { |
||
| 34 | $property->setAccessible(false); |
||
| 35 | } |
||
| 36 | |||
| 37 | return $result; |
||
| 38 | } |
||
| 58 |