diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml
new file mode 100644
index 0000000..c20e0c5
--- /dev/null
+++ b/.github/workflows/coding-standards.yml
@@ -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"
diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml
deleted file mode 100644
index bf0505a..0000000
--- a/.github/workflows/integration.yml
+++ /dev/null
@@ -1,110 +0,0 @@
-name: Testing JSON schema to PHP
-on: [push, pull_request]
-
-jobs:
- tests:
- strategy:
- fail-fast: false
- matrix:
- php-version:
- - "7.4"
- os: [ubuntu-latest]
- experimental: [false]
- include:
- - php-version: "8.0"
- os: ubuntu-latest
- experimental: true
- runs-on: ${{ matrix.os }}
- name: PHP ${{ matrix.php-version }} Test on ${{ matrix.os }}
- continue-on-error: ${{ matrix.experimental }}
- steps:
- - name: "Checkout"
- uses: actions/checkout@v2
-
- - name: "Install PHP"
- uses: shivammathur/setup-php@v2
- with:
- php-version: "${{ matrix.php-version }}"
- coverage: xdebug
-
- - name: Get composer cache directory
- id: composercache
- run: echo "::set-output name=dir::$(composer config cache-files-dir)"
-
- - name: Cache composer dependencies
- uses: actions/cache@v2
- with:
- path: ${{ steps.composercache.outputs.dir }}
- # Use composer.json for key, if composer.lock is not committed.
- # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
- key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
- restore-keys: ${{ runner.os }}-composer-
-
- - name: Install Composer dependencies
- run: |
- composer install --no-progress --prefer-dist --optimize-autoloader
-
- - name: Run Tests
- run: php vendor/bin/phpunit --coverage-text
-
- coding-standard:
- name: Coding Standard
- runs-on: ubuntu-latest
- steps:
- - name: Checkout
- uses: actions/checkout@v2
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: '7.4'
-
- - name: Get composer cache directory
- id: composercache
- run: echo "::set-output name=dir::$(composer config cache-files-dir)"
-
- - name: Cache composer dependencies
- uses: actions/cache@v2
- with:
- path: ${{ steps.composercache.outputs.dir }}
- # Use composer.json for key, if composer.lock is not committed.
- # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
- key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
- restore-keys: ${{ runner.os }}-composer-
-
- - name: Install dependencies
- run: composer install --no-progress --prefer-dist --optimize-autoloader
-
- - name: PHP CodeSniffer
- run: composer cs
-
- static-analysis:
- name: Static Analysis
- runs-on: ubuntu-latest
- steps:
- - name: Checkout
- uses: actions/checkout@v2
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: '7.4'
-
- - name: Get composer cache directory
- id: composercache
- run: echo "::set-output name=dir::$(composer config cache-files-dir)"
-
- - name: Cache composer dependencies
- uses: actions/cache@v2
- with:
- path: ${{ steps.composercache.outputs.dir }}
- # Use composer.json for key, if composer.lock is not committed.
- # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
- key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
- restore-keys: ${{ runner.os }}-composer-
-
- - name: Install dependencies
- run: composer install --no-progress --prefer-dist --optimize-autoloader
-
- - name: Static Analysis using PHPStan
- run: composer analyse
diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml
new file mode 100644
index 0000000..66e6482
--- /dev/null
+++ b/.github/workflows/phpunit.yml
@@ -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"
diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml
new file mode 100644
index 0000000..138ccdc
--- /dev/null
+++ b/.github/workflows/psalm.yml
@@ -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"
diff --git a/.gitignore b/.gitignore
index 3ac8cc7..99cc440 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,5 @@ app.env
.phpunit.result.cache
build/*
vendor/
-composer.lock
.idea
.php_cs.cache
diff --git a/composer.json b/composer.json
index 496282e..01749d4 100644
--- a/composer.json
+++ b/composer.json
@@ -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."
@@ -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,
diff --git a/phpstan.neon.dist b/phpstan.neon.dist
deleted file mode 100644
index 2b3ae99..0000000
--- a/phpstan.neon.dist
+++ /dev/null
@@ -1,5 +0,0 @@
-parameters:
- level: 6
- paths:
- - src/
- - tests/
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
new file mode 100644
index 0000000..0589735
--- /dev/null
+++ b/psalm-baseline.xml
@@ -0,0 +1,18 @@
+
+
+
+
+ TypeDefinition
+
+
+ $type
+
+
+ $typeSet === null
+ $typeSet === null
+
+
+
+
+
+
diff --git a/psalm.xml b/psalm.xml
new file mode 100644
index 0000000..0de3b49
--- /dev/null
+++ b/psalm.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/FileGenerator.php b/src/FileGenerator.php
index 1a7206e..6517107 100644
--- a/src/FileGenerator.php
+++ b/src/FileGenerator.php
@@ -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))
);
}
diff --git a/src/ValueObject/ArrayFactory.php b/src/ValueObject/ArrayFactory.php
index 6f8f715..9ed6be3 100644
--- a/src/ValueObject/ArrayFactory.php
+++ b/src/ValueObject/ArrayFactory.php
@@ -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');
}
diff --git a/tests/ClassGeneratorTest.php b/tests/ClassGeneratorTest.php
index 6026f14..7340cf4 100644
--- a/tests/ClassGeneratorTest.php
+++ b/tests/ClassGeneratorTest.php
@@ -96,19 +96,12 @@ public function it_generates_classes_of_objects(): void
return $classBuilder->getName() === $className;
};
};
- // @phpstan-ignore-next-line
$this->assertOrder($fileCollection->filter(($filter)('Order'))->current());
- // @phpstan-ignore-next-line
$this->assertBillingAddress($fileCollection->filter(($filter)('BillingAddress'))->current());
- // @phpstan-ignore-next-line->filter(($filter)('BillingAddress'))->current());
$this->assertShippingAddresses($fileCollection->filter(($filter)('ShippingAddresses'))->current());
- // @phpstan-ignore-next-line
$this->assertAddress($fileCollection->filter(($filter)('Address'))->current());
- // @phpstan-ignore-next-line
$this->assertStreetAddress($fileCollection->filter(($filter)('StreetAddress'))->current());
- // @phpstan-ignore-next-line
$this->assertCity($fileCollection->filter(($filter)('City'))->current());
- // @phpstan-ignore-next-line
$this->assertState($fileCollection->filter(($filter)('State'))->current());
}