Skip to content

Commit 2eda8a1

Browse files
CS fixes
1 parent b5fa3ba commit 2eda8a1

13 files changed

+39
-39
lines changed

Adapter/AbstractConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected function configureOptions(OptionsResolver $resolver)
4545

4646
$resolver->setDefault('port', fn (Options $options) => 'ssl' === $options['encryption'] ? 636 : 389);
4747

48-
$resolver->setDefault('connection_string', fn (Options $options) => sprintf('ldap%s://%s:%s', 'ssl' === $options['encryption'] ? 's' : '', $options['host'], $options['port']));
48+
$resolver->setDefault('connection_string', fn (Options $options) => \sprintf('ldap%s://%s:%s', 'ssl' === $options['encryption'] ? 's' : '', $options['host'], $options['port']));
4949

5050
$resolver->setAllowedTypes('host', 'string');
5151
$resolver->setAllowedTypes('port', 'numeric');

Adapter/ExtLdap/Collection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ private function getSingleEntry($con, $current): Entry
125125
private function cleanupAttributes(array $entry): array
126126
{
127127
$attributes = array_diff_key($entry, array_flip(range(0, $entry['count'] - 1)) + [
128-
'count' => null,
129-
'dn' => null,
130-
]);
128+
'count' => null,
129+
'dn' => null,
130+
]);
131131
array_walk($attributes, function (&$value) {
132132
unset($value['count']);
133133
});

Adapter/ExtLdap/Connection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function getResource(): ?LDAPConnection
103103
public function setOption(string $name, array|string|int|bool $value)
104104
{
105105
if (!@ldap_set_option($this->connection, ConnectionOptions::getOption($name), $value)) {
106-
throw new LdapException(sprintf('Could not set value "%s" for option "%s".', $value, $name));
106+
throw new LdapException(\sprintf('Could not set value "%s" for option "%s".', $value, $name));
107107
}
108108
}
109109

