Skip to content

Commit 04f04d2

Browse files
authored
Merge pull request #17 from open-code-modeling/feature/switch-to-psalm
Switch from PHPStan to Psalm - Close #16
2 parents 629ca28 + e812584 commit 04f04d2

12 files changed

+215
-133
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "Check Coding Standards"
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
jobs:
8+
coding-standards:
9+
name: "Check Coding Standards"
10+
11+
runs-on: ${{ matrix.operating-system }}
12+
13+
strategy:
14+
matrix:
15+
dependencies:
16+
- "locked"
17+
php-version:
18+
- "7.4"
19+
operating-system:
20+
- "ubuntu-latest"
21+
22+
steps:
23+
- name: "Checkout"
24+
uses: "actions/checkout@v2"
25+
26+
- name: "Install PHP"
27+
uses: "shivammathur/setup-php@v2"
28+
with:
29+
coverage: "pcov"
30+
php-version: "${{ matrix.php-version }}"
31+
ini-values: memory_limit=-1
32+
tools: composer:v2
33+
34+
- name: "Cache dependencies"
35+
uses: "actions/cache@v2"
36+
with:
37+
path: |
38+
~/.composer/cache
39+
vendor
40+
key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
41+
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
42+
43+
- name: "Install lowest dependencies"
44+
if: ${{ matrix.dependencies == 'lowest' }}
45+
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest"
46+
47+
- name: "Install highest dependencies"
48+
if: ${{ matrix.dependencies == 'highest' }}
49+
run: "composer update --no-interaction --no-progress --no-suggest"
50+
51+
- name: "Install locked dependencies"
52+
if: ${{ matrix.dependencies == 'locked' }}
53+
run: "composer install --no-interaction --no-progress --no-suggest"
54+
55+
- name: "Coding Standard"
56+
run: "vendor/bin/php-cs-fixer fix -v --diff --dry-run"

.github/workflows/integration.yml

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

.github/workflows/phpunit.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: "PHPUnit tests"
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
jobs:
8+
phpunit:
9+
name: "PHPUnit tests"
10+
11+
runs-on: ${{ matrix.operating-system }}
12+
13+
strategy:
14+
matrix:
15+
dependencies:
16+
- "lowest"
17+
- "highest"
18+
- "locked"
19+
php-version:
20+
- "7.4"
21+
- "8.0"
22+
operating-system:
23+
- "ubuntu-latest"
24+
25+
steps:
26+
- name: "Checkout"
27+
uses: "actions/checkout@v2"
28+
29+
- name: "Install PHP"
30+
uses: "shivammathur/setup-php@v2"
31+
with:
32+
coverage: "pcov"
33+
php-version: "${{ matrix.php-version }}"
34+
ini-values: memory_limit=-1
35+
tools: composer:v2
36+
37+
- name: "Cache dependencies"
38+
uses: "actions/cache@v2"
39+
with:
40+
path: |
41+
~/.composer/cache
42+
vendor
43+
key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
44+
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
45+
46+
- name: "Install lowest dependencies"
47+
if: ${{ matrix.dependencies == 'lowest' }}
48+
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest"
49+
50+
- name: "Install highest dependencies"
51+
if: ${{ matrix.dependencies == 'highest' }}
52+
run: "composer update --no-interaction --no-progress --no-suggest"
53+
54+
- name: "Install locked dependencies"
55+
if: ${{ matrix.dependencies == 'locked' }}
56+
run: "composer install --no-interaction --no-progress --no-suggest"
57+
58+
- name: "Tests"
59+
run: "vendor/bin/phpunit"

