Skip to content

Commit

Permalink
Add workaround for PHP 8.3 displaying true instead of bool
Browse files Browse the repository at this point in the history
  • Loading branch information
cs278 committed Nov 6, 2023
1 parent 0a9769d commit d8703cc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/func_015.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ foreach (['', (object) [], '1234', 4.5, true, new \DateTimeImmutable(), new \Dat
} catch (TypeError $e) {
$message = $e->getMessage();

if (PHP_VERSION_ID >= 80300) {
// PHP 8.3+ outputs "true given" instead of "bool given".
$message = str_replace('true given', 'bool given', $message);
}

// Workaround exception message not including type in PHP 7 so the same test can be used for both.
if (PHP_MAJOR_VERSION === 7) {
$message = str_replace('N/A given', var_type($input).' given', $message);
Expand Down
5 changes: 5 additions & 0 deletions tests/func_016.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ foreach (['', (object) [], '1234', 4.5, true, new \DateTimeImmutable(), new \Dat
} catch (TypeError $e) {
$message = $e->getMessage();

if (PHP_VERSION_ID >= 80300) {
// PHP 8.3+ outputs "true given" instead of "bool given".
$message = str_replace('true given', 'bool given', $message);
}

// Workaround exception message not including type in PHP 7 so the same test can be used for both.
if (PHP_MAJOR_VERSION === 7) {
$message = str_replace('N/A given', var_type($input).' given', $message);
Expand Down
2 changes: 1 addition & 1 deletion tests/func_017.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ timecop_scale\(\)( expects parameter 1 to be|: Argument #1 \(\$scale\) must be o
timecop_scale\(\)( expects parameter 1 to be|: Argument #1 \(\$scale\) must be of type) (integer|int), (object|stdClass) given
timecop_scale\(\)( expects parameter 1 to be|: Argument #1 \(\$scale\) must be of type) (integer|int), string given
timecop_scale\(\)( expects parameter 1 to be|: Argument #1 \(\$scale\) must be of type) (integer|int), float given
timecop_scale\(\)( expects parameter 1 to be|: Argument #1 \(\$scale\) must be of type) (integer|int), (bool|boolean) given
timecop_scale\(\)( expects parameter 1 to be|: Argument #1 \(\$scale\) must be of type) (integer|int), (bool|boolean|true) given
bool\(false\)

0 comments on commit d8703cc

Please sign in to comment.