Skip to content

Commit 405cc7e

Browse files
wouterjnicolas-grekas
authored andcommitted
Add missing PHPdoc return types
1 parent 9758632 commit 405cc7e

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

Adapter/EntryManagerInterface.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ interface EntryManagerInterface
2525
/**
2626
* Adds a new entry in the Ldap server.
2727
*
28+
* @return $this
29+
*
2830
* @throws NotBoundException
2931
* @throws LdapException
3032
*/
@@ -33,6 +35,8 @@ public function add(Entry $entry);
3335
/**
3436
* Updates an entry from the Ldap server.
3537
*
38+
* @return $this
39+
*
3640
* @throws NotBoundException
3741
* @throws LdapException
3842
*/
@@ -41,6 +45,8 @@ public function update(Entry $entry);
4145
/**
4246
* Moves an entry on the Ldap server.
4347
*
48+
* @return $this
49+
*
4450
* @throws NotBoundException
4551
* @throws LdapException
4652
*/
@@ -49,6 +55,8 @@ public function move(Entry $entry, string $newParent);
4955
/**
5056
* Renames an entry on the Ldap server.
5157
*
58+
* @return $this
59+
*
5260
* @throws NotBoundException
5361
* @throws LdapException
5462
*/
@@ -57,6 +65,8 @@ public function rename(Entry $entry, string $newRdn, bool $removeOldRdn = true);
5765
/**
5866
* Removes an entry from the Ldap server.
5967
*
68+
* @return $this
69+
*
6070
* @throws NotBoundException
6171
* @throws LdapException
6272
*/

Adapter/ExtLdap/EntryManager.php

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Ldap\Adapter\ExtLdap;
1313

14+
use LDAP\Connection as LDAPConnection;
1415
use Symfony\Component\Ldap\Adapter\EntryManagerInterface;
1516
use Symfony\Component\Ldap\Entry;
1617
use Symfony\Component\Ldap\Exception\LdapException;
@@ -30,6 +31,9 @@ public function __construct(Connection $connection)
3031
$this->connection = $connection;
3132
}
3233

34+
/**
35+
* @return $this
36+
*/
3337
public function add(Entry $entry)
3438
{
3539
$con = $this->getConnectionResource();
@@ -41,27 +45,39 @@ public function add(Entry $entry)
4145
return $this;
4246
}
4347

48+
/**
49+
* @return $this
50+
*/
4451
public function update(Entry $entry)
4552
{
4653
$con = $this->getConnectionResource();
4754

4855
if (!@ldap_modify($con, $entry->getDn(), $entry->getAttributes())) {
4956
throw new LdapException(sprintf('Could not update entry "%s": ', $entry->getDn()).ldap_error($con), ldap_errno($con));
5057
}
58+
59+
return $this;
5160
}
5261

62+
/**
63+
* @return $this
64+
*/
5365
public function remove(Entry $entry)
5466
{
5567
$con = $this->getConnectionResource();
5668

5769
if (!@ldap_delete($con, $entry->getDn())) {
5870
throw new LdapException(sprintf('Could not remove entry "%s": ', $entry->getDn()).ldap_error($con), ldap_errno($con));
5971
}
72+
73+
return $this;
6074
}
6175

6276
/**
6377
* Adds values to an entry's multi-valued attribute from the LDAP server.
6478
*
79+
* @return $this
80+
*
6581
* @throws NotBoundException
6682
* @throws LdapException
6783
*/
@@ -72,11 +88,15 @@ public function addAttributeValues(Entry $entry, string $attribute, array $value
7288
if (!@ldap_mod_add($con, $entry->getDn(), [$attribute => $values])) {
7389
throw new LdapException(sprintf('Could not add values to entry "%s", attribute "%s": ', $entry->getDn(), $attribute).ldap_error($con), ldap_errno($con));
7490
}
91+
92+
return $this;
7593
}
7694

7795
/**
7896
* Removes values from an entry's multi-valued attribute from the LDAP server.
7997
*
98+
* @return $this
99+
*
80100
* @throws NotBoundException
81101
* @throws LdapException
82102
*/
@@ -87,6 +107,8 @@ public function removeAttributeValues(Entry $entry, string $attribute, array $va
87107
if (!@ldap_mod_del($con, $entry->getDn(), [$attribute => $values])) {
88108
throw new LdapException(sprintf('Could not remove values from entry "%s", attribute "%s": ', $entry->getDn(), $attribute).ldap_error($con), ldap_errno($con));
89109
}
110+
111+
return $this;
90112
}
91113

92114
public function rename(Entry $entry, string $newRdn, bool $removeOldRdn = true)
@@ -96,11 +118,15 @@ public function rename(Entry $entry, string $newRdn, bool $removeOldRdn = true)
96118
if (!@ldap_rename($con, $entry->getDn(), $newRdn, '', $removeOldRdn)) {
97119
throw new LdapException(sprintf('Could not rename entry "%s" to "%s": ', $entry->getDn(), $newRdn).ldap_error($con), ldap_errno($con));
98120
}
121+
122+
return $this;
99123
}
100124

101125
/**
102126
* Moves an entry on the Ldap server.
103127
*
128+
* @return $this
129+
*
104130
* @throws NotBoundException if the connection has not been previously bound
105131
* @throws LdapException if an error is thrown during the rename operation
106132
*/
@@ -112,10 +138,14 @@ public function move(Entry $entry, string $newParent)
112138
if (!@ldap_rename($con, $entry->getDn(), $rdn, $newParent, true)) {
113139
throw new LdapException(sprintf('Could not move entry "%s" to "%s": ', $entry->getDn(), $newParent).ldap_error($con), ldap_errno($con));
114140
}
141+
142+
return $this;
115143
}
116144

117145
/**
118146
* Get the connection resource, but first check if the connection is bound.
147+
*
148+
* @return resource|LDAPConnection
119149
*/
120150
private function getConnectionResource()
121151
{
@@ -130,9 +160,11 @@ private function getConnectionResource()
130160
/**
131161
* @param iterable<int, UpdateOperation> $operations An array or iterable of UpdateOperation instances
132162
*
163+
* @return $this
164+
*
133165
* @throws UpdateOperationException in case of an error
134166
*/
135-
public function applyOperations(string $dn, iterable $operations): void
167+
public function applyOperations(string $dn, iterable $operations)
136168
{
137169
$operationsMapped = [];
138170
foreach ($operations as $modification) {
@@ -143,6 +175,8 @@ public function applyOperations(string $dn, iterable $operations): void
143175
if (!@ldap_modify_batch($con, $dn, $operationsMapped)) {
144176
throw new UpdateOperationException(sprintf('Error executing UpdateOperation on "%s": ', $dn).ldap_error($con), ldap_errno($con));
145177
}
178+
179+
return $this;
146180
}
147181

148182
private function parseRdnFromEntry(Entry $entry): string

0 commit comments

Comments
 (0)