1 | <?php |
||
16 | class PublicScopeSimulator |
||
17 | { |
||
18 | public const OPERATION_SET = 'set'; |
||
19 | public const OPERATION_GET = 'get'; |
||
20 | public const OPERATION_ISSET = 'isset'; |
||
21 | public const OPERATION_UNSET = 'unset'; |
||
22 | |||
23 | /** |
||
24 | * Generates code for simulating access to a property from the scope that is accessing a proxy. |
||
25 | * This is done by introspecting `debug_backtrace()` and then binding a closure to the scope |
||
26 | * of the parent caller. |
||
27 | * |
||
28 | * @param string $operationType operation to execute: one of 'get', 'set', 'isset' or 'unset' |
||
29 | * @param string $nameParameter name of the `name` parameter of the magic method |
||
30 | * @param string|null $valueParameter name of the `value` parameter of the magic method |
||
31 | * @param PropertyGenerator $valueHolder name of the property containing the target object from which |
||
32 | * to read the property. `$this` if none provided |
||
33 | * @param string|null $returnPropertyName name of the property to which we want to assign the result of |
||
34 | * the operation. Return directly if none provided |
||
35 | * |
||
36 | * @throws InvalidArgumentException |
||
37 | */ |
||
38 | 8 | public static function getPublicAccessSimulationCode( |
|
71 | |||
72 | /** |
||
73 | * This will generate code that triggers a notice if access is attempted on a non-existing property |
||
74 | */ |
||
75 | private static function getUndefinedPropertyNotice(string $operationType, string $nameParameter) : string |
||
93 | 2 | ||
94 | /** |
||
95 | * Defines whether the given operation produces a reference. |
||
96 | * |
||
97 | * Note: if the object is a wrapper, the wrapped instance is accessed directly. If the object |
||
98 | * is a ghost or the proxy has no wrapper, then an instance of the parent class is created via |
||
99 | * on-the-fly unserialization |
||
100 | */ |
||
101 | private static function getByRefReturnValue(string $operationType) : string |
||
105 | 8 | ||
106 | /** |
||
107 | * Retrieves the logic to fetch the object on which access should be attempted |
||
108 | */ |
||
109 | private static function getTargetObject(?PropertyGenerator $valueHolder = null) : string |
||
117 | |||
118 | /** |
||
119 | 5 | * @throws InvalidArgumentException |
|
120 | */ |
||
121 | private static function getOperation(string $operationType, string $nameParameter, ?string $valueParameter) : string |
||
140 | |||
141 | /** |
||
142 | 1 | * Generates code to bind operations to the parent scope |
|
143 | */ |
||
144 | private static function getScopeReBind() : string |
||
151 | } |
||
152 |