Conditions | 1 |
Paths | 1 |
Total Lines | 13 |
Code Lines | 4 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | public static function allowAccessToProperty(string $className, string $propertyName) |
||
23 | { |
||
24 | // Create a reflection object for the class |
||
25 | $reflectionClass = new ReflectionClass($className); |
||
26 | |||
27 | // Get the protected property |
||
28 | $property = $reflectionClass->getProperty($propertyName); |
||
29 | |||
30 | // Make the property accessible |
||
31 | $property->setAccessible(true); |
||
32 | |||
33 | // Set the value of the protected property |
||
34 | return new $className(); |
||
35 | } |
||
37 |