Skip to content

Switch from PHPStan to Psalm - Close #16 #17

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 1 commit into from
Jan 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
56 changes: 56 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "Check Coding Standards"

on:
pull_request:
push:

jobs:
coding-standards:
name: "Check Coding Standards"

runs-on: ${{ matrix.operating-system }}

strategy:
matrix:
dependencies:
- "locked"
php-version:
- "7.4"
operating-system:
- "ubuntu-latest"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
tools: composer:v2

- name: "Cache dependencies"
uses: "actions/cache@v2"
with:
path: |
~/.composer/cache
vendor
key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"

- name: "Install lowest dependencies"
if: ${{ matrix.dependencies == 'lowest' }}
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest"

- name: "Install highest dependencies"
if: ${{ matrix.dependencies == 'highest' }}
run: "composer update --no-interaction --no-progress --no-suggest"

- name: "Install locked dependencies"
if: ${{ matrix.dependencies == 'locked' }}
run: "composer install --no-interaction --no-progress --no-suggest"

- name: "Coding Standard"
run: "vendor/bin/php-cs-fixer fix -v --diff --dry-run"
110 changes: 0 additions & 110 deletions .github/workflows/integration.yml

This file was deleted.

59 changes: 59 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "PHPUnit tests"

on:
pull_request:
push:

jobs:
phpunit:
name: "PHPUnit tests"

runs-on: ${{ matrix.operating-system }}

strategy:
matrix:
dependencies:
- "lowest"
- "highest"
- "locked"
php-version:
- "7.4"
- "8.0"
operating-system:
- "ubuntu-latest"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
tools: composer:v2

- name: "Cache dependencies"
uses: "actions/cache@v2"
with:
path: |
~/.composer/cache
vendor
key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"

- name: "Install lowest dependencies"
if: ${{ matrix.dependencies == 'lowest' }}
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest"

- name: "Install highest dependencies"
if: ${{ matrix.dependencies == 'highest' }}
run: "composer update --no-interaction --no-progress --no-suggest"

- name: "Install locked dependencies"
if: ${{ matrix.dependencies == 'locked' }}
run: "composer install --no-interaction --no-progress --no-suggest"

- name: "Tests"
run: "vendor/bin/phpunit"
56 changes: 56 additions & 0 deletions .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "Static Analysis by Psalm"

on:
pull_request:
push:

jobs:
static-analysis-psalm:
name: "Static Analysis by Psalm"

runs-on: ${{ matrix.operating-system }}

strategy:
matrix:
dependencies:
- "locked"
php-version:
- "8.0"
operating-system:
- "ubuntu-latest"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
tools: composer:v2, cs2pr

- name: "Cache dependencies"
uses: "actions/cache@v2"
with:
path: |
~/.composer/cache
vendor
key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"

- name: "Install lowest dependencies"
if: ${{ matrix.dependencies == 'lowest' }}
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest"

- name: "Install highest dependencies"
if: ${{ matrix.dependencies == 'highest' }}
run: "composer update --no-interaction --no-progress --no-suggest"

- name: "Install locked dependencies"
if: ${{ matrix.dependencies == 'locked' }}
run: "composer install --no-interaction --no-progress --no-suggest"

- name: "psalm"
run: "vendor/bin/psalm --output-format=github --shepherd --stats"
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ app.env
.phpunit.result.cache
build/*
vendor/
composer.lock
.idea
.php_cs.cache
13 changes: 6 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,14 @@
"open-code-modeling/php-code-ast": "^0.10.0 || 0.11.x-dev"
},
"require-dev": {
"jangregor/phpstan-prophecy": "^0.8.0",
"laminas/laminas-filter": "^2.9",
"open-code-modeling/php-filter": "^0.1.1",
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/phpstan": "^0.12.33",
"phpstan/phpstan-strict-rules": "^0.12.4",
"phpunit/phpunit": "^9.5.0",
"prooph/php-cs-fixer-config": "^0.3",
"prooph/php-cs-fixer-config": "^v0.4.0",
"psalm/plugin-phpunit": "^0.15.0",
"roave/security-advisories": "dev-master",
"squizlabs/php_codesniffer": "^3.4"
"vimeo/psalm": "^4.4"
},
"suggest": {
"open-code-modeling/php-filter": "For pre-configured filters for proper class / method / property names etc."
Expand All @@ -60,8 +58,9 @@
],
"cs": "php-cs-fixer fix -v --diff --dry-run",
"cs-fix": "php-cs-fixer fix -v --diff",
"test": "vendor/bin/phpunit",
"analyse": "php vendor/bin/phpstan.phar analyse --no-interaction"
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
"static-analysis": "psalm --shepherd --stats"
},
"config": {
"sort-packages": true,
Expand Down
5 changes: 0 additions & 5 deletions phpstan.neon.dist

This file was deleted.

18 changes: 18 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.4.1@9fd7a7d885b3a216cff8dec9d8c21a132f275224">
<file src="src/ValueObject/ArrayFactory.php">
<InvalidNullableReturnType occurrences="1">
<code>TypeDefinition</code>
</InvalidNullableReturnType>
<NullableReturnStatement occurrences="1">
<code>$type</code>
</NullableReturnStatement>
<TypeDoesNotContainNull occurrences="2">
<code>$typeSet === null</code>
<code>$typeSet === null</code>
</TypeDoesNotContainNull>
</file>
<file src="src/ValueObject/EnumFactory.php">
<InvalidArgument occurrences="1"/>
</file>
</files>
20 changes: 20 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<psalm
errorLevel="4"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>

<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
</psalm>
2 changes: 0 additions & 2 deletions src/FileGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,12 @@ public function generateFiles(
$classInfo = $this->classInfoList->classInfoForNamespace($previousNamespace);
$path = $classInfo->getPath($classBuilder->getNamespace() . '\\' . $classBuilder->getName());
}
// @phpstan-ignore-next-line
$filename = $classInfo->getFilenameFromPathAndName($path, $classBuilder->getName());

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

$files[$filename] = $printer->prettyPrintFile(
// @phpstan-ignore-next-line
$nodeTraverser->traverse($currentFileAst($classBuilder, $classInfo))
);
}
Expand Down
1 change: 0 additions & 1 deletion src/ValueObject/ArrayFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ private function determineType(string $name, TypeSet ...$typeSets): TypeDefiniti
}
$typeSet = \array_shift($typeSets);

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