@@ -113,7 +113,7 @@ public function setOption(string $name, array|string|int|bool $value)
113113
public function getOption(string $name)
114114
{
115115
if (!@ldap_get_option($this->connection, ConnectionOptions::getOption($name), $ret)) {
116-
throw new LdapException(sprintf('Could not retrieve value for option "%s".', $name));
116+
throw new LdapException(\sprintf('Could not retrieve value for option "%s".', $name));
117117
}
118118

119119
return $ret;

Adapter/ExtLdap/ConnectionOptions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ final class ConnectionOptions
6565

6666
public static function getOptionName(string $name): string
6767
{
68-
return sprintf('%s::%s', self::class, strtoupper($name));
68+
return \sprintf('%s::%s', self::class, strtoupper($name));
6969
}
7070

7171
/**
@@ -80,7 +80,7 @@ public static function getOption(string $name): int
8080
$constantName = self::getOptionName($name);
8181

8282
if (!\defined($constantName)) {
83-
throw new LdapException(sprintf('Unknown option "%s".', $name));
83+
throw new LdapException(\sprintf('Unknown option "%s".', $name));
8484
}
8585

8686
return \constant($constantName);

Adapter/ExtLdap/EntryManager.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function add(Entry $entry)
3737
$con = $this->getConnectionResource();
3838

3939
if (!@ldap_add($con, $entry->getDn(), $entry->getAttributes())) {
40-
throw new LdapException(sprintf('Could not add entry "%s": ', $entry->getDn()).ldap_error($con), ldap_errno($con));
40+
throw new LdapException(\sprintf('Could not add entry "%s": ', $entry->getDn()).ldap_error($con), ldap_errno($con));
4141
}
4242

4343
return $this;
@@ -51,7 +51,7 @@ public function update(Entry $entry)
5151
$con = $this->getConnectionResource();
5252

5353
if (!@ldap_modify($con, $entry->getDn(), $entry->getAttributes())) {
54-
throw new LdapException(sprintf('Could not update entry "%s": ', $entry->getDn()).ldap_error($con), ldap_errno($con));
54+
throw new LdapException(\sprintf('Could not update entry "%s": ', $entry->getDn()).ldap_error($con), ldap_errno($con));
5555
}
5656

5757
return $this;
@@ -65,7 +65,7 @@ public function remove(Entry $entry)
6565
$con = $this->getConnectionResource();
6666

6767
if (!@ldap_delete($con, $entry->getDn())) {
68-
throw new LdapException(sprintf('Could not remove entry "%s": ', $entry->getDn()).ldap_error($con), ldap_errno($con));
68+
throw new LdapException(\sprintf('Could not remove entry "%s": ', $entry->getDn()).ldap_error($con), ldap_errno($con));
6969
}
7070

7171
return $this;
@@ -84,7 +84,7 @@ public function addAttributeValues(Entry $entry, string $attribute, array $value
8484
$con = $this->getConnectionResource();
8585

8686
if (!@ldap_mod_add($con, $entry->getDn(), [$attribute => $values])) {
87-
throw new LdapException(sprintf('Could not add values to entry "%s", attribute "%s": ', $entry->getDn(), $attribute).ldap_error($con), ldap_errno($con));
87+
throw new LdapException(\sprintf('Could not add values to entry "%s", attribute "%s": ', $entry->getDn(), $attribute).ldap_error($con), ldap_errno($con));
8888
}
8989

9090
return $this;
@@ -103,7 +103,7 @@ public function removeAttributeValues(Entry $entry, string $attribute, array $va
103103
$con = $this->getConnectionResource();
104104

105105
if (!@ldap_mod_del($con, $entry->getDn(), [$attribute => $values])) {
106-
throw new LdapException(sprintf('Could not remove values from entry "%s", attribute "%s": ', $entry->getDn(), $attribute).ldap_error($con), ldap_errno($con));
106+
throw new LdapException(\sprintf('Could not remove values from entry "%s", attribute "%s": ', $entry->getDn(), $attribute).ldap_error($con), ldap_errno($con));
107107
}
108108

109109
return $this;
@@ -117,7 +117,7 @@ public function rename(Entry $entry, string $newRdn, bool $removeOldRdn = true)
117117
$con = $this->getConnectionResource();
118118

119119
if (!@ldap_rename($con, $entry->getDn(), $newRdn, '', $removeOldRdn)) {
120-
throw new LdapException(sprintf('Could not rename entry "%s" to "%s": ', $entry->getDn(), $newRdn).ldap_error($con), ldap_errno($con));
120+
throw new LdapException(\sprintf('Could not rename entry "%s" to "%s": ', $entry->getDn(), $newRdn).ldap_error($con), ldap_errno($con));
121121
}
122122

123123
return $this;
@@ -137,7 +137,7 @@ public function move(Entry $entry, string $newParent)
137137
$con = $this->getConnectionResource();
138138
// deleteOldRdn does not matter here, since the Rdn will not be changing in the move.
139139
if (!@ldap_rename($con, $entry->getDn(), $rdn, $newParent, true)) {
140-
throw new LdapException(sprintf('Could not move entry "%s" to "%s": ', $entry->getDn(), $newParent).ldap_error($con), ldap_errno($con));
140+
throw new LdapException(\sprintf('Could not move entry "%s" to "%s": ', $entry->getDn(), $newParent).ldap_error($con), ldap_errno($con));
141141
}
142142

143143
return $this;
@@ -172,7 +172,7 @@ public function applyOperations(string $dn, iterable $operations)
172172

173173
$con = $this->getConnectionResource();
174174
if (!@ldap_modify_batch($con, $dn, $operationsMapped)) {
175-
throw new UpdateOperationException(sprintf('Error executing UpdateOperation on "%s": ', $dn).ldap_error($con), ldap_errno($con));
175+
throw new UpdateOperationException(\sprintf('Error executing UpdateOperation on "%s": ', $dn).ldap_error($con), ldap_errno($con));
176176
}
177177

178178
return $this;
@@ -181,7 +181,7 @@ public function applyOperations(string $dn, iterable $operations)
181181
private function parseRdnFromEntry(Entry $entry): string
182182
{
183183
if (!preg_match('/(^[^,\\\\]*(?:\\\\.[^,\\\\]*)*),/', $entry->getDn(), $matches)) {
184-
throw new LdapException(sprintf('Entry "%s" malformed, could not parse RDN.', $entry->getDn()));
184+
throw new LdapException(\sprintf('Entry "%s" malformed, could not parse RDN.', $entry->getDn()));
185185
}
186186

187187
return $matches[1];

Adapter/ExtLdap/Query.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function execute(): CollectionInterface
7676
static::SCOPE_BASE => 'ldap_read',
7777
static::SCOPE_ONE => 'ldap_list',
7878
static::SCOPE_SUB => 'ldap_search',
79-
default => throw new LdapException(sprintf('Could not search in scope "%s".', $this->options['scope'])),
79+
default => throw new LdapException(\sprintf('Could not search in scope "%s".', $this->options['scope'])),
8080
};
8181

8282
$itemsLeft = $maxItems = $this->options['maxItems'];
@@ -104,13 +104,13 @@ public function execute(): CollectionInterface
104104
if (false === $search) {
105105
$ldapError = '';
106106
if ($errno = ldap_errno($con)) {
107-
$ldapError = sprintf(' LDAP error was [%d] %s', $errno, ldap_error($con));
107+
$ldapError = \sprintf(' LDAP error was [%d] %s', $errno, ldap_error($con));
108108
}
109109
if ($pageControl) {
110110
$this->resetPagination();
111111
}
112112

113-
throw new LdapException(sprintf('Could not complete search with dn "%s", query "%s" and filters "%s".%s.', $this->dn, $this->query, implode(',', $this->options['filter']), $ldapError), $errno);
113+
throw new LdapException(\sprintf('Could not complete search with dn "%s", query "%s" and filters "%s".%s.', $this->dn, $this->query, implode(',', $this->options['filter']), $ldapError), $errno);
114114
}
115115

116116
$this->results[] = $search;

Adapter/ExtLdap/UpdateOperation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ class UpdateOperation
3535
public function __construct(int $operationType, string $attribute, ?array $values)
3636
{
3737
if (!\in_array($operationType, self::VALID_OPERATION_TYPES, true)) {
38-
throw new UpdateOperationException(sprintf('"%s" is not a valid modification type.', $operationType));
38+
throw new UpdateOperationException(\sprintf('"%s" is not a valid modification type.', $operationType));
3939
}
4040
if (\LDAP_MODIFY_BATCH_REMOVE_ALL === $operationType && null !== $values) {
41-
throw new UpdateOperationException(sprintf('$values must be null for LDAP_MODIFY_BATCH_REMOVE_ALL operation, "%s" given.', get_debug_type($values)));
41+
throw new UpdateOperationException(\sprintf('$values must be null for LDAP_MODIFY_BATCH_REMOVE_ALL operation, "%s" given.', get_debug_type($values)));
4242
}
4343

4444
$this->operationType = $operationType;

Ldap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function escape(string $subject, string $ignore = '', int $flags = 0): st
5858
public static function create(string $adapter, array $config = []): static
5959
{
6060
if ('ext_ldap' !== $adapter) {
61-
throw new DriverNotFoundException(sprintf('Adapter "%s" not found. Only "ext_ldap" is supported at the moment.', $adapter));
61+
throw new DriverNotFoundException(\sprintf('Adapter "%s" not found. Only "ext_ldap" is supported at the moment.', $adapter));
6262
}
6363

6464
return new self(new Adapter($config));

Security/CheckLdapCredentialsListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function onCheckPassport(CheckPassportEvent $event)
5353
}
5454

5555
if (!$passport->hasBadge(PasswordCredentials::class)) {
56-
throw new \LogicException(sprintf('LDAP authentication requires a passport containing password credentials, authenticator "%s" does not fulfill these requirements.', $event->getAuthenticator()::class));
56+
throw new \LogicException(\sprintf('LDAP authentication requires a passport containing password credentials, authenticator "%s" does not fulfill these requirements.', $event->getAuthenticator()::class));
5757
}
5858

5959
/** @var PasswordCredentials $passwordCredentials */
@@ -63,7 +63,7 @@ public function onCheckPassport(CheckPassportEvent $event)
6363
}
6464

