Skip to content

Commit 2f53d49

Browse files
authored
Merge pull request #697 from DirectoryTree/laravel-11
Laravel 11 compatibility
2 parents 5ff91b6 + d0ba758 commit 2f53d49

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+162
-154
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
"psr/log": "*",
3737
"psr/simple-cache": "^1.0|^2.0|^3.0",
3838
"nesbot/carbon": "*",
39-
"illuminate/contracts": "^8.0|^9.0|^10.0",
40-
"illuminate/collections": "^8.0|^9.0|^10.0"
39+
"illuminate/contracts": "^8.0|^9.0|^10.0|^11.0",
40+
"illuminate/collections": "^8.0|^9.0|^10.0|^11.0"
4141
},
4242
"require-dev": {
4343
"phpunit/phpunit": "^9.0",

src/Auth/Events/Event.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ abstract class Event
2424
/**
2525
* Constructor.
2626
*/
27-
public function __construct(LdapInterface $connection, string $username = null, string $password = null)
27+
public function __construct(LdapInterface $connection, ?string $username = null, ?string $password = null)
2828
{
2929
$this->connection = $connection;
3030
$this->username = $username;

src/Auth/Guard.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function attempt(string $username, string $password, bool $stayBound = fa
7373
* @throws BindException
7474
* @throws \LdapRecord\ConnectionException
7575
*/
76-
public function bind(string $username = null, string $password = null): void
76+
public function bind(?string $username = null, ?string $password = null): void
7777
{
7878
$this->fireAuthEvent('binding', $username, $password);
7979

@@ -102,7 +102,7 @@ public function bind(string $username = null, string $password = null): void
102102
*
103103
* @throws \LdapRecord\ConnectionException
104104
*/
105-
protected function authenticate(string $username = null, string $password = null): bool
105+
protected function authenticate(?string $username = null, ?string $password = null): bool
106106
{
107107
if ($this->configuration->get('use_sasl') ?? false) {
108108
return $this->connection->saslBind(
@@ -139,15 +139,15 @@ public function getDispatcher(): ?DispatcherInterface
139139
/**
140140
* Set the event dispatcher instance.
141141
*/
142-
public function setDispatcher(DispatcherInterface $dispatcher = null): void
142+
public function setDispatcher(?DispatcherInterface $dispatcher = null): void
143143
{
144144
$this->events = $dispatcher;
145145
}
146146

147147
/**
148148
* Fire an authentication event.
149149
*/
150-
protected function fireAuthEvent(string $name, string $username = null, string $password = null): void
150+
protected function fireAuthEvent(string $name, ?string $username = null, ?string $password = null): void
151151
{
152152
if (isset($this->events)) {
153153
$event = implode('\\', [Events::class, ucfirst($name)]);

src/Connection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class Connection
7171
*
7272
* @throws ConfigurationException
7373
*/
74-
public function __construct(DomainConfiguration|array $config = [], LdapInterface $ldap = null)
74+
public function __construct(DomainConfiguration|array $config = [], ?LdapInterface $ldap = null)
7575
{
7676
$this->setConfiguration($config);
7777

@@ -207,7 +207,7 @@ public function setGuardResolver(Closure $callback): void
207207
* @throws Auth\BindException
208208
* @throws LdapRecordException
209209
*/
210-
public function connect(string $username = null, string $password = null): void
210+
public function connect(?string $username = null, ?string $password = null): void
211211
{
212212
$attempt = function () use ($username, $password) {
213213
$this->dispatch(new Events\Connecting($this));

src/ConnectionManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct($dispatcher = new Dispatcher())
5151
/**
5252
* Add a new connection.
5353
*/
54-
public function addConnection(Connection $connection, string $name = null): void
54+
public function addConnection(Connection $connection, ?string $name = null): void
5555
{
5656
$this->connections[$name ?? $this->default] = $connection;
5757

@@ -83,7 +83,7 @@ public function getConnections(): array
8383
*
8484
* @throws ContainerException If the given connection does not exist.
8585
*/
86-
public function getConnection(string $name = null): Connection
86+
public function getConnection(?string $name = null): Connection
8787
{
8888
if ($this->hasConnection($name = $name ?? $this->default)) {
8989
return $this->connections[$name];

src/Container.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static function getInstance(): static
2626
/**
2727
* Set the container instance.
2828
*/
29-
public static function setInstance(self $container = null): ?static
29+
public static function setInstance(?self $container = null): ?static
3030
{
3131
return static::$instance = $container;
3232
}

src/Events/Logger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Logger
1919
/**
2020
* Constructor.
2121
*/
22-
public function __construct(LoggerInterface $logger = null)
22+
public function __construct(?LoggerInterface $logger = null)
2323
{
2424
$this->logger = $logger;
2525
}

src/Ldap.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
class Ldap implements LdapInterface
88
{
9-
use HandlesConnection;
109
use DetectsErrors;
10+
use HandlesConnection;
1111

1212
/**
1313
* {@inheritdoc}
@@ -74,7 +74,7 @@ public function countEntries(mixed $result): int
7474
/**
7575
* {@inheritDoc}
7676
*/
77-
public function compare(string $dn, string $attribute, string $value, array $controls = null): bool|int
77+
public function compare(string $dn, string $attribute, string $value, ?array $controls = null): bool|int
7878
{
7979
return $this->executeFailableOperation(function () use ($dn, $attribute, $value, $controls) {
8080
return ldap_compare($this->connection, $dn, $attribute, $value, $controls);
@@ -192,7 +192,7 @@ public function close(): bool
192192
/**
193193
* {@inheritdoc}
194194
*/
195-
public function search(string $dn, string $filter, array $fields, bool $onlyAttributes = false, int $size = 0, int $time = 0, int $deref = LDAP_DEREF_NEVER, array $controls = null): mixed
195+
public function search(string $dn, string $filter, array $fields, bool $onlyAttributes = false, int $size = 0, int $time = 0, int $deref = LDAP_DEREF_NEVER, ?array $controls = null): mixed
196196
{
197197
return $this->executeFailableOperation(function () use (
198198
$dn,
@@ -211,7 +211,7 @@ public function search(string $dn, string $filter, array $fields, bool $onlyAttr
211211
/**
212212
* {@inheritdoc}
213213
*/
214-
public function list(string $dn, string $filter, array $fields, bool $onlyAttributes = false, int $size = 0, int $time = 0, int $deref = LDAP_DEREF_NEVER, array $controls = null): mixed
214+
public function list(string $dn, string $filter, array $fields, bool $onlyAttributes = false, int $size = 0, int $time = 0, int $deref = LDAP_DEREF_NEVER, ?array $controls = null): mixed
215215
{
216216
return $this->executeFailableOperation(function () use (
217217
$dn,
@@ -230,7 +230,7 @@ public function list(string $dn, string $filter, array $fields, bool $onlyAttrib
230230
/**
231231
* {@inheritdoc}
232232
*/
233-
public function read(string $dn, string $filter, array $fields, bool $onlyAttributes = false, int $size = 0, int $time = 0, int $deref = LDAP_DEREF_NEVER, array $controls = null): mixed
233+
public function read(string $dn, string $filter, array $fields, bool $onlyAttributes = false, int $size = 0, int $time = 0, int $deref = LDAP_DEREF_NEVER, ?array $controls = null): mixed
234234
{
235235
return $this->executeFailableOperation(function () use (
236236
$dn,
@@ -249,7 +249,7 @@ public function read(string $dn, string $filter, array $fields, bool $onlyAttrib
249249
/**
250250
* {@inheritdoc}
251251
*/
252-
public function parseResult(mixed $result, int &$errorCode = 0, string &$dn = null, string &$errorMessage = null, array &$referrals = null, array &$controls = null): LdapResultResponse|false
252+
public function parseResult(mixed $result, int &$errorCode = 0, ?string &$dn = null, ?string &$errorMessage = null, ?array &$referrals = null, ?array &$controls = null): LdapResultResponse|false
253253
{
254254
if (ldap_parse_result($this->connection, $result, $errorCode, $dn, $errorMessage, $referrals, $controls)) {
255255
return new LdapResultResponse(
@@ -267,7 +267,7 @@ public function parseResult(mixed $result, int &$errorCode = 0, string &$dn = nu
267267
/**
268268
* {@inheritdoc}
269269
*/
270-
public function bind(string $dn = null, string $password = null, array $controls = null): LdapResultResponse
270+
public function bind(?string $dn = null, ?string $password = null, ?array $controls = null): LdapResultResponse
271271
{
272272
/** @var \LDAP\Result $result */
273273
$result = $this->executeFailableOperation(function () use ($dn, $password, $controls) {
@@ -284,7 +284,7 @@ public function bind(string $dn = null, string $password = null, array $controls
284284
/**
285285
* {@inheritDoc}
286286
*/
287-
public function saslBind(string $dn = null, string $password = null, array $options = []): bool
287+
public function saslBind(?string $dn = null, ?string $password = null, array $options = []): bool
288288
{
289289
return $this->executeFailableOperation(function () use ($dn, $password, $options) {
290290
$options = array_merge([

src/LdapInterface.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public function countEntries(mixed $result): int;
201201
/**
202202
* Compare value of attribute found in entry specified with DN.
203203
*/
204-
public function compare(string $dn, string $attribute, string $value, array $controls = null): bool|int;
204+
public function compare(string $dn, string $attribute, string $value, ?array $controls = null): bool|int;
205205

206206
/**
207207
* Set an option on the current connection.
@@ -261,7 +261,7 @@ public function close(): bool;
261261
*
262262
* @return \LDAP\Result
263263
*/
264-
public function search(string $dn, string $filter, array $fields, bool $onlyAttributes = false, int $size = 0, int $time = 0, int $deref = LDAP_DEREF_NEVER, array $controls = null): mixed;
264+
public function search(string $dn, string $filter, array $fields, bool $onlyAttributes = false, int $size = 0, int $time = 0, int $deref = LDAP_DEREF_NEVER, ?array $controls = null): mixed;
265265

266266
/**
267267
* Performs a single level search on the current connection.
@@ -270,7 +270,7 @@ public function search(string $dn, string $filter, array $fields, bool $onlyAttr
270270
*
271271
* @return \LDAP\Result
272272
*/
273-
public function list(string $dn, string $filter, array $fields, bool $onlyAttributes = false, int $size = 0, int $time = 0, int $deref = LDAP_DEREF_NEVER, array $controls = null): mixed;
273+
public function list(string $dn, string $filter, array $fields, bool $onlyAttributes = false, int $size = 0, int $time = 0, int $deref = LDAP_DEREF_NEVER, ?array $controls = null): mixed;
274274

275275
/**
276276
* Reads an entry on the current connection.
@@ -279,7 +279,7 @@ public function list(string $dn, string $filter, array $fields, bool $onlyAttrib
279279
*
280280
* @return \LDAP\Result
281281
*/
282-
public function read(string $dn, string $filter, array $fields, bool $onlyAttributes = false, int $size = 0, int $time = 0, int $deref = LDAP_DEREF_NEVER, array $controls = null): mixed;
282+
public function read(string $dn, string $filter, array $fields, bool $onlyAttributes = false, int $size = 0, int $time = 0, int $deref = LDAP_DEREF_NEVER, ?array $controls = null): mixed;
283283

284284
/**
285285
* Extract information from an LDAP result.
@@ -288,7 +288,7 @@ public function read(string $dn, string $filter, array $fields, bool $onlyAttrib
288288
*
289289
* @param \LDAP\Result $result
290290
*/
291-
public function parseResult(mixed $result, int &$errorCode = 0, string &$dn = null, string &$errorMessage = null, array &$referrals = null, array &$controls = null): LdapResultResponse|false;
291+
public function parseResult(mixed $result, int &$errorCode = 0, ?string &$dn = null, ?string &$errorMessage = null, ?array &$referrals = null, ?array &$controls = null): LdapResultResponse|false;
292292

293293
/**
294294
* Bind to the LDAP directory.
@@ -297,7 +297,7 @@ public function parseResult(mixed $result, int &$errorCode = 0, string &$dn = nu
297297
*
298298
* @throws LdapRecordException
299299
*/
300-
public function bind(string $dn = null, string $password = null, array $controls = null): LdapResultResponse;
300+
public function bind(?string $dn = null, ?string $password = null, ?array $controls = null): LdapResultResponse;
301301

302302
/**
303303
* Bind to the LDAP directory using SASL.
@@ -312,7 +312,7 @@ public function bind(string $dn = null, string $password = null, array $controls
312312
* @see https://php.net/manual/en/function.ldap-sasl-bind.php
313313
* @see https://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml
314314
*/
315-
public function saslBind(string $dn = null, string $password = null, array $options = []): bool;
315+
public function saslBind(?string $dn = null, ?string $password = null, array $options = []): bool;
316316

317317
/**
318318
* Adds an entry to the current connection.

src/LdapRecordException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ class LdapRecordException extends Exception
1414
/**
1515
* Create a new Bind Exception with a detailed connection error.
1616
*/
17-
public static function withDetailedError(Exception $e, DetailedError $error = null): static
17+
public static function withDetailedError(Exception $e, ?DetailedError $error = null): static
1818
{
1919
return (new static($e->getMessage(), $e->getCode(), $e))->setDetailedError($error);
2020
}
2121

2222
/**
2323
* Set the detailed error.
2424
*/
25-
public function setDetailedError(DetailedError $error = null): static
25+
public function setDetailedError(?DetailedError $error = null): static
2626
{
2727
$this->detailedError = $error;
2828

0 commit comments

Comments
 (0)