Skip to content

Commit 75a78cf

Browse files
authored
Merge pull request #2355 from WordPress/feature/ghactions-add-phpstan
Add PHPStan to QA checks
2 parents c24b906 + d6e47ab commit 75a78cf

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/.codecov.yml export-ignore
1010
/.phpcs.xml.dist export-ignore
1111
/CODE_OF_CONDUCT.md export-ignore
12+
/phpstan.neon.dist export-ignore
1213
/phpunit.xml.dist export-ignore
1314
/.github export-ignore
1415
/Tests export-ignore

.github/workflows/basic-qa.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,31 @@ jobs:
160160
- name: Fail the build on fixer conflicts and other errors
161161
if: ${{ steps.phpcbf.outputs.EXITCODE != 0 && steps.phpcbf.outputs.EXITCODE != 1 }}
162162
run: exit ${{ steps.phpcbf.outputs.EXITCODE }}
163+
164+
phpstan:
165+
name: "PHPStan"
166+
167+
runs-on: "ubuntu-latest"
168+
169+
steps:
170+
- name: Checkout code
171+
uses: actions/checkout@v3
172+
173+
- name: Install PHP
174+
uses: shivammathur/setup-php@v2
175+
with:
176+
php-version: '7.4'
177+
coverage: none
178+
tools: phpstan
179+
180+
# Install dependencies and handle caching in one go.
181+
# Dependencies need to be installed to make sure the PHPCS and PHPUnit classes are recognized.
182+
# @link https://github.com/marketplace/actions/install-composer-dependencies
183+
- name: Install Composer dependencies
184+
uses: "ramsey/composer-install@v2"
185+
with:
186+
# Bust the cache at least once a month - output format: YYYY-MM.
187+
custom-cache-suffix: $(date -u "+%Y-%m")
188+
189+
- name: Run PHPStan
190+
run: phpstan analyse

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ build/
44
phpunit.xml
55
phpcs.xml
66
.phpcs.xml
7+
phpstan.neon

phpstan.neon.dist

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
parameters:
2+
#phpVersion: 50400 # Needs to be 70100 or higher... sigh...
3+
level: 5
4+
paths:
5+
- WordPress
6+
bootstrapFiles:
7+
- Tests/bootstrap.php
8+
treatPhpDocTypesAsCertain: false
9+
10+
ignoreErrors:
11+
# Level 0
12+
- '#^Result of method \S+ \(void\) is used\.$#'
13+
14+
# Level 4
15+
- '#^Property \S+::\$\S+ \([^)]+\) in isset\(\) is not nullable\.$#'
16+
-
17+
count: 1
18+
message: '#^Result of && is always true\.$#'
19+
path: WordPress/Sniffs/Security/EscapeOutputSniff.php
20+
-
21+
count: 1
22+
message: '#^Strict comparison using === between true and false will always evaluate to false\.$#'
23+
path: WordPress/Sniffs/Utils/I18nTextDomainFixerSniff.php
24+
25+
# Level 5
26+
- '#^Parameter \#3 \$value of method \S+File::recordMetric\(\) expects string, \(?(float|int|bool)(\|(float|int|bool))*\)? given\.$#'

0 commit comments

Comments
 (0)