Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99725 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82997 invoked from network); 3 Jul 2017 21:21:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jul 2017 21:21:25 -0000 Authentication-Results: pb1.pair.com header.from=andreas@heigl.org; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=andreas@heigl.org; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain heigl.org designates 195.191.240.18 as permitted sender) X-PHP-List-Original-Sender: andreas@heigl.org X-Host-Fingerprint: 195.191.240.18 hos109.unaxus.net Received: from [195.191.240.18] ([195.191.240.18:40339] helo=hos109.unaxus.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6D/19-15131-355BA595 for ; Mon, 03 Jul 2017 17:21:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=heigl.org; s=default; h=Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe :List-Post:List-Owner:List-Archive; bh=i9n66Zw10gji4WAP521moFrC24a2Be5fX3yGOFusrUk=; b=ZmgQxxvKJtRQjQRFDaLoIRxTtm UzPKjmqZQpymF2oojDlOA0TFIC5HgEulQPqQWJ+sW8wzSfIHOMViNuWGZe0r8nFtJkKcNl4SPcnMK jLWzGpQiRjnwAZNSz/d6EL1a8na/vU+vQ+qBzjsx86RSRshBZ6CRZf2+UwNvT2r2Z+fGRsY0RD1jX NyIAML5p5ofotsWkJ4L69a5y0q4Xr4oyHtIw83Y8tdJCv3x4h955xw38olO5fPO84QyMKGnGluEDh H+HrC2rlokkkH6JDk2pZoZVC78PbsGkmGdkoiABUMUhqnPl7sFPFroTOgztOBMQ3RpndbTSs15JoK aWXjDEfw==; Received: from heigl.gw.tgnet.de ([80.72.250.242]:61250 helo=localadmins-MacBook-Pro.local) by hos109.unaxus.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89) (envelope-from ) id 1dS8mV-0040e3-Ps; Mon, 03 Jul 2017 23:21:19 +0200 To: Andreas Treichel , internals@lists.php.net, =?UTF-8?Q?C=c3=b4me_Chilliet?= References: <2963553.WttLOBJENj@mcmic-probook> Openpgp: id=967CCFA50DFFEE03BB8BF5F2CA9213C75BFCE472 Message-ID: <9a0b9d93-a8bd-0da0-dc16-971eb5d0c448@heigl.org> Date: Mon, 3 Jul 2017 23:21:15 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="kSs04vj8CjBdUEhxlJWb3De4FqiK5TSab" X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hos109.unaxus.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - heigl.org X-Get-Message-Sender-Via: hos109.unaxus.net: authenticated_id: a.heigl+heigl.org/only user confirmed/virtual account not confirmed X-Authenticated-Sender: hos109.unaxus.net: a.heigl@heigl.org Subject: Re: [PHP-DEV] Re: [RFC] LDAP EXOP From: andreas@heigl.org (Andreas Heigl) --kSs04vj8CjBdUEhxlJWb3De4FqiK5TSab Content-Type: multipart/mixed; boundary="gaFBBwrFBUnmkplEBO71Vc2CGid5RRJX1"; protected-headers="v1" From: Andreas Heigl To: Andreas Treichel , internals@lists.php.net, =?UTF-8?Q?C=c3=b4me_Chilliet?= Message-ID: <9a0b9d93-a8bd-0da0-dc16-971eb5d0c448@heigl.org> Subject: Re: [PHP-DEV] Re: [RFC] LDAP EXOP References: <2963553.WttLOBJENj@mcmic-probook> In-Reply-To: --gaFBBwrFBUnmkplEBO71Vc2CGid5RRJX1 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hey C=C3=B4me, hey Andreas. Am 03.07.17 um 17:04 schrieb Andreas Treichel: > Hello, >=20 > please change the signature form >=20 > bool ldap_exop_whoami(resource $link, string &$result) >=20 > to >=20 > string ldap_whoami(resource $link); >=20 > i dont see the benefit to return a single value with a reference. >=20 > Without a reference the function can used as an argument: > doSomethingWithTheUserName(ldap_whoami($link)); >=20 >=20 > With a reference a variable is required: > ldap_whoami($link, $username); > doSomethingWithTheUserName($username); >=20 >=20 > same with the return statement of a method: >=20 > class MyLdap > { > public function getCurrentUser(): string > { > return ldap_whoami($this->link); > } > } >=20 > class MyLdap > { > function getCurrentUser(): string > { > ldap_whoami($this->link, $username); > return $username; > } > } After thinking a while about this I think it would be a good idea to alter the signature of the functions and return a value or FALSE instead of a boolean value. In my eyes the code and the extension would benefit in a few ways: * It would allow us to slowly get rid of pass-by-reference variables * It would make it easier for users to get a value * It would allow us to shift to use Exceptions instead of errors more eas= ily For methods that could return more than one value we could return an array or an object. There are currently both ways in the code but from the discussions I've had so far I've learned that removing the references (and getting rid of the resources) would be a plus. =46rom what I've seen in the code at least removing the pass-by-reference= should be possible without too much changes. So the signatures would look like this: string|FALSE ldap_exop_whoami(resource $link) - The returned string is the DN of the currently bound user. string|FALSE ldap_exop_passwd(resource $link [, string $user [, string $oldPassword [, string $newPassword]]] - The returned string is the new password of the user. Either the given newPassword or a newly generated o= ne. Both would return FALSE on an error (or throw an Exception) so one can use them like this if (false =3D=3D=3D ($password =3D ldap_exop_passwd($link))) { // something went wrong } else { echo $password; } Or is that complete and utter nonsense? Cheers Andreas --=20 ,,, (o o) +---------------------------------------------------------ooO-(_)-Ooo-+ | Andreas Heigl | | mailto:andreas@heigl.org N 50=C2=B022'59.5" E 08=C2=B0= 23'58" | | http://andreas.heigl.org http://hei.gl/wiFKy7 | +---------------------------------------------------------------------+ | http://hei.gl/root-ca | +---------------------------------------------------------------------+ --gaFBBwrFBUnmkplEBO71Vc2CGid5RRJX1-- --kSs04vj8CjBdUEhxlJWb3De4FqiK5TSab Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org iQIzBAEBCAAdFiEENHMr85T+FLwCJRBgjNqPc6i4Q/AFAllatUsACgkQjNqPc6i4 Q/BXixAAsqNbWjIH5rKheiK+tXNwa2bMx30zJmXANFWPnfZXvch9ZS/c1qzULy9h jKkGyStX200TI05syqzcy2H4+Bwwunrf82dbNIZg6rx/jDzB11rHML9VXPsXLhGo GDzKYf5hUYj5wxImU7R+/eHZLjTvtTXaNPrGdWA1BWzxzECtTq2udSY4nl06o+Fm 56Tua4mA0AaLx5SZdCPyzxnz20DoQYIOzJDBDgVfDDfzUsfqmQ9Qmv7fsJt3fhwV Xktsthyfxp3dBQmjaOfiSKU9AxfGAnJSzPSKr1o8gAJPsTrkqXW2gKNGGRZMJsV6 gjpseM5tkIUwbIAvf+eazhy7JXwxb1BBr/u+r6VguluJ8XohrPHjW7OV0/u64dRA bcHVlO6+vcT6AbYjRqQk+hCtXh2Xbl54+1BGVcdIzvmx03WXhNiXt5sPcG1//tLa 4STwJOFvAj5nW4S33vRX0x4o+n2ERsEVVBKZWE+hqMdVvSDGJigl0UeogAsMpl00 eCmj0UCjJFQRK7lrAR+PEWHHIZFeVmkbdeiy6MlDewPKX9d7/ZSsavyo5IoLEmCz /9aaWVQb05IB44fUWddRZk0S2hsgsaPbatoHcZ2KqdsNvYEsqU7fysKZxCkP1PSN uHNG6whLFqY/Ret13/VjmMQ1GH3BRtkZxdyDorqQkO+pGRhLk2Y= =/Egs -----END PGP SIGNATURE----- --kSs04vj8CjBdUEhxlJWb3De4FqiK5TSab--