Skip to content

Commit 70c2f6d

Browse files
committed
Update codebase to PHP 8.2
1 parent a499352 commit 70c2f6d

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88

99
strategy:
1010
matrix:
11-
php: [8.1, 8.2, 8.3, 8.4]
11+
php: [8.2, 8.3, 8.4]
1212

1313
steps:
1414
- name: Checkout code

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
],
2323
"homepage": "https://codeception.com/",
2424
"require": {
25-
"php": "^8.1",
25+
"php": "^8.2",
2626
"codeception/codeception": "*@dev",
2727
"codeception/lib-asserts": "^2.2"
2828
},

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A Codeception module containing various assertions.
99

1010
## Requirements
1111

12-
* `PHP 8.1` or higher.
12+
* `PHP 8.2` or higher.
1313

1414
## Installation
1515

src/Codeception/Module/Asserts.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace Codeception\Module;
66

7+
use Throwable;
8+
use function get_debug_type;
9+
710
/**
811
* Special module for using asserts in your tests.
912
*/
@@ -31,10 +34,8 @@ class Asserts extends AbstractAsserts
3134
* $this->doSomethingBad();
3235
* });
3336
* ```
34-
*
35-
* @param \Throwable|string $throwable
3637
*/
37-
public function expectThrowable($throwable, callable $callback): void
38+
public function expectThrowable(string|Throwable $throwable, callable $callback): void
3839
{
3940
if (is_object($throwable)) {
4041
$class = get_class($throwable);
@@ -48,7 +49,7 @@ public function expectThrowable($throwable, callable $callback): void
4849

4950
try {
5051
$callback();
51-
} catch (\Throwable $t) {
52+
} catch (Throwable $t) {
5253
$this->checkThrowable($t, $class, $msg, $code);
5354
return;
5455
}
@@ -60,13 +61,13 @@ public function expectThrowable($throwable, callable $callback): void
6061
* Check if the given throwable matches the expected data,
6162
* fail (throws an exception) if it does not.
6263
*/
63-
protected function checkThrowable(\Throwable $throwable, string $expectedClass, ?string $expectedMsg, $expectedCode = null): void
64+
protected function checkThrowable(Throwable $throwable, string $expectedClass, ?string $expectedMsg, int|null $expectedCode = null): void
6465
{
6566
if (!($throwable instanceof $expectedClass)) {
6667
$this->fail(sprintf(
6768
"Exception of class '%s' expected to be thrown, but class '%s' was caught",
6869
$expectedClass,
69-
get_class($throwable)
70+
get_debug_type($throwable)
7071
));
7172
}
7273

0 commit comments

Comments
 (0)