Search by

rtcamp / wp-phpstan

rtcamparyanjasalaAnuragVasanwala

rtCamp PHPStan configuration and baseline for WordPress projects.

Package info

github.com/rtCamp/wp-phpstan

Homepage

Issues

pkg:composer/rtcamp/wp-phpstan

Statistics

Installs: 9 657

Dependents: 4

Suggesters: 0

Stars: 0

v2.0.0 2026-12-02 11:51 UTC

This package is auto-updated.

Last update: 2026-12-02 11:59:25 UTC


README

License: GPL-2.0-or-later PHP 8.2+ PHPStan 2.3+

rtCamp's shared PHPStan baseline for WordPress projects (rtcamp/wp-phpstan).

Developed in rtCamp/wp-tooling. The rtCamp/wp-phpstan repository is a read-only mirror, split from there on each release. Please open issues and pull requests in wp-tooling.

This package ships a single phpstan.neon.dist of rtCamp defaults (level 8, PHP 8.2–8.5, WordPress-aware rules) and pulls in szepeviktor/phpstan-wordpress, which loads the WordPress function stubs and dynamic return-type extensions PHPStan needs to understand core.

Install

composer require --dev rtcamp/wp-phpstan

This brings phpstan/phpstan and szepeviktor/phpstan-wordpress (and the WordPress stubs) along with it — you do not need to require them separately.

Use

Create a phpstan.neon.dist at your project root that includes this baseline, then point PHPStan at your code:

includes:
    - vendor/rtcamp/wp-phpstan/phpstan.neon.dist

parameters:
    # Every file and directory holding your own PHP. Dependencies resolve
    # through Composer's autoloader, so vendor/ needs no entry.
    paths:
        - my-plugin.php
        - inc/
    # Project-specific overrides and suppressions go here.

That single include is all you need. Run the analysis with:

vendor/bin/phpstan analyse

The WordPress extension must load exactly once. This baseline already includes szepeviktor/phpstan-wordpress, and loading it twice fails PHPStan. So: don't include its extension.neon in your own neon, and if you use phpstan/extension-installer, make it skip the package in composer.json:

"extra": {
    "phpstan/extension-installer": {
        "ignore": ["szepeviktor/phpstan-wordpress"]
    }
}

Overriding

Anything you set under parameters in your own neon overrides this baseline, so a project can change the level, add paths, or add ignoreErrors without forking it. Per-project suppressions belong in your own neon — keep this shared file clean.

License

GPL-2.0-or-later. See LICENSE.

rtCamp