1 | <?php |
||
7 | trait AccessProtectedTrait |
||
8 | { |
||
9 | /** |
||
10 | * Create closure to call inaccessible method. |
||
11 | * |
||
12 | * @param $instance |
||
13 | * @return \Closure |
||
14 | */ |
||
15 | 384 | protected function createProtectedCaller($instance) |
|
25 | |||
26 | /** |
||
27 | * Gets inaccessible property. |
||
28 | * |
||
29 | * @param $instance |
||
30 | * @param $property |
||
31 | * @return \Closure |
||
32 | */ |
||
33 | 84 | protected function getProtected($instance, $property) |
|
34 | { |
||
35 | $closure = function ($property) { |
||
36 | 84 | return $this->$property; |
|
37 | 84 | }; |
|
38 | 84 | $callback = $closure->bindTo($instance, $instance); |
|
39 | |||
40 | 84 | return $callback($property); |
|
41 | } |
||
42 | |||
43 | /** |
||
44 | * Calls inaccessible method. |
||
45 | * |
||
46 | * @param object|\Closure $instance |
||
47 | * @param $method |
||
48 | * @param $args |
||
49 | * @return mixed |
||
50 | */ |
||
51 | 12 | protected function callProtected($instance, $method, $args = []) |
|
59 | } |
||
60 |