Skip to content

Update to PHP 8.2, Codeception 5 and static analysis #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update codebase to PHP 8.2
  • Loading branch information
TavoNiievez committed May 2, 2025
commit 70c2f6d1ee27b66134634f064d19a183ce6ac30d
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
php: [8.1, 8.2, 8.3, 8.4]
php: [8.2, 8.3, 8.4]

steps:
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
],
"homepage": "https://codeception.com/",
"require": {
"php": "^8.1",
"php": "^8.2",
"codeception/codeception": "*@dev",
"codeception/lib-asserts": "^2.2"
},
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A Codeception module containing various assertions.

## Requirements

* `PHP 8.1` or higher.
* `PHP 8.2` or higher.

## Installation

Expand Down
13 changes: 7 additions & 6 deletions src/Codeception/Module/Asserts.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Codeception\Module;

use Throwable;
use function get_debug_type;

/**
* Special module for using asserts in your tests.
*/
Expand Down Expand Up @@ -31,10 +34,8 @@ class Asserts extends AbstractAsserts
* $this->doSomethingBad();
* });
* ```
*
* @param \Throwable|string $throwable
*/
public function expectThrowable($throwable, callable $callback): void
public function expectThrowable(string|Throwable $throwable, callable $callback): void
{
if (is_object($throwable)) {
$class = get_class($throwable);
Expand All @@ -48,7 +49,7 @@ public function expectThrowable($throwable, callable $callback): void

try {
$callback();
} catch (\Throwable $t) {
} catch (Throwable $t) {
$this->checkThrowable($t, $class, $msg, $code);
return;
}
Expand All @@ -60,13 +61,13 @@ public function expectThrowable($throwable, callable $callback): void
* Check if the given throwable matches the expected data,
* fail (throws an exception) if it does not.
*/
protected function checkThrowable(\Throwable $throwable, string $expectedClass, ?string $expectedMsg, $expectedCode = null): void
protected function checkThrowable(Throwable $throwable, string $expectedClass, ?string $expectedMsg, int|null $expectedCode = null): void
{
if (!($throwable instanceof $expectedClass)) {
$this->fail(sprintf(
"Exception of class '%s' expected to be thrown, but class '%s' was caught",
$expectedClass,
get_class($throwable)
get_debug_type($throwable)
));
}

Expand Down