@@ -24,7 +24,48 @@ public function param() {
24
24
return new Callback ($ this ->callback , $ this ->params +$ params );
25
25
}
26
26
}
27
- class CallbackReference extends Callback{
27
+ class CallbackReturnReference extends Callback {
28
+ protected $ reference ;
29
+ public function __construct (&$ reference , $ name = null ){
30
+ $ this ->reference =& $ reference ;
31
+ $ this ->callback = array ($ this , 'callback ' );
32
+ }
33
+ public function callback () {
34
+ return $ this ->reference ;
35
+ }
36
+ }
37
+ class CallbackReturnValue extends Callback {
38
+ protected $ value ;
39
+ public function __construct ($ value , $ name = null ){
40
+ $ this ->value =& $ value ;
41
+ $ this ->callback = array ($ this , 'callback ' );
42
+ }
43
+ public function callback () {
44
+ return $ this ->value ;
45
+ }
46
+ }
47
+ /**
48
+ * CallbackParameterToReference can be used when we don't really want a callback,
49
+ * only parameter passed to it. CallbackReference takes first parameter's value
50
+ * and passes it to reference. Thanks to that, we can use *if statement* instead
51
+ * of *callback function*.
52
+ *
53
+ * @author Tobiasz Cudnik <tobiasz.cudnik/gmail.com>
54
+ *
55
+ */
56
+ class CallbackParameterToReference extends Callback {
57
+ /**
58
+ *
59
+ * @param $reference
60
+ * @param $paramIndex
61
+ * @TODO implement $paramIndex;
62
+ * param index choose which callback param will be passed to reference
63
+ */
64
+ public function __construct (&$ reference , $ paramIndex = null ){
65
+ $ this ->callback =& $ reference ;
66
+ }
67
+ }
68
+ class CallbackReference extends Callback {
28
69
/**
29
70
*
30
71
* @param $reference
0 commit comments