Skip to content

Commit

Permalink
instal php stan integration for TCMN
Browse files Browse the repository at this point in the history
  • Loading branch information
dpanta94 committed Jan 23, 2025
1 parent 03a6aba commit 2bc0d01
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 22 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 'PHPStan Tests'
on:
pull_request:
paths:
- '.github/**/*'
- '*.php'
- 'src/**.php'
jobs:
phpstan:
strategy:
matrix:
phpVersion: [
"7.4",
# ----------------------------------------
# Disabled until we get all of 7.4 passing
# "8.0",
# "8.1",
# "8.2",
# "8.3",
# ----------------------------------------
]
runs-on: ubuntu-20.04
steps:
- name: Checkout the repository
uses: actions/checkout@v4
# ------------------------------------------------------------------------------
# Set up PHP and run phpstan
# ------------------------------------------------------------------------------
- name: Configure PHP environment to run phpstan
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.phpVersion }}
# ------------------------------------------------------------------------------
# Override composer php version
# ------------------------------------------------------------------------------
- name: Set php version ${{ matrix.phpVersion }} in composer
run: composer config platform.php ${{ matrix.phpVersion }}
# ------------------------------------------------------------------------------
# Install dependencies - ignoring php requirements
# ------------------------------------------------------------------------------
- name: Install dependencies
run: composer i --ignore-platform-req=php+
# ------------------------------------------------------------------------------
# Run phpstan
# ------------------------------------------------------------------------------
- name: Run phpstan
run: ./vendor/bin/phpstan analyse -c phpstan.neon.dist --memory-limit=1024M --error-format=table
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
"wp-coding-standards/wpcs": "^3.0.0",
"automattic/jetpack-changelogger": "^4.2",
"codeception/module-rest": "^2.0",
"phpstan/phpstan": "^2.1",
"php-stubs/wordpress-stubs": "^6.7"
"php-stubs/wordpress-stubs": "^6.7",
"szepeviktor/phpstan-wordpress": "^1.1"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -93,6 +93,9 @@
"pup": [
"test -f ./bin/pup.phar || curl -o ./bin/pup.phar -L -C - https://github.com/stellarwp/pup/releases/download/1.3.7/pup.phar",
"@php bin/pup.phar"
],
"analyze": [
"phpstan analyse -c phpstan.neon.dist --memory-limit=1024M"
]
},
"extra": {
Expand Down
85 changes: 74 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions phpstan.neon

This file was deleted.

34 changes: 34 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Configuration for PHPStan
# https://phpstan.org/config-reference

includes:
# @see https://github.com/phpstan/phpstan-src/blob/master/conf/bleedingEdge.neon
- phar://phpstan.phar/conf/bleedingEdge.neon
# Include this extension
- vendor/szepeviktor/phpstan-wordpress/extension.neon

parameters:
parallel:
jobSize: 10
maximumNumberOfProcesses: 32
minimumNumberOfJobsPerProcess: 2
level: 5
inferPrivatePropertyTypeFromConstructor: true
reportUnmatchedIgnoredErrors: false
checkGenericClassInNonGenericObjectType: false
treatPhpDocTypesAsCertain: false

# Paths to be analyzed.
paths:
- %currentWorkingDirectory%/src

ignoreErrors:
# Uses func_get_args()
- '#^Function add_query_arg invoked with [123] parameters?, 0 required\.$#'
# Uses func_get_args()
- '#^Function apply_filters(_ref_array)? invoked with [34567] parameters, 2 required\.$#'
- '#^Constant WP_CONTENT_DIR not found\.$#'
- '#^Constant WP_CONTENT_URL not found\.$#'
- '#^Constant WPMU_PLUGIN_URL not found\.$#'
- '#^Constant WP_PLUGIN_DIR not found\.$#'
- '#^Constant WP_PLUGIN_URL not found\.$#'

0 comments on commit 2bc0d01

Please sign in to comment.