Skip to content

Commit 5575488

Browse files
Merge pull request #9 from ostrolucky/psalm
Add psalm and PHP 8.3 to CI
2 parents 92f7f0d + 3967ecb commit 5575488

File tree

5 files changed

+35
-14
lines changed

5 files changed

+35
-14
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
- "8.0"
2020
- "8.1"
2121
- "8.2"
22+
- "8.3"
2223

2324
steps:
2425
- name: "Checkout"
@@ -52,5 +53,8 @@ jobs:
5253
- name: "PhpStan for tests"
5354
run: "vendor/bin/phpstan analyse --error-format=checkstyle tests --level=6 | cs2pr"
5455

56+
- name: "Psalm"
57+
run: "vendor/bin/psalm --output-format=github --php-version=${{ matrix.php-version }}"
58+
5559
- name: "PHPUnit Test"
5660
run: "vendor/bin/phpunit tests/BaseTest.php"

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
"require-dev": {
2727
"phpstan/phpstan": "^1.10",
2828
"symplify/easy-coding-standard": "^11.3",
29-
"phpunit/phpunit": "^9|^10"
29+
"phpunit/phpunit": "^9|^10",
30+
"vimeo/psalm": "^5.18",
31+
"psalm/plugin-phpunit": "^0.18"
3032
},
3133
"autoload": {
3234
"psr-4": {

psalm.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="1"
4+
resolveFromConfigFile="true"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8+
findUnusedCode="true"
9+
findUnusedBaselineEntry="true"
10+
>
11+
<projectFiles>
12+
<directory name="src" />
13+
<directory name="tests" />
14+
<ignoreFiles>
15+
<directory name="vendor" />
16+
</ignoreFiles>
17+
</projectFiles>
18+
<plugins>
19+
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
20+
</plugins>
21+
</psalm>

src/ConsecutiveParams.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212

1313
trait ConsecutiveParams
1414
{
15-
/** @return list<Callback> */
15+
/** @return \Generator<int, Callback> */
1616
public static function withConsecutive(array $firstCallArguments, array ...$consecutiveCallsArguments): iterable
1717
{
1818
foreach ($consecutiveCallsArguments as $consecutiveCallArguments) {
1919
TestCase::assertSameSize($firstCallArguments, $consecutiveCallArguments, 'Each expected arguments list need to have the same size.');
2020
}
2121

22-
$allConsecutiveCallsArguments = [$firstCallArguments, ...$consecutiveCallsArguments];
22+
$allConsecutiveCallsArguments = [$firstCallArguments, ...array_values($consecutiveCallsArguments)];
2323

2424
$numberOfArguments = count($firstCallArguments);
2525
$argumentList = [];
@@ -29,10 +29,11 @@ public static function withConsecutive(array $firstCallArguments, array ...$cons
2929

3030
$mockedMethodCall = 0;
3131
$callbackCall = 0;
32-
foreach ($argumentList as $index => $argument) {
32+
foreach ($argumentList as $argument) {
3333
yield new Callback(
34-
static function ($actualArgument) use ($argumentList, &$mockedMethodCall, &$callbackCall, $index, $numberOfArguments): bool {
35-
$expected = $argumentList[$index][$mockedMethodCall] ?? null;
34+
static function ($actualArgument) use (&$mockedMethodCall, &$callbackCall, $argument, $numberOfArguments): bool {
35+
/** @var mixed $expected */
36+
$expected = $argument[$mockedMethodCall] ?? null;
3637

3738
++$callbackCall;
3839
$mockedMethodCall = (int) ($callbackCall / $numberOfArguments);

tests/BaseTest.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,13 @@
99

1010
final class TestableClass
1111
{
12-
public function foo(object $testClass): void
12+
public function foo(InputInterface $testClass): void
1313
{
1414
$testClass->setSomething(1);
1515
$testClass->setSomething(2);
1616
}
1717
}
1818

19-
final class InputClass implements InputInterface
20-
{
21-
public function setSomething(int $i): void
22-
{
23-
}
24-
}
25-
2619
interface InputInterface
2720
{
2821
public function setSomething(int $i): void;

0 commit comments

Comments
 (0)