Skip to content

Commit f46e349

Browse files
committed
Add PHPStan and PHP Code Sniffer
1 parent 0a3fac6 commit f46e349

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

.github/workflows/main.yml

+20-13
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,27 @@ jobs:
1111
php: [8.2, 8.3, 8.4]
1212

1313
steps:
14-
- name: Checkout code
15-
uses: actions/checkout@v4
14+
- name: Checkout code
15+
uses: actions/checkout@v4
1616

17-
- name: Setup PHP
18-
uses: shivammathur/setup-php@v2
19-
with:
20-
php-version: ${{ matrix.php }}
21-
coverage: none
17+
- name: Setup PHP
18+
uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: ${{ matrix.php }}
21+
coverage: none
22+
tools: phpstan, phpcs
2223

23-
- name: Validate composer.json and composer.lock
24-
run: composer validate
24+
- name: Validate composer.json and composer.lock
25+
run: composer validate
2526

26-
- name: Install dependencies
27-
run: composer install --prefer-dist --no-progress --no-interaction --no-suggest
27+
- name: Install dependencies
28+
run: composer install --prefer-dist --no-progress --no-interaction --no-suggest
2829

29-
- name: Run test suite
30-
run: php vendor/bin/codecept run
30+
- name: Run PHPStan
31+
run: phpstan analyse src
32+
33+
- name: Run PHPCS
34+
run: phpcs --standard=PSR12 src
35+
36+
- name: Run test suite
37+
run: php vendor/bin/codecept run

src/Codeception/Module/Asserts.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Codeception\Module;
66

77
use Throwable;
8+
89
use function get_debug_type;
910

1011
/**
@@ -26,6 +27,7 @@ class Asserts extends AbstractAsserts
2627
* $this->doSomethingBad();
2728
* });
2829
* ```
30+
*
2931
* If you want to check message or throwable code, you can pass them with throwable instance:
3032
* ```php
3133
* <?php
@@ -40,7 +42,7 @@ public function expectThrowable(string|Throwable $throwable, callable $callback)
4042
if (is_object($throwable)) {
4143
$class = get_class($throwable);
4244
$msg = $throwable->getMessage();
43-
$code = $throwable->getCode();
45+
$code = (int) $throwable->getCode();
4446
} else {
4547
$class = $throwable;
4648
$msg = null;

0 commit comments

Comments
 (0)