Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
19 / 19
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
6 / 6
CRAP
100.00% covered (success)
100.00%
1 / 1
HookProxy
100.00% covered (success)
100.00%
19 / 19
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
6 / 6
7
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __get
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __set
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __call
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 __get_private
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __call_private
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php namespace GorillaClaw;
2
3class HookProxy {
4   
5    public $__cb;
6    protected $__that;
7 
8    function __construct(&$hook_cb, &$that) {
9        $proxy = &$this;
10        $this->__that = &$that;
11        $this->__cb = \Closure::bind(function (...$args) use (&$proxy, &$hook_cb) {
12            return \Closure::bind($hook_cb, $proxy)(...$args);
13        }, $that);
14    }
15 
16    function __get($prop) {
17        return $this->__get_private($prop);
18    }
19 
20    function __set($prop, $val) {
21        $private = &$this->__get_private($prop);
22        $private = $val;
23    }
24 
25    function __call($method, $args) {
26
27        if($method === '__cb') {
28            return $this->__cb->bindTo($this->__that, $this->__that)(...$args);
29        }
30
31        return $this->__call_private($method, $args);
32    }
33     
34    public function &__get_private($var): mixed {
35        $that = &$this->__that;
36        return \Closure::bind(function &($that) use ($var) {
37            return $that->$var;
38        }, $that, $that)($that);
39    }
40
41    public function __call_private($var, $args): mixed {
42        $that = &$this->__that;
43        return \Closure::bind(function ($that) use ($var, $args) {
44            return $that->$var(...$args);
45        }, $that, $that)($that);
46    }
47 }