Skip to content

Commit ba0342a

Browse files
committed
Replace Psalm by PHPStan
1 parent f50521f commit ba0342a

File tree

7 files changed

+34
-23
lines changed

7 files changed

+34
-23
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@ jobs:
8383
if: matrix.coding-standards
8484
run: cat LICENSE |grep -E "\(c\) ([0-9]+\-)*`date +%G`"
8585

86-
- name: Run Psalm
86+
- name: Run PHPStan
8787
if: matrix.static-analysis
88-
run: php vendor/bin/psalm --stats --output-format=github
88+
run: php vendor/bin/phpstan --no-progress --error-format=github

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
},
2727
"require-dev": {
2828
"friendsofphp/php-cs-fixer": "^3.0",
29-
"phpunit/phpunit": "^8.4",
30-
"vimeo/psalm": "^4.23"
29+
"phpstan/phpstan": "^1.9",
30+
"phpunit/phpunit": "^8.4"
3131
},
3232
"config": {
3333
"sort-packages": true

phpstan-baseline.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#no value type specified in iterable type array#'
5+
path: tests/

phpstan.neon.dist

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
4+
5+
parameters:
6+
level: max
7+
paths:
8+
- src
9+
- tests

psalm.xml

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/ScalarValues.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
class ScalarValues
1717
{
18+
/**
19+
* @param array<mixed> $array
20+
*/
1821
public static function containsOnlyScalarValues(array $array): bool
1922
{
2023
foreach ($array as $child) {
@@ -26,6 +29,11 @@ public static function containsOnlyScalarValues(array $array): bool
2629
return true;
2730
}
2831

32+
/**
33+
* @param array<mixed> $array
34+
*
35+
* @return array<scalar>
36+
*/
2937
public static function filterScalarValues(array $array): array
3038
{
3139
return array_filter($array, fn ($child) => \is_scalar($child));

tests/ScalarValuesTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ScalarValuesTest extends TestCase
2121
/**
2222
* @dataProvider getTestContainsOnlyScalarValuesProdiver
2323
*/
24-
public function testContainsOnlyScalarValues($input, $expected): void
24+
public function testContainsOnlyScalarValues(array $input, bool $expected): void
2525
{
2626
$this->assertEquals(
2727
$expected,
@@ -49,12 +49,14 @@ public function getTestContainsOnlyScalarValuesProdiver(): array
4949
}
5050

5151
/**
52+
* @param mixed $input
53+
*
5254
* @dataProvider getNotArrayInputProdiver
5355
*/
5456
public function testContainsOnlyScalarValuesInputError($input): void
5557
{
5658
$this->expectException(\TypeError::class);
57-
ScalarValues::containsOnlyScalarValues($input);
59+
ScalarValues::containsOnlyScalarValues($input); // @phpstan-ignore-line
5860
}
5961

6062
public function getNotArrayInputProdiver(): array
@@ -71,7 +73,7 @@ public function getNotArrayInputProdiver(): array
7173
/**
7274
* @dataProvider getTestFilterScalarValuesProdiver
7375
*/
74-
public function testFilterScalarValues($input, $expected): void
76+
public function testFilterScalarValues(array $input, array $expected): void
7577
{
7678
$this->assertEquals(
7779
$expected,
@@ -99,11 +101,13 @@ public function getTestFilterScalarValuesProdiver(): array
99101
}
100102

101103
/**
104+
* @param mixed $input
105+
*
102106
* @dataProvider getNotArrayInputProdiver
103107
*/
104108
public function testFilterScalarValuesInputError($input): void
105109
{
106110
$this->expectException(\TypeError::class);
107-
ScalarValues::filterScalarValues($input);
111+
ScalarValues::filterScalarValues($input); // @phpstan-ignore-line
108112
}
109113
}

0 commit comments

Comments
 (0)