PHPackages                             humanmade/psalm-plugin-wordpress - 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. humanmade/psalm-plugin-wordpress

ActivePsalm-plugin[Utility &amp; Helpers](/categories/utility)

humanmade/psalm-plugin-wordpress
================================

WordPress stubs and plugin for Psalm static analysis.

3.1.2(2y ago)81459.7k—8%18[1 issues](https://github.com/psalm/psalm-plugin-wordpress/issues)[1 PRs](https://github.com/psalm/psalm-plugin-wordpress/pulls)20MITPHPCI passing

Since May 14Pushed 2mo ago22 watchersCompare

[ Source](https://github.com/psalm/psalm-plugin-wordpress)[ Packagist](https://packagist.org/packages/humanmade/psalm-plugin-wordpress)[ RSS](/packages/humanmade-psalm-plugin-wordpress/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (17)Used By (20)

WordPress plugin for Psalm
==========================

[](#wordpress-plugin-for-psalm)

[![Packagist](https://camo.githubusercontent.com/b98a818a515e630d20d3204343e65a21227c9b9cd15dc03be36df5a38b9097d3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68756d616e6d6164652f7073616c6d2d706c7567696e2d776f726470726573732e737667)](https://packagist.org/packages/humanmade/psalm-plugin-wordpress)[![Packagist](https://camo.githubusercontent.com/70427b727b3ef022eb00bfde49c188ea2e9e2a21355b351145b0bbbaf7e6654e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68756d616e6d6164652f7073616c6d2d706c7567696e2d776f726470726573732e737667)](https://packagist.org/packages/humanmade/psalm-plugin-wordpress)

Write type-safe WordPress code. This plugin supports WordPress 3 and newer (4, 5, 6, currently WP 6.7) and generally also works on WordPress trunk and beta/RC versions.

This [Psalm](https://psalm.dev/) plugin provides all WordPress and WP CLI stubs, so your WordPress based project or plugin will have type information for calls to WordPress APIs. This ensures your WordPress plugin or theme has less bugs!

- Stubs for all of WordPress Core
- Stubs for WP CLI
- Types for `apply_filters` return values.
- Types for `add_filter` / `add_action`
- Configuration options to use your own stubs

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

[](#installation)

Please refer to the [full Psalm documentation](https://psalm.dev/quickstart) for a more detailed guide on introducing Psalm into your project.

After Psalm is installed, install this package and enable the plugin:

```
composer require --dev humanmade/psalm-plugin-wordpress
./vendor/bin/psalm-plugin enable humanmade/psalm-plugin-wordpress
```

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

[](#configuration)

If you follow the installation instructions, the `psalm-plugin` command will add this plugin configuration to the `psalm.xml` configuration file.

```

```

Further details about plugins can be found on [Psalm's website](https://psalm.dev/docs/running_psalm/plugins/using_plugins/).

### Default WordPress stubs

[](#default-wordpress-stubs)

If you do not want to use the default WordPress class/method/function stubs, which are part of this plugin, `useDefaultStubs` must be set to `false`:

```

```

### Default WordPress hooks

[](#default-wordpress-hooks)

If you do not want to use the default WordPress hooks, which are part of this plugin, `useDefaultHooks` must be set to `false`:

```

```

### Custom hooks

[](#custom-hooks)

You can also provide custom hooks:

```

```

If a directory is provided, the plugin will search for the following files:

- `actions.json`
- `filters.json`
- `hooks.json`

The plugin expects a JSON representation of the hooks as per [wp-hooks/generator](https://github.com/wp-hooks/generator).

### Require passing all parameters

[](#require-passing-all-parameters)

If you want to get an error if `apply_filters` and `do_action` do not have the same number of parameters in all cases, `requireAllParams` must be set to `true`:

```

```

### WordPress paths

[](#wordpress-paths)

To help Psalm analyze your project you might need to define some of WordPress' default global constants such as those for paths.

```

```

The following example bootstrap file is for a Bedrock installation:

```
