Skip to content

Commit

Permalink
ci: Add PHPStan
Browse files Browse the repository at this point in the history
This should prevent whole swathes of bugs, especially once we increase the rule level.
  • Loading branch information
jtojnar committed Mar 19, 2023
1 parent 95a0e90 commit 1277b4c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
- name: Run unit tests
run: composer test

- name: Run static analysis
run: composer phpstan -- --error-format=github

test-compiled:
runs-on: ubuntu-latest

Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.19 || ^3.8",
"mf2/mf2": "^0.5.0",
"phpstan/phpstan": "^1.10",
"psr/simple-cache": "^1 || ^2 || ^3",
"yoast/phpunit-polyfills": "^1.0.1"
},
Expand Down Expand Up @@ -61,6 +62,7 @@
"sort-packages": true
},
"scripts": {
"phpstan": "phpstan analyze --memory-limit 512M",
"test": "phpunit"
}
}
19 changes: 19 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
parameters:
level: 2

paths:
- src/
- tests/

ignoreErrors:
# Not used since https://github.com/simplepie/simplepie/commit/b2eb0134d53921e75f0fa70b1cf901ed82b988b1 but cannot be removed due to BC.
- '(Constructor of class SimplePie\\Enclosure has an unused parameter \$javascript\.)'

# Testing legacy dynamic property usage.
- '(Access to an undefined property SimplePie.IRI::\$nonexistant_prop\.)'

# PHPStan stubs bug https://github.com/phpstan/phpstan/issues/8629
-
message: '(^Access to an undefined property XMLReader::\$\w+\.$)'
# Only occurs on PHP ≥ 8.2
reportUnmatched: false

0 comments on commit 1277b4c

Please sign in to comment.