Skip to content

Commit e158167

Browse files
minor #48793 Leverage arrow function syntax for closure (tigitz)
This PR was merged into the 6.3 branch. Discussion ---------- Leverage arrow function syntax for closure | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #47658 <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | License | MIT | Doc PR | <!-- required for new features --> Rationale in the RFC [here](https://wiki.php.net/rfc/arrow_functions_v2#introduction) It's also notable that using arrow function syntax rather than the classic one has been enforced in the past by symfony core member: symfony/symfony#48069 (comment) So this PR would be consistent. Commits ------- f5802d3a2a Leverage arrow function syntax for closure
2 parents e9e19bd + 7d3b6f6 commit e158167

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)