diff --git a/src/Testing/Constraints/CountInDatabase.php b/src/Testing/Constraints/CountInDatabase.php index 6e2c5b9a..3522d1e3 100644 --- a/src/Testing/Constraints/CountInDatabase.php +++ b/src/Testing/Constraints/CountInDatabase.php @@ -47,7 +47,7 @@ public function failureDescription(mixed $other): string ); } - public function toString(int $options = 0): string + public function toString(): string { return (new ReflectionClass($this))->name; } diff --git a/src/Testing/Constraints/HasInDatabase.php b/src/Testing/Constraints/HasInDatabase.php index ebfd64ef..16f92e13 100644 --- a/src/Testing/Constraints/HasInDatabase.php +++ b/src/Testing/Constraints/HasInDatabase.php @@ -11,6 +11,7 @@ use PHPUnit\Framework\Constraint\Constraint; use Throwable; +use function is_int; use function json_encode; use function sprintf; @@ -56,10 +57,18 @@ public function failureDescription(mixed $other): string } /** + * @param mixed|null $options + * * @throws JsonException */ - public function toString(int $options = 0): string + public function toString($options = null): string { - return json_encode($this->data, JSON_THROW_ON_ERROR | $options); + if (is_int($options)) { + $options |= JSON_THROW_ON_ERROR; + } else { + $options = JSON_THROW_ON_ERROR; + } + + return json_encode($this->data, $options | $options); } }