Skip to content

Commit 7d3b6f6

Browse files
tigitznicolas-grekas
authored andcommitted
Leverage arrow function syntax for closure
1 parent e7e746c commit 7d3b6f6

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

Adapter/AbstractConnection.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,9 @@ protected function configureOptions(OptionsResolver $resolver)
4040
'options' => [],
4141
]);
4242

43-
$resolver->setDefault('port', function (Options $options) {
44-
return 'ssl' === $options['encryption'] ? 636 : 389;
45-
});
43+
$resolver->setDefault('port', fn (Options $options) => 'ssl' === $options['encryption'] ? 636 : 389);
4644

47-
$resolver->setDefault('connection_string', function (Options $options) {
48-
return sprintf('ldap%s://%s:%s', 'ssl' === $options['encryption'] ? 's' : '', $options['host'], $options['port']);
49-
});
45+
$resolver->setDefault('connection_string', fn (Options $options) => sprintf('ldap%s://%s:%s', 'ssl' === $options['encryption'] ? 's' : '', $options['host'], $options['port']));
5046

5147
$resolver->setAllowedTypes('host', 'string');
5248
$resolver->setAllowedTypes('port', 'numeric');

Adapter/AbstractQuery.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ public function __construct(ConnectionInterface $connection, string $dn, string
4040
$resolver->setAllowedValues('deref', [static::DEREF_ALWAYS, static::DEREF_NEVER, static::DEREF_FINDING, static::DEREF_SEARCHING]);
4141
$resolver->setAllowedValues('scope', [static::SCOPE_BASE, static::SCOPE_ONE, static::SCOPE_SUB]);
4242

43-
$resolver->setNormalizer('filter', function (Options $options, $value) {
44-
return \is_array($value) ? $value : [$value];
45-
});
43+
$resolver->setNormalizer('filter', fn (Options $options, $value) => \is_array($value) ? $value : [$value]);
4644

4745
$this->connection = $connection;
4846
$this->dn = $dn;

Tests/Security/CheckLdapCredentialsListenerTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,13 @@ private function createEvent($password = 's3cr3t', $ldapBadge = null)
214214
{
215215
return new CheckPassportEvent(
216216
new TestAuthenticator(),
217-
new Passport(new UserBadge('Wouter', function () { return new InMemoryUser('Wouter', null, ['ROLE_USER']); }), new PasswordCredentials($password), [$ldapBadge ?? new LdapBadge('app.ldap')])
217+
new Passport(new UserBadge('Wouter', fn () => new InMemoryUser('Wouter', null, ['ROLE_USER'])), new PasswordCredentials($password), [$ldapBadge ?? new LdapBadge('app.ldap')])
218218
);
219219
}
220220

221221
private function createListener()
222222
{
223-
$ldapLocator = new class(['app.ldap' => function () {
224-
return $this->ldap;
225-
}]) implements ContainerInterface {
223+
$ldapLocator = new class(['app.ldap' => fn () => $this->ldap]) implements ContainerInterface {
226224
use ServiceLocatorTrait;
227225
};
228226

0 commit comments

Comments
 (0)