Le lundi 3 juillet 2017, 17:04:02 Andreas Treichel a écrit : > i dont see the benefit to return a single value with a reference. > > Without a reference the function can used as an argument: > doSomethingWithTheUserName(ldap_whoami($link));
Where do you handle errors in this case? For me returning a mixed will result in: $identity = ldap_exop_whoami($link); if ($identity !== FALSE) { // do something with $identity } else { // handle errors } While with the reference it’s cleaner: if (ldap_exop_whoami($link, $identity)) { // do something with $identity } else { // handle errors } It seems both solutions exists in existing LDAP methods: https://secure.php.net/manual/en/function.ldap-get-option.php https://secure.php.net/manual/en/function.ldap-get-dn.php The other thing I liked about using bool return and a reference is that it will allow all ldap_exop_* methods to be consistent, all returning a boolean and filling as many reference parameters as needed (from 0 to whatever). > same with the return statement of a method: > > class MyLdap > { > public function getCurrentUser(): string > { > return ldap_whoami($this->link); > } > } > > class MyLdap > { > function getCurrentUser(): string > { > ldap_whoami($this->link, $username); > return $username; > } > } This is a valid point. Côme
signature.asc
Description: This is a digitally signed message part.