.github/workflows/psalm.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "Static Analysis by Psalm"
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
jobs:
8+
static-analysis-psalm:
9+
name: "Static Analysis by Psalm"
10+
11+
runs-on: ${{ matrix.operating-system }}
12+
13+
strategy:
14+
matrix:
15+
dependencies:
16+
- "locked"
17+
php-version:
18+
- "8.0"
19+
operating-system:
20+
- "ubuntu-latest"
21+
22+
steps:
23+
- name: "Checkout"
24+
uses: "actions/checkout@v2"
25+
26+
- name: "Install PHP"
27+
uses: "shivammathur/setup-php@v2"
28+
with:
29+
coverage: "pcov"
30+
php-version: "${{ matrix.php-version }}"
31+
ini-values: memory_limit=-1
32+
tools: composer:v2, cs2pr
33+
34+
- name: "Cache dependencies"
35+
uses: "actions/cache@v2"
36+
with:
37+
path: |
38+
~/.composer/cache
39+
vendor
40+
key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
41+
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
42+
43+
- name: "Install lowest dependencies"
44+
if: ${{ matrix.dependencies == 'lowest' }}
45+
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest"
46+
47+
- name: "Install highest dependencies"
48+
if: ${{ matrix.dependencies == 'highest' }}
49+
run: "composer update --no-interaction --no-progress --no-suggest"
50+
51+
- name: "Install locked dependencies"
52+
if: ${{ matrix.dependencies == 'locked' }}
53+
run: "composer install --no-interaction --no-progress --no-suggest"
54+
55+
- name: "psalm"
56+
run: "vendor/bin/psalm --output-format=github --shepherd --stats"

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ app.env
33
.phpunit.result.cache
44
build/*
55
vendor/
6-
composer.lock
76
.idea
87
.php_cs.cache

composer.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,14 @@
3737
"open-code-modeling/php-code-ast": "^0.10.0 || 0.11.x-dev"
3838
},
3939
"require-dev": {
40-
"jangregor/phpstan-prophecy": "^0.8.0",
4140
"laminas/laminas-filter": "^2.9",
4241
"open-code-modeling/php-filter": "^0.1.1",
4342
"phpspec/prophecy-phpunit": "^2.0",
44-
"phpstan/phpstan": "^0.12.33",
45-
"phpstan/phpstan-strict-rules": "^0.12.4",
4643
"phpunit/phpunit": "^9.5.0",
47-
"prooph/php-cs-fixer-config": "^0.3",
44+
"prooph/php-cs-fixer-config": "^v0.4.0",
45+
"psalm/plugin-phpunit": "^0.15.0",
4846
"roave/security-advisories": "dev-master",
49-
"squizlabs/php_codesniffer": "^3.4"
47+
"vimeo/psalm": "^4.4"
5048
},
5149
"suggest": {
5250
"open-code-modeling/php-filter": "For pre-configured filters for proper class / method / property names etc."
@@ -60,8 +58,9 @@
6058
],
6159
"cs": "php-cs-fixer fix -v --diff --dry-run",
6260
"cs-fix": "php-cs-fixer fix -v --diff",
63-
"test": "vendor/bin/phpunit",
64-
"analyse": "php vendor/bin/phpstan.phar analyse --no-interaction"
61+
"test": "phpunit --colors=always",
62+
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
63+
"static-analysis": "psalm --shepherd --stats"
6564
},
6665
"config": {
6766
"sort-packages": true,

phpstan.neon.dist

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

psalm-baseline.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<files psalm-version="4.4.1@9fd7a7d885b3a216cff8dec9d8c21a132f275224">
3+
<file src="src/ValueObject/ArrayFactory.php">
4+
<InvalidNullableReturnType occurrences="1">
5+
<code>TypeDefinition</code>
6+
</InvalidNullableReturnType>
7+
<NullableReturnStatement occurrences="1">
8+
<code>$type</code>
9+
</NullableReturnStatement>
10+
<TypeDoesNotContainNull occurrences="2">
11+
<code>$typeSet === null</code>
12+
<code>$typeSet === null</code>
13+
</TypeDoesNotContainNull>
14+
</file>
15+
<file src="src/ValueObject/EnumFactory.php">
16+
<InvalidArgument occurrences="1"/>
17+
</file>
18+
</files>

psalm.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="4"
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+
errorBaseline="psalm-baseline.xml"
9+
>
10+
<projectFiles>
11+
<directory name="src" />
12+
<ignoreFiles>
13+
<directory name="vendor" />
14+
</ignoreFiles>
15+
</projectFiles>
16+
17+
<plugins>
18+
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
19+
</plugins>
20+
</psalm>

src/FileGenerator.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,12 @@ public function generateFiles(
5656
$classInfo = $this->classInfoList->classInfoForNamespace($previousNamespace);
5757
$path = $classInfo->getPath($classBuilder->getNamespace() . '\\' . $classBuilder->getName());
5858
}
59-
// @phpstan-ignore-next-line
6059
$filename = $classInfo->getFilenameFromPathAndName($path, $classBuilder->getName());
6160

6261
$nodeTraverser = new NodeTraverser();
6362
$classBuilder->injectVisitors($nodeTraverser, $parser);
6463

6564
$files[$filename] = $printer->prettyPrintFile(
66-
// @phpstan-ignore-next-line
6765
$nodeTraverser->traverse($currentFileAst($classBuilder, $classInfo))
6866
);
6967
}

src/ValueObject/ArrayFactory.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ private function determineType(string $name, TypeSet ...$typeSets): TypeDefiniti
208208
}
209209
$typeSet = \array_shift($typeSets);
210210

211-
// @phpstan-ignore-next-line
212211
if ($typeSet === null || $typeSet->count() !== 1) {
213212
throw new \RuntimeException('Can only handle one JSON type');
214213
}

0 commit comments

Comments
 (0)