1 | <?php |
||
21 | class Reference |
||
22 | { |
||
23 | /** |
||
24 | * The reference |
||
25 | * @var null |
||
26 | */ |
||
27 | private $point; |
||
28 | |||
29 | /** |
||
30 | * Reference constructor. |
||
31 | * Pass in the thing you want to get the reference of |
||
32 | * @param null|mixed $ref |
||
33 | */ |
||
34 | 6 | public function __construct(&$ref = null) |
|
38 | |||
39 | /** |
||
40 | * Set data at the location the reference points to |
||
41 | * @param $data |
||
42 | */ |
||
43 | 3 | public function set($data) |
|
47 | |||
48 | /** |
||
49 | * Return a copy of the data references to by this reference instance |
||
50 | * @return null |
||
51 | */ |
||
52 | 3 | public function copy() |
|
56 | |||
57 | /** |
||
58 | * Swap this reference with another |
||
59 | * @param \twhiston\twLib\Reference\Reference $point |
||
60 | * @return mixed|null |
||
61 | */ |
||
62 | 2 | public function &swap(Reference &$point) |
|
73 | |||
74 | /** |
||
75 | * Remember that you MUST put & infront of the function call as well to actually get a reference |
||
76 | * This will return the memory location of the object pointed to by $this->point |
||
77 | * @return null|mixed |
||
78 | */ |
||
79 | 4 | public function &getRef() |
|
83 | |||
84 | /** |
||
85 | * Release the current reference and either set this reference to NULL or to &$ref |
||
86 | * @param null $ref |
||
87 | */ |
||
88 | 2 | public function reset(&$ref = null) |
|
93 | |||
94 | /** |
||
95 | * Release the reference |
||
96 | */ |
||
97 | 2 | public function release() |
|
102 | } |