Skip to content

Commit

Permalink
adding psalm to workflow, fixes/updates throughout
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsizemore committed Apr 25, 2024
1 parent 8f089d3 commit 8c50219
Show file tree
Hide file tree
Showing 19 changed files with 1,679 additions and 61 deletions.
2 changes: 0 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
/composer.lock export-ignore
/CONTRIBUTING.md export-ignore
/phpstan.neon export-ignore
/phpstan-baseline.neon export-ignore
/phpunit.xml export-ignore
/psalm.xml export-ignore
/psalm-baseline.xml export-ignore
/renovate.json export-ignore
17 changes: 17 additions & 0 deletions .github/workflows/psalm-static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Psalm Static analysis

on: [push, pull_request]

jobs:
psalm:
name: Psalm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Psalm
uses: docker://vimeo/psalm-github-actions:latest
with:
args: --shepherd
composer_require_dev: true
security_analysis: false
2 changes: 1 addition & 1 deletion .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: actions/checkout@v4

- name: Psalm Security Scan
uses: psalm/psalm-github-security-scan@1.4.0
uses: psalm/psalm-github-security-scan@master

- name: Upload Security Analysis results to GitHub
uses: github/codeql-action/upload-sarif@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: [ '8.2', '8.3', '8.4' ]
php: [ '8.2', '8.3' ]
steps:
- uses: actions/checkout@v4
with:
Expand Down
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

* New dev dependencies: `phpstan/extension-installer` and `phpstan/phpstan-deprecation-rules`.
* New dev dependencies:
* `phpstan/extension-installer`
* `phpstan/phpstan-deprecation-rules`.
* `psalm/plugin-phpunit`
* `vimeo/psalm`
* Added issue templates and a pull request template.
* Added `CONTRIBUTING.md` for additional contributing information.
* Added `backward-compatibility.md` for my backward compatibility promise.
Expand All @@ -19,6 +23,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

* Updated dev dependencies.
* `Generator::generatePhpEnum()` can now throw a `RuntimeException` if `generateMapping` returns an empty array.

### Fixed

* Implemented fixes throughout based on Psalm.


## [2.0.0] - 2024-04-07
Expand Down
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ The configuration file can be found at `.php-cs-fixer.dist.php`, in the reposito
$ composer run-script cs:fix
```

#### Psalm

The configuration file can be found at `psalm.xml`, in the repository, for [Psalm](https://psalm.dev/). You can use Psalm to perform static analysis (with a focus on type checking):

```bash
$ composer run-script psalm
```

#### Unit tests (via PHPUnit)

The configuration file can be found at `phpunit.xml`, in the repository, for [PHPUnit](https://phpunit.de/index.html). You can run the test suite with:
Expand Down
5 changes: 4 additions & 1 deletion bin/generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
$mimeTypesContent = \file_get_contents($mimeTypes);
$mimeTypesCustomContent = \file_get_contents($mimeTypesCustom);

\assert($mimeTypesContent !== false);
\assert($mimeTypesCustomContent !== false);

$generator = new Generator($mimeTypesCustomContent . \PHP_EOL . $mimeTypesContent);
$mapping = $generator->generateMapping();
$generator->generateMapping();

file_put_contents($jsonDestination, $generator->generateJson(false));
file_put_contents($minJsonDestination, $generator->generateJson());
Expand Down
2 changes: 2 additions & 0 deletions bin/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

$mimeTypes = \file_get_contents($updateUrl);

\assert($mimeTypes !== false);

\file_put_contents($destinationFile, $mimeTypes);

echo \sprintf("Downloaded mime.types from '%s' and stored at '%s'", $updateUrl, $destinationFile) . \PHP_EOL;
Expand Down
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
"phpstan/phpstan-deprecation-rules": "^1.2",
"phpstan/phpstan-phpunit": "^1.4",
"phpstan/phpstan-strict-rules": "^1.6",
"phpunit/phpunit": "^11.1"
"phpunit/phpunit": "^11.1",
"psalm/plugin-phpunit": "^0.19.0",
"vimeo/psalm": "dev-master"
},
"suggest": {
"ext-mbstring": "For non-English (user) input parsing"
Expand Down Expand Up @@ -95,6 +97,9 @@
"cs:fix": "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php",
"cs:check": "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --dry-run --diff",
"phpstan": "vendor/bin/phpstan analyse -c phpstan.neon",
"psalm": "vendor/bin/psalm --no-diff --use-baseline=psalm-baseline.xml",
"psalm:ci": "vendor/bin/psalm --no-diff --long-progress --output-format=github --use-baseline=psalm-baseline.xml",
"psalm:stats": "vendor/bin/psalm --no-diff --stats --use-baseline=psalm-baseline.xml",
"test": "phpunit",
"update-types": "@php bin/update.php"
}
Expand Down

0 comments on commit 8c50219

Please sign in to comment.