Skip to content

Commit e7de373

Browse files
committed
Merge branch 'main' into add/phar-dump-autoload
2 parents bf9ea5e + 4865fa1 commit e7de373

File tree

12 files changed

+556
-192
lines changed

12 files changed

+556
-192
lines changed

bin/run-phpstan-tests

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
# Run the code style check only if a configuration file exists.
4+
if [ -f "phpstan.dist.neon" ] || [ -f "phpstan.neon.dist" ] || [ -f "phpstan.neon" ]
5+
then
6+
vendor/bin/phpstan --memory-limit=2048M analyse "$@"
7+
fi

composer.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@
99
"license": "MIT",
1010
"type": "phpcodesniffer-standard",
1111
"require": {
12-
"php": ">=5.6",
12+
"php": ">=7.2.24",
1313
"behat/behat": "^3.7",
1414
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || ^0.5 || ^0.6.2 || ^0.7.1 || ^1.0.0",
1515
"php-parallel-lint/php-console-highlighter": "^1.0",
1616
"php-parallel-lint/php-parallel-lint": "^1.3.1",
1717
"phpcompatibility/php-compatibility": "dev-develop",
18+
"phpstan/extension-installer": "^1.4.3",
19+
"phpstan/phpstan": "^1.12.26",
20+
"szepeviktor/phpstan-wordpress": "^v1.3.5",
1821
"wp-cli/config-command": "^1 || ^2",
1922
"wp-cli/core-command": "^1 || ^2",
2023
"wp-cli/eval-command": "^1 || ^2",
@@ -28,7 +31,8 @@
2831
"config": {
2932
"allow-plugins": {
3033
"dealerdirect/phpcodesniffer-composer-installer": true,
31-
"johnpbloch/wordpress-core-installer": true
34+
"johnpbloch/wordpress-core-installer": true,
35+
"phpstan/extension-installer": true
3236
},
3337
"sort-packages": true,
3438
"lock": false
@@ -63,19 +67,22 @@
6367
"bin/run-linter-tests",
6468
"bin/run-php-unit-tests",
6569
"bin/run-phpcs-tests",
66-
"bin/run-phpcbf-cleanup"
70+
"bin/run-phpcbf-cleanup",
71+
"bin/run-phpstan-tests"
6772
],
6873
"scripts": {
6974
"behat": "run-behat-tests",
7075
"behat-rerun": "rerun-behat-tests",
7176
"lint": "run-linter-tests",
7277
"phpcs": "run-phpcs-tests",
7378
"phpcbf": "run-phpcbf-cleanup",
79+
"phpstan": "run-phpstan-tests",
7480
"phpunit": "run-php-unit-tests",
7581
"prepare-tests": "install-package-tests",
7682
"test": [
7783
"@lint",
7884
"@phpcs",
85+
"@phpstan",
7986
"@phpunit",
8087
"@behat"
8188
]

phpcs.xml.dist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
<!-- For help understanding the `testVersion` configuration setting:
4343
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
44-
<config name="testVersion" value="5.6-"/>
44+
<config name="testVersion" value="7.2-"/>
4545

4646
<!-- Verify that everything in the global namespace is either namespaced or prefixed.
4747
See: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#naming-conventions-prefix-everything-in-the-global-namespace -->
@@ -59,6 +59,8 @@
5959
#############################################################################
6060
-->
6161

62+
<exclude-pattern>tests/phpstan/scan-files.php</exclude-pattern>
63+
6264
<!-- This is a procedural stand-alone file that is never loaded in a WordPress context,
6365
so this file does not have to comply with WP naming conventions. -->
6466
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">

phpstan.neon.dist

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
parameters:
2+
level: 6
3+
paths:
4+
- src
5+
- tests
6+
scanDirectories:
7+
- vendor/wp-cli/wp-cli
8+
- vendor/phpunit/php-code-coverage
9+
- vendor/behat/behat
10+
scanFiles:
11+
- tests/phpstan/scan-files.php
12+
treatPhpDocTypesAsCertain: false
13+
dynamicConstantNames:
14+
- WP_DEBUG
15+
- WP_DEBUG_LOG
16+
- WP_DEBUG_DISPLAY
17+
ignoreErrors:
18+
# Needs fixing in WP-CLI.
19+
- message: '#Parameter \#1 \$cmd of function WP_CLI\\Utils\\esc_cmd expects array<string>#'

0 commit comments

Comments
 (0)