My question is a follow up to the following question: What does it mean to start a php function with an ampersand?
The example code used in the question is this:
class FacebookRestClient {
...
public function &users_hasAppPermission($ext_perm, $uid=null) {
return $this->call_method('facebook.users.hasAppPermission',
array('ext_perm' => $ext_perm, 'uid' => $uid));
}
...
}
Why would a reference be necessary when we already have a reference ($this)?
The chosen answer quotes the following from the PHP manual on Returning References
Returning by reference is useful when you want to use a function to find to which variable a reference should be bound. Do not use return-by-reference to increase performance. The engine will automatically optimize this on its own. Only return references when you have a valid technical reason to do so.
The second answer gives a reason why this technique was needed in PHP4. But I don't find the answer for why it is needed in PHP5 very convincing.
Does anybody know of any valid reason(s) for using this technique in PHP5?