6565
if (!$this->ldapLocator->has($ldapBadge->getLdapServiceId())) {
66-
throw new \LogicException(sprintf('Cannot check credentials using the "%s" ldap service, as such service is not found. Did you maybe forget to add the "ldap" service tag to this service?', $ldapBadge->getLdapServiceId()));
66+
throw new \LogicException(\sprintf('Cannot check credentials using the "%s" ldap service, as such service is not found. Did you maybe forget to add the "ldap" service tag to this service?', $ldapBadge->getLdapServiceId()));
6767
}
6868

6969
$presentedPassword = $passwordCredentials->getPassword();

Security/LdapAuthenticator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function authenticate(Request $request): Passport
7070
*/
7171
public function createAuthenticatedToken(PassportInterface $passport, string $firewallName): TokenInterface
7272
{
73-
throw new \BadMethodCallException(sprintf('The "%s()" method cannot be called.', __METHOD__));
73+
throw new \BadMethodCallException(\sprintf('The "%s()" method cannot be called.', __METHOD__));
7474
}
7575

7676
public function createToken(Passport $passport, string $firewallName): TokenInterface
@@ -91,7 +91,7 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
9191
public function start(Request $request, ?AuthenticationException $authException = null): Response
9292
{
9393
if (!$this->authenticator instanceof AuthenticationEntryPointInterface) {
94-
throw new NotAnEntryPointException(sprintf('Decorated authenticator "%s" does not implement interface "%s".', get_debug_type($this->authenticator), AuthenticationEntryPointInterface::class));
94+
throw new NotAnEntryPointException(\sprintf('Decorated authenticator "%s" does not implement interface "%s".', get_debug_type($this->authenticator), AuthenticationEntryPointInterface::class));
9595
}
9696

9797
return $this->authenticator->start($request, $authException);

0 commit comments

Comments
 (0)