Skip to content

Commit

Permalink
Fix diagnostic message strict types
Browse files Browse the repository at this point in the history
  • Loading branch information
stevebauman committed Nov 1, 2023
1 parent 6561688 commit 6f5b7f2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/DetailedError.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ class DetailedError
* Constructor.
*/
public function __construct(
protected ?int $errorCode,
protected ?string $errorMessage,
protected int $errorCode,
protected string $errorMessage,
protected ?string $diagnosticMessage
) {
}

/**
* Returns the LDAP error code.
*/
public function getErrorCode(): ?int
public function getErrorCode(): int
{
return $this->errorCode;
}

/**
* Returns the LDAP error message.
*/
public function getErrorMessage(): ?string
public function getErrorMessage(): string
{
return $this->errorMessage;
}
Expand Down
14 changes: 7 additions & 7 deletions src/Testing/LdapExpectation.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ class LdapExpectation
protected bool $indefinitely = true;

/**
* Whether the expectation should return errors.
* Whether the expectation should return an error.
*/
protected bool $errors = false;

/**
* The error number to return.
* The error code to return.
*/
protected ?string $errorCode = null;
protected int $errorCode = 1;

/**
* The last error string to return.
* The error message to return.
*/
protected ?string $errorMessage = null;
protected string $errorMessage = 'Unknown error';

/**
* The diagnostic message string to return.
Expand Down Expand Up @@ -130,7 +130,7 @@ public function andReturnFalse(): static
/**
* The error message to return from the expectation.
*/
public function andReturnError(int $errorCode = 1, string $errorMessage = '', string $diagnosticMessage = ''): static
public function andReturnError(int $errorCode = 1, string $errorMessage = 'Unknown error', string $diagnosticMessage = null): static
{
$this->errors = true;

Expand Down Expand Up @@ -287,7 +287,7 @@ public function isReturningError(): bool
/**
* Get the expected error code.
*/
public function getExpectedErrorCode(): ?int
public function getExpectedErrorCode(): int
{
return $this->errorCode;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Testing/LdapFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ class LdapFake implements LdapInterface
/**
* The default fake last error string.
*/
protected string $lastError = '';
protected string $lastError = 'Unknown error';

/**
* The default fake diagnostic message string.
*/
protected string $diagnosticMessage = '';
protected ?string $diagnosticMessage = null;

/**
* Create a new expected operation.
Expand Down Expand Up @@ -152,7 +152,7 @@ public function shouldReturnErrorNumber(int $number = 1): static
/**
* Set the last error of a failed bind attempt.
*/
public function shouldReturnError(string $message = ''): static
public function shouldReturnError(string $message): static
{
$this->lastError = $message;

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

Expand All @@ -188,7 +188,7 @@ public function getLastError(): string
/**
* Return a fake diagnostic message.
*/
public function getDiagnosticMessage(): string
public function getDiagnosticMessage(): ?string
{
return $this->diagnosticMessage;
}
Expand Down

0 comments on commit 6f5b7f2

Please sign in to comment.