Skip to content

Introduce PHPStan and adjust minimum requirements #320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
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
23 changes: 23 additions & 0 deletions .github/workflows/phpstan-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Run PHPStan

on: [push]

jobs:
run-phpstan:
name: Static Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 'latest'
coverage: none
tools: composer, cs2pr
- name: Install PHP dependencies
uses: ramsey/composer-install@v2
with:
composer-options: '--prefer-dist --no-scripts'
- name: PHPStan
run: composer phpstan
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ jobs:
strategy:
matrix:
include:
- php: '5.6'
wordpress: '4.7'
- php: '7.2'
wordpress: '5.1'
- php: '7.4'
wordpress: '5.9'
- php: '8.0'
Expand All @@ -16,7 +16,7 @@ jobs:
wordpress: '6.4'
- php: '8.3'
wordpress: 'latest'
- php: '8.3'
- php: '8.4'
wordpress: 'nightly'
steps:
- name: Checkout
Expand Down
14 changes: 11 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"forum": "https://wordpress.org/support/plugin/cachify"
},
"require": {
"php": ">=5.6",
"php": ">=7.2",
"composer/installers": "^v1|^v2"
},
"require-dev": {
Expand All @@ -32,7 +32,11 @@
"squizlabs/php_codesniffer": "^3.10",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"wp-coding-standards/wpcs": "^3.1",
"yoast/phpunit-polyfills": "^2.0"
"yoast/phpunit-polyfills": "^2.0",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^1.12",
"szepeviktor/phpstan-wordpress": "^1.0",
"php-stubs/wp-cli-stubs": "^2.11"
},
"scripts": {
"post-install-cmd": [
Expand Down Expand Up @@ -71,12 +75,16 @@
],
"coverage": [
"php -d xdebug.mode=coverage vendor/bin/phpunit --coverage-html tests/coverage"
],
"phpstan": [
"vendor/bin/phpstan analyse --memory-limit=1G"
]
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"composer/installers": true
"composer/installers": true,
"phpstan/extension-installer": true
}
}
}
4 changes: 2 additions & 2 deletions inc/class-cachify.php
Original file line number Diff line number Diff line change
Expand Up @@ -1073,8 +1073,8 @@ public static function register_publish_hooks() {
/**
* Removes the post type cache on post updates
*
* @param int $post_id Post ID.
* @param object $post Post object.
* @param int $post_id Post ID.
* @param ?object $post Post object.
*
* @since 2.0.3
*
Expand Down
15 changes: 15 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
parameters:
level: 1
paths:
- inc/
- cachify.php
scanFiles:
- %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-stubs.php
- %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-commands-stubs.php
#- %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-i18n-stubs.php
#- %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-tools-stubs.php
excludePaths:
- inc/cachify.settings.php
ignoreErrors:
- '/^Constant CACHIFY_BASE not found\.$/'
- '/^Constant DOMAIN_CURRENT_SITE not found\.$/'