Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bin/run-phpstan-tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

# Run the code style check only if a configuration file exists.
if [ -f "phpstan.dist.neon" ] || [ -f "phpstan.neon.dist" ] || [ -f "phpstan.neon" ]
then
vendor/bin/phpstan --memory-limit=2048M analyse "$@"
fi
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"php-parallel-lint/php-console-highlighter": "^1.0",
"php-parallel-lint/php-parallel-lint": "^1.3.1",
"phpcompatibility/php-compatibility": "dev-develop",
"phpstan/extension-installer": "^1.4.3",
"phpstan/phpstan": "^1.12.26",
"szepeviktor/phpstan-wordpress": "^v1.3.5",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is a new addition, it'd be better to start with 2.0?!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't, because we currently require PHP 7.2+, but v2 requires PHP 7.4+

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, ok. Makes sense.

"wp-cli/config-command": "^1 || ^2",
"wp-cli/core-command": "^1 || ^2",
"wp-cli/eval-command": "^1 || ^2",
Expand All @@ -28,7 +31,8 @@
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"johnpbloch/wordpress-core-installer": true
"johnpbloch/wordpress-core-installer": true,
"phpstan/extension-installer": true
},
"sort-packages": true,
"lock": false
Expand Down Expand Up @@ -63,19 +67,22 @@
"bin/run-linter-tests",
"bin/run-php-unit-tests",
"bin/run-phpcs-tests",
"bin/run-phpcbf-cleanup"
"bin/run-phpcbf-cleanup",
"bin/run-phpstan-tests"
],
"scripts": {
"behat": "run-behat-tests",
"behat-rerun": "rerun-behat-tests",
"lint": "run-linter-tests",
"phpcs": "run-phpcs-tests",
"phpcbf": "run-phpcbf-cleanup",
"phpstan": "run-phpstan-tests",
"phpunit": "run-php-unit-tests",
"prepare-tests": "install-package-tests",
"test": [
"@lint",
"@phpcs",
"@phpstan",
"@phpunit",
"@behat"
]
Expand Down
2 changes: 2 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
#############################################################################
-->

<exclude-pattern>tests/phpstan/scan-files.php</exclude-pattern>

<!-- This is a procedural stand-alone file that is never loaded in a WordPress context,
so this file does not have to comply with WP naming conventions. -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
Expand Down
19 changes: 19 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
parameters:
level: 6
paths:
- src
- tests
scanDirectories:
- vendor/wp-cli/wp-cli
- vendor/phpunit/php-code-coverage
- vendor/behat/behat
scanFiles:
- tests/phpstan/scan-files.php
treatPhpDocTypesAsCertain: false
dynamicConstantNames:
- WP_DEBUG
- WP_DEBUG_LOG
- WP_DEBUG_DISPLAY
ignoreErrors:
# Needs fixing in WP-CLI.
- message: '#Parameter \#1 \$cmd of function WP_CLI\\Utils\\esc_cmd expects array<string>#'
Loading