PHPStan - markhowellsmead/helpers GitHub Wiki

As used in a WordPress Theme.

Composer dependencies

{
	"require-dev": {
		"phpstan/phpstan": "^2.1",
		"szepeviktor/phpstan-wordpress": "^2.0",
		"phpstan/extension-installer": "^1.4",
		"php-stubs/wordpress-stubs": "^6.8",
		"php-stubs/wp-cli-stubs": "^2.12"
	},
	"config": {
		"allow-plugins": {
			"phpstan/extension-installer": true
		}
	},
	"scripts": {
		"phpstan": "phpstan analyse --memory-limit=2048M"
	}
}

phpstan.neon

parameters:
  phpVersion: 80324
  level: 5
  excludePaths:
    - vendor/*
    - node_modules/*
  scanDirectories:
    - ./
    - ./vendor
    - ../../plugins/
    - ../../themes/
    - ./dist/vendor # only if in the current project
  scanFiles:
        - %rootDir%/../../php-stubs/wordpress-stubs/wordpress-stubs.php
        - %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