Skip to content

Commit 6f5b7f2

Browse files
committed
Fix diagnostic message strict types
1 parent 6561688 commit 6f5b7f2

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/DetailedError.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@ class DetailedError
88
* Constructor.
99
*/
1010
public function __construct(
11-
protected ?int $errorCode,
12-
protected ?string $errorMessage,
11+
protected int $errorCode,
12+
protected string $errorMessage,
1313
protected ?string $diagnosticMessage
1414
) {
1515
}
1616

1717
/**
1818
* Returns the LDAP error code.
1919
*/
20-
public function getErrorCode(): ?int
20+
public function getErrorCode(): int
2121
{
2222
return $this->errorCode;
2323
}
2424

2525
/**
2626
* Returns the LDAP error message.
2727
*/
28-
public function getErrorMessage(): ?string
28+
public function getErrorMessage(): string
2929
{
3030
return $this->errorMessage;
3131
}

src/Testing/LdapExpectation.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,19 @@ class LdapExpectation
5454
protected bool $indefinitely = true;
5555

5656
/**
57-
* Whether the expectation should return errors.
57+
* Whether the expectation should return an error.
5858
*/
5959
protected bool $errors = false;
6060

6161
/**
62-
* The error number to return.
62+
* The error code to return.
6363
*/
64-
protected ?string $errorCode = null;
64+
protected int $errorCode = 1;
6565

6666
/**
67-
* The last error string to return.
67+
* The error message to return.
6868
*/
69-
protected ?string $errorMessage = null;
69+
protected string $errorMessage = 'Unknown error';
7070

7171
/**
7272
* The diagnostic message string to return.
@@ -130,7 +130,7 @@ public function andReturnFalse(): static
130130
/**
131131
* The error message to return from the expectation.
132132
*/
133-
public function andReturnError(int $errorCode = 1, string $errorMessage = '', string $diagnosticMessage = ''): static
133+
public function andReturnError(int $errorCode = 1, string $errorMessage = 'Unknown error', string $diagnosticMessage = null): static
134134
{
135135
$this->errors = true;
136136

@@ -287,7 +287,7 @@ public function isReturningError(): bool
287287
/**
288288
* Get the expected error code.
289289
*/
290-
public function getExpectedErrorCode(): ?int
290+
public function getExpectedErrorCode(): int
291291
{
292292
return $this->errorCode;
293293
}

src/Testing/LdapFake.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ class LdapFake implements LdapInterface
3232
/**
3333
* The default fake last error string.
3434
*/
35-
protected string $lastError = '';
35+
protected string $lastError = 'Unknown error';
3636

3737
/**
3838
* The default fake diagnostic message string.
3939
*/
40-
protected string $diagnosticMessage = '';
40+
protected ?string $diagnosticMessage = null;
4141

4242
/**
4343
* Create a new expected operation.
@@ -152,7 +152,7 @@ public function shouldReturnErrorNumber(int $number = 1): static
152152
/**
153153
* Set the last error of a failed bind attempt.
154154
*/
155-
public function shouldReturnError(string $message = ''): static
155+
public function shouldReturnError(string $message): static
156156
{
157157
$this->lastError = $message;
158158

@@ -162,7 +162,7 @@ public function shouldReturnError(string $message = ''): static
162162
/**
163163
* Set the diagnostic message of a failed bind attempt.
164164
*/
165-
public function shouldReturnDiagnosticMessage(string $message = ''): static
165+
public function shouldReturnDiagnosticMessage(?string $message): static
166166
{
167167
$this->diagnosticMessage = $message;
168168

@@ -188,7 +188,7 @@ public function getLastError(): string
188188
/**
189189
* Return a fake diagnostic message.
190190
*/
191-
public function getDiagnosticMessage(): string
191+
public function getDiagnosticMessage(): ?string
192192
{
193193
return $this->diagnosticMessage;
194194
}

0 commit comments

Comments
 (0)