Re: Re: [RFC] LDAP EXOP
| From: | Côme Chilliet | Date: | Mon, 03 Jul 2017 15:41:41 +0000 |
| Subject: | Re: Re: [RFC] LDAP EXOP | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-99709@lists.php.net to get a copy of this message | ||
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
Attachment: [application/pgp-signature] This is a digitally signed message part. signature.asc
Attachment: [application/pgp-signature] This is a digitally signed message part. signature.asc