Skip to content

Commit fa61795

Browse files
wouterjnicolas-grekas
authored andcommitted
[Components] Convert to native return types
1 parent 87e7906 commit fa61795

File tree

9 files changed

+25
-56
lines changed

9 files changed

+25
-56
lines changed

Adapter/AbstractConnection.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ public function __construct(array $config = [])
3030
$this->config = $resolver->resolve($config);
3131
}
3232

33-
/**
34-
* @return void
35-
*/
36-
protected function configureOptions(OptionsResolver $resolver)
33+
protected function configureOptions(OptionsResolver $resolver): void
3734
{
3835
$resolver->setDefaults([
3936
'host' => 'localhost',

Adapter/ConnectionInterface.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ public function isBound(): bool;
3131
* @throws AlreadyExistsException When the connection can't be created because of an LDAP_ALREADY_EXISTS error
3232
* @throws ConnectionTimeoutException When the connection can't be created because of an LDAP_TIMEOUT error
3333
* @throws InvalidCredentialsException When the connection can't be created because of an LDAP_INVALID_CREDENTIALS error
34-
*
35-
* @return void
3634
*/
37-
public function bind(string $dn = null, #[\SensitiveParameter] string $password = null);
35+
public function bind(string $dn = null, #[\SensitiveParameter] string $password = null): void;
3836
}

Adapter/EntryManagerInterface.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ interface EntryManagerInterface
3030
* @throws NotBoundException
3131
* @throws LdapException
3232
*/
33-
public function add(Entry $entry);
33+
public function add(Entry $entry): static;
3434

3535
/**
3636
* Updates an entry from the Ldap server.
@@ -40,7 +40,7 @@ public function add(Entry $entry);
4040
* @throws NotBoundException
4141
* @throws LdapException
4242
*/
43-
public function update(Entry $entry);
43+
public function update(Entry $entry): static;
4444

4545
/**
4646
* Moves an entry on the Ldap server.
@@ -50,7 +50,7 @@ public function update(Entry $entry);
5050
* @throws NotBoundException
5151
* @throws LdapException
5252
*/
53-
public function move(Entry $entry, string $newParent);
53+
public function move(Entry $entry, string $newParent): static;
5454

5555
/**
5656
* Renames an entry on the Ldap server.
@@ -60,7 +60,7 @@ public function move(Entry $entry, string $newParent);
6060
* @throws NotBoundException
6161
* @throws LdapException
6262
*/
63-
public function rename(Entry $entry, string $newRdn, bool $removeOldRdn = true);
63+
public function rename(Entry $entry, string $newRdn, bool $removeOldRdn = true): static;
6464

6565
/**
6666
* Removes an entry from the Ldap server.
@@ -70,5 +70,5 @@ public function rename(Entry $entry, string $newRdn, bool $removeOldRdn = true);
7070
* @throws NotBoundException
7171
* @throws LdapException
7272
*/
73-
public function remove(Entry $entry);
73+
public function remove(Entry $entry): static;
7474
}

Adapter/ExtLdap/Connection.php

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ public function __sleep(): array
4646
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
4747
}
4848

49-
/**
50-
* @return void
51-
*/
52-
public function __wakeup()
49+
public function __wakeup(): void
5350
{
5451
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
5552
}
@@ -66,10 +63,8 @@ public function isBound(): bool
6663

6764
/**
6865
* @param string $password WARNING: When the LDAP server allows unauthenticated binds, a blank $password will always be valid
69-
*
70-
* @return void
7166
*/
72-
public function bind(string $dn = null, #[\SensitiveParameter] string $password = null)
67+
public function bind(string $dn = null, #[\SensitiveParameter] string $password = null): void
7368
{
7469
if (!$this->connection) {
7570
$this->connect();
@@ -101,20 +96,14 @@ public function getResource()
10196
return $this->connection;
10297
}
10398

104-
/**
105-
* @return void
106-
*/
107-
public function setOption(string $name, array|string|int|bool $value)
99+
public function setOption(string $name, array|string|int|bool $value): void
108100
{
109101
if (!@ldap_set_option($this->connection, ConnectionOptions::getOption($name), $value)) {
110102
throw new LdapException(sprintf('Could not set value "%s" for option "%s".', $value, $name));
111103
}
112104
}
113105

114-
/**
115-
* @return array|string|int|null
116-
*/
117-
public function getOption(string $name)
106+
public function getOption(string $name): array|string|int|null
118107
{
119108
if (!@ldap_get_option($this->connection, ConnectionOptions::getOption($name), $ret)) {
120109
throw new LdapException(sprintf('Could not retrieve value for option "%s".', $name));
@@ -123,10 +112,7 @@ public function getOption(string $name)
123112
return $ret;
124113
}
125114

126-
/**
127-
* @return void
128-
*/
129-
protected function configureOptions(OptionsResolver $resolver)
115+
protected function configureOptions(OptionsResolver $resolver): void
130116
{
131117
parent::configureOptions($resolver);
132118

Adapter/ExtLdap/EntryManager.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(Connection $connection)
3434
/**
3535
* @return $this
3636
*/
37-
public function add(Entry $entry)
37+
public function add(Entry $entry): static
3838
{
3939
$con = $this->getConnectionResource();
4040

@@ -48,7 +48,7 @@ public function add(Entry $entry)
4848
/**
4949
* @return $this
5050
*/
51-
public function update(Entry $entry)
51+
public function update(Entry $entry): static
5252
{
5353
$con = $this->getConnectionResource();
5454

@@ -62,7 +62,7 @@ public function update(Entry $entry)
6262
/**
6363
* @return $this
6464
*/
65-
public function remove(Entry $entry)
65+
public function remove(Entry $entry): static
6666
{
6767
$con = $this->getConnectionResource();
6868

@@ -81,7 +81,7 @@ public function remove(Entry $entry)
8181
* @throws NotBoundException
8282
* @throws LdapException
8383
*/
84-
public function addAttributeValues(Entry $entry, string $attribute, array $values)
84+
public function addAttributeValues(Entry $entry, string $attribute, array $values): static
8585
{
8686
$con = $this->getConnectionResource();
8787

@@ -100,7 +100,7 @@ public function addAttributeValues(Entry $entry, string $attribute, array $value
100100
* @throws NotBoundException
101101
* @throws LdapException
102102
*/
103-
public function removeAttributeValues(Entry $entry, string $attribute, array $values)
103+
public function removeAttributeValues(Entry $entry, string $attribute, array $values): static
104104
{
105105
$con = $this->getConnectionResource();
106106

@@ -114,7 +114,7 @@ public function removeAttributeValues(Entry $entry, string $attribute, array $va
114114
/**
115115
* @return $this
116116
*/
117-
public function rename(Entry $entry, string $newRdn, bool $removeOldRdn = true)
117+
public function rename(Entry $entry, string $newRdn, bool $removeOldRdn = true): static
118118
{
119119
$con = $this->getConnectionResource();
120120

@@ -133,7 +133,7 @@ public function rename(Entry $entry, string $newRdn, bool $removeOldRdn = true)
133133
* @throws NotBoundException if the connection has not been previously bound
134134
* @throws LdapException if an error is thrown during the rename operation
135135
*/
136-
public function move(Entry $entry, string $newParent)
136+
public function move(Entry $entry, string $newParent): static
137137
{
138138
$con = $this->getConnectionResource();
139139
$rdn = $this->parseRdnFromEntry($entry);
@@ -167,7 +167,7 @@ private function getConnectionResource()
167167
*
168168
* @throws UpdateOperationException in case of an error
169169
*/
170-
public function applyOperations(string $dn, iterable $operations)
170+
public function applyOperations(string $dn, iterable $operations): static
171171
{
172172
$operationsMapped = [];
173173
foreach ($operations as $modification) {

Adapter/ExtLdap/Query.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ public function __sleep(): array
3636
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
3737
}
3838

39-
/**
40-
* @return void
41-
*/
42-
public function __wakeup()
39+
public function __wakeup(): void
4340
{
4441
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
4542
}

Entry.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,17 @@ public function getAttributes(): array
9696

9797
/**
9898
* Sets a value for the given attribute.
99-
*
100-
* @return void
10199
*/
102-
public function setAttribute(string $name, array $value)
100+
public function setAttribute(string $name, array $value): void
103101
{
104102
$this->attributes[$name] = $value;
105103
$this->lowerMap[strtolower($name)] = $name;
106104
}
107105

108106
/**
109107
* Removes a given attribute.
110-
*
111-
* @return void
112108
*/
113-
public function removeAttribute(string $name)
109+
public function removeAttribute(string $name): void
114110
{
115111
unset($this->attributes[$name]);
116112
unset($this->lowerMap[strtolower($name)]);

LdapInterface.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ interface LdapInterface
2929
* Return a connection bound to the ldap.
3030
*
3131
* @throws ConnectionException if dn / password could not be bound
32-
*
33-
* @return void
3432
*/
35-
public function bind(string $dn = null, #[\SensitiveParameter] string $password = null);
33+
public function bind(string $dn = null, #[\SensitiveParameter] string $password = null): void;
3634

3735
/**
3836
* Queries a ldap server for entries matching the given criteria.

Security/CheckLdapCredentialsListener.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ public function __construct(ContainerInterface $ldapLocator)
3636
$this->ldapLocator = $ldapLocator;
3737
}
3838

39-
/**
40-
* @return void
41-
*/
42-
public function onCheckPassport(CheckPassportEvent $event)
39+
public function onCheckPassport(CheckPassportEvent $event): void
4340
{
4441
$passport = $event->getPassport();
4542
if (!$passport->hasBadge(LdapBadge::class)) {

0 commit comments

Comments
 (0)