PHPackages                             johnbillion/wp-compat - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. johnbillion/wp-compat

ActivePhpstan-extension[Utility &amp; Helpers](/categories/utility)

johnbillion/wp-compat
=====================

PHPStan extension to help verify that your PHP code is compatible with a given version of WordPress

1.4.0(5mo ago)24115.0k—3.6%1[1 issues](https://github.com/johnbillion/wp-compat/issues)7MITPHPPHP &gt;= 7.4CI passing

Since Sep 3Pushed 5mo ago3 watchersCompare

[ Source](https://github.com/johnbillion/wp-compat)[ Packagist](https://packagist.org/packages/johnbillion/wp-compat)[ GitHub Sponsors](https://github.com/sponsors/johnbillion)[ RSS](/packages/johnbillion-wp-compat/feed)WikiDiscussions trunk Synced 1mo ago

READMEChangelog (10)Dependencies (13)Versions (14)Used By (7)

WPCompat
========

[](#wpcompat)

WPCompat is a PHPStan extension which helps verify that your PHP code is compatible with a given version of WordPress. You can use it to help ensure that your plugin or theme remains compatible with its "Requires at least" version.

It works by checking that any WordPress functions, class methods, actions, or filters that are in use were introduced prior to the minimum version of WordPress that your code supports. For example, if your plugin or theme supports WordPress 6.0 or higher but the `get_template_hierarchy()` function is used unconditionally, the extension will trigger an error because that function was only introduced in WordPress 6.1.

If your code is correctly guarded with a valid `function_exists()` or `method_exists()` check then an error won't be triggered.

Status
------

[](#status)

Version information was last updated for WordPress 6.9.

Requirements
------------

[](#requirements)

- PHPStan 2.0 or higher
- PHP 7.4 or higher (tested up to PHP 8.4)

Installation
------------

[](#installation)

```
composer require --dev johnbillion/wp-compat
```

If you also install [phpstan/extension-installer](https://github.com/phpstan/extension-installer) then you're all set!

 Manual installationIf you don't want to use `phpstan/extension-installer`, include extension.neon in your project's PHPStan config:

```
includes:
    - vendor/johnbillion/wp-compat/extension.neon
```

Configuration
-------------

[](#configuration)

### Themes

[](#themes)

If your style.css file contains a "Requires at least" header then wp-compat will read this header and use its value as the minimum supported WordPress version. There is no need for any additional config.

### Plugins

[](#plugins)

If the name of your main plugin file matches its parent directory -- for example `my-plugin/my-plugin.php` -- then wp-compat will read the "Requires at least" header from this file and use its value as the minimum supported WordPress version. There is no need for any additional config.

If your main plugin file is named otherwise or located elsewhere, you can specify its name in your PHPStan config file:

```
parameters:
    WPCompat:
        pluginFile: my-plugin.php
```

### Manual config

[](#manual-config)

Alternatively you can specify the minimum supported WordPress version number of your plugin or theme directly in your PHPStan config file. Note that this must be a string so it must be wrapped in quote marks.

```
parameters:
    WPCompat:
        requiresAtLeast: '6.0'
```

Any version number in `major.minor` or `major.minor.patch` format is accepted.

Ignoring errors
---------------

[](#ignoring-errors)

You can ignore an error from this extension by using its error identifier. For full information, see [the PHPStan guide to ignoring errors](https://phpstan.org/user-guide/ignoring-errors).

### Functions and methods

[](#functions-and-methods)

If your code is correctly guarded with a valid `function_exists()` or `method_exists()` check then an error won't be triggered.

```
// @phpstan-ignore WPCompat.functionNotAvailable
wp_foo();

// @phpstan-ignore WPCompat.methodNotAvailable
WP::foo();
```

### Actions and filters

[](#actions-and-filters)

There is no concept of checking the existence of an action or filter in WordPress in order to guard its usage. You can still ignore an error for an action or filter using its error identifier, which contains a sanitized version of the hook name.

```
// @phpstan-ignore WPCompat.filterNotAvailable.filtername
add_filter( 'filter_name', 'callback' );

// @phpstan-ignore WPCompat.actionNotAvailable.myactionname
add_action( 'my_action_name', 'callback' );
```

Technical details
-----------------

[](#technical-details)

This extension does not scan your project in order to detect the `@since` versions of WordPress functions, methods, and hooks. This information is included directly in the extension. This approach ensures that your code is always tested against the most up to date and most accurate `@since` documentation, regardless of the version of WordPress that your tests are using.

### Functions and methods

[](#functions-and-methods-1)

The [symbols.json](symbols.json) file contains a dictionary of all functions and methods in WordPress along with the version of WordPress in which they were introduced.

The file can be regenerated by running:

```
composer generate
```

The JSON schema for the file can be found in [schemas/symbols.json](schemas/symbols.json).

### Actions and filters

[](#actions-and-filters-1)

Information about actions and filters is provided by [the `wp-hooks/wordpress-core` package](https://github.com/wp-hooks/wordpress-core-hooks).

Sponsors
--------

[](#sponsors)

The time that I spend maintaining this extension and others is in part sponsored by:

[![Automattic](https://camo.githubusercontent.com/b772ed2bbb2f490e5cf6117b2cdfea077c3949279bf5c48dbbeaaf2215c925dd/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f6a6f686e62696c6c696f6e2f6a6f686e62696c6c696f6e406c61746573742f6173736574732f73706f6e736f72732f6175746f6d61747469632e737667)](https://automattic.com)

[![ServMask](https://camo.githubusercontent.com/9d9e5722a5e02afaed959c20a630979fb55fa9e64bf62b38ac61d78242c7d3c1/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f6a6f686e62696c6c696f6e2f6a6f686e62696c6c696f6e406c61746573742f6173736574732f73706f6e736f72732f736572766d61736b2e737667)](https://servmask.com)

Plus all my kind sponsors on GitHub:

[![Sponsors](https://camo.githubusercontent.com/f21a9d0b4d63cceec70d4ceda15b47d46f71bd0a64d2932a05f83d9dd529910f/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f6a6f686e62696c6c696f6e2f6a6f686e62696c6c696f6e406c61746573742f73706f6e736f72732e737667)](https://github.com/sponsors/johnbillion)

[Click here to find out about supporting my open source tools and plugins](https://github.com/sponsors/johnbillion).

License
-------

[](#license)

MIT

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance70

Regular maintenance activity

Popularity42

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~37 days

Recently: every ~92 days

Total

13

Last Release

165d ago

Major Versions

0.3.0 → 1.0.02024-11-25

0.3.1 → 1.1.02024-11-30

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/208434?v=4)[John Blackbourn](/maintainers/johnbillion)[@johnbillion](https://github.com/johnbillion)

---

Top Contributors

[![johnbillion](https://avatars.githubusercontent.com/u/208434?v=4)](https://github.com/johnbillion "johnbillion (114 commits)")[![staabm](https://avatars.githubusercontent.com/u/120441?v=4)](https://github.com/staabm "staabm (5 commits)")

---

Tags

phpstanphpstan-extensionwordpressPHPStanwordpress

###  Code Quality

TestsPHPUnit

Type Coverage Yes

### Embed Badge

![Health badge](/badges/johnbillion-wp-compat/health.svg)

```
[![Health](https://phpackages.com/badges/johnbillion-wp-compat/health.svg)](https://phpackages.com/packages/johnbillion-wp-compat)
```

###  Alternatives

[php-stubs/wordpress-stubs

WordPress function and class declaration stubs for static analysis.

19513.0M263](/packages/php-stubs-wordpress-stubs)[php-stubs/woocommerce-stubs

WooCommerce function and class declaration stubs for static analysis.

942.9M66](/packages/php-stubs-woocommerce-stubs)[ticketswap/phpstan-error-formatter

A minimalistic error formatter for PHPStan

87578.8k35](/packages/ticketswap-phpstan-error-formatter)[php-stubs/wp-cli-stubs

WP-CLI function and class declaration stubs for static analysis.

302.3M79](/packages/php-stubs-wp-cli-stubs)[timeweb/phpstan-enum

Enum class reflection extension for PHPStan

443.2M21](/packages/timeweb-phpstan-enum)[php-stubs/wordpress-globals

Global variables and global constants from WordPress core.

13799.0k17](/packages/php-stubs-wordpress-globals)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
