Skip to content

Commit 357dc12

Browse files
committed
Various changes requested for review
Change an excepion switch into a batch of if tests Remove PHPdoc in implementation Fix typo introduced in previous commit
1 parent 80b9e46 commit 357dc12

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ public function bind(?string $dn = null, #[\SensitiveParameter] ?string $passwor
7070

7171
if (false === @ldap_bind($this->connection, $dn, $password)) {
7272
$error = ldap_error($this->connection);
73-
switch (ldap_errno($this->connection)) {
74-
case self::LDAP_INVALID_CREDENTIALS:
73+
$errno = ldap_errno($this->connection);
74+
if (self::LDAP_INVALID_CREDENTIALS === $errno) {
7575
throw new InvalidCredentialsException($error);
76-
case self::LDAP_TIMEOUT:
76+
}
77+
if (self::LDAP_TIMEOUT === $errno) {
7778
throw new ConnectionTimeoutException($error);
78-
case self::LDAP_ALREADY_EXISTS:
79+
}
80+
if (self::LDAP_ALREADY_EXISTS === $errno) {
7981
throw new AlreadyExistsException($error);
8082
}
8183
ldap_get_option($this->connection, LDAP_OPT_DIAGNOSTIC_MESSAGE, $diagnostic_message);
@@ -87,10 +89,8 @@ public function bind(?string $dn = null, #[\SensitiveParameter] ?string $passwor
8789

8890
/**
8991
* @param string $password WARNING: When the LDAP server allows unauthenticated binds, a blank $password will always be valid
90-
*
91-
* @return void
9292
*/
93-
public function sasBbind(?string $dn = null, #[\SensitiveParameter] ?string $password = null, ?string $mech = null, ?string $realm = null, ?string $authcId = null, ?string $authzId = null, ?string $props = null): void
93+
public function saslBind(?string $dn = null, #[\SensitiveParameter] ?string $password = null, ?string $mech = null, ?string $realm = null, ?string $authcId = null, ?string $authzId = null, ?string $props = null): void
9494
{
9595
if (!function_exists('ldap_sasl_bind')) {
9696
throw new LdapException('Library - missing SASL support');
@@ -102,12 +102,14 @@ public function sasBbind(?string $dn = null, #[\SensitiveParameter] ?string $pas
102102

103103
if (false === @ldap_sasl_bind($this->connection, $dn, $password, $mech, $realm, $authcId, $authzId, $props)) {
104104
$error = ldap_error($this->connection);
105-
switch (ldap_errno($this->connection)) {
106-
case self::LDAP_INVALID_CREDENTIALS:
105+
$errno = ldap_errno($this->connection);
106+
if (self::LDAP_INVALID_CREDENTIALS === $errno) {
107107
throw new InvalidCredentialsException($error);
108-
case self::LDAP_TIMEOUT:
108+
}
109+
if (self::LDAP_TIMEOUT === $errno) {
109110
throw new ConnectionTimeoutException($error);
110-
case self::LDAP_ALREADY_EXISTS:
111+
}
112+
if (self::LDAP_ALREADY_EXISTS === $errno) {
111113
throw new AlreadyExistsException($error);
112114
}
113115
throw new ConnectionException($error);
@@ -119,8 +121,6 @@ public function sasBbind(?string $dn = null, #[\SensitiveParameter] ?string $pas
119121

120122
/**
121123
* ldap_exop_whoami accessor, returns authenticated DN
122-
*
123-
* @return string
124124
*/
125125
public function whoami(): string
126126
{

src/Symfony/Component/Ldap/Ldap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function bind(?string $dn = null, #[\SensitiveParameter] ?string $passwor
3232
$this->adapter->getConnection()->bind($dn, $password);
3333
}
3434

35-
public function saslbind(?string $dn = null, #[\SensitiveParameter] ?string $password = null, ?string $mech = null, ?string $realm = null, ?string $authcId = null, ?string $authzId = null, ?string $props = null): void
35+
public function saslBind(?string $dn = null, #[\SensitiveParameter] ?string $password = null, ?string $mech = null, ?string $realm = null, ?string $authcId = null, ?string $authzId = null, ?string $props = null): void
3636
{
3737
$this->adapter->getConnection()->saslBind($dn, $password, $mech, $realm, $authcId, $authzId, $props);
3838
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy