1 | <?php declare(strict_types=1); |
||
13 | final class ReflectionApi |
||
14 | { |
||
15 | /** |
||
16 | * @var ReflectionClass[] |
||
17 | */ |
||
18 | private static $reflections = []; |
||
19 | |||
20 | /** |
||
21 | * @var object[] |
||
22 | */ |
||
23 | private static $instances = []; |
||
24 | |||
25 | /** |
||
26 | * Creates instance of the given class. |
||
27 | * |
||
28 | * @param string $class |
||
29 | * @return object |
||
30 | */ |
||
31 | 4 | public static function createInstance(string $class) |
|
46 | |||
47 | 2 | public static function createClass(string $class): RuntimeClass |
|
51 | |||
52 | 3 | public static function getClosureBody(Closure $closure): string |
|
65 | |||
66 | /** |
||
67 | * Overrides object's property value. |
||
68 | * |
||
69 | * @param $instance |
||
70 | * @param string $property property name |
||
71 | * @param $value |
||
72 | */ |
||
73 | 2 | public static function writeProperty($instance, string $property, $value): void |
|
85 | |||
86 | /** |
||
87 | * @param $instance |
||
88 | * @param string $property |
||
89 | * @return mixed |
||
90 | */ |
||
91 | 2 | public static function readProperty($instance, string $property) |
|
104 | |||
105 | /** |
||
106 | * Creates and caches in memory reflection of the given class. |
||
107 | * |
||
108 | * @param string $className |
||
109 | * @return ReflectionClass |
||
110 | * @throws \ReflectionException |
||
111 | */ |
||
112 | 1 | public static function reflectClass(string $className): ReflectionClass |
|
120 | |||
121 | /** |
||
122 | * Creates and caches in memory reflection of the given function. |
||
123 | * |
||
124 | * @param $function |
||
125 | * @return ReflectionFunction |
||
126 | * @throws \ReflectionException |
||
127 | */ |
||
128 | 3 | public static function reflectFunction($function): ReflectionFunction |
|
140 | |||
141 | /** |
||
142 | * Creates and caches in memory reflection of the given method. |
||
143 | * |
||
144 | * @param string $class |
||
145 | * @param string $method |
||
146 | * @return ReflectionMethod |
||
147 | * @throws \ReflectionException |
||
148 | */ |
||
149 | public static function reflectMethod(string $class, string $method): ReflectionMethod |
||
155 | } |
||
156 |