Download the PHP package humanmade/psalm-plugin-wordpress without Composer
On this page you can find all versions of the php package humanmade/psalm-plugin-wordpress. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download humanmade/psalm-plugin-wordpress
More information about humanmade/psalm-plugin-wordpress
Files in humanmade/psalm-plugin-wordpress
Package psalm-plugin-wordpress
Short Description WordPress stubs and plugin for Psalm static analysis.
License MIT
Informations about the package psalm-plugin-wordpress
WordPress plugin for Psalm
Write type-safe WordPress code.
This Psalm 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!
- [x] Stubs for all of WordPress Core
- [x] Stubs for WP CLI
- [x] Types for
apply_filters
return values. - [x] Types for
add_filter
/add_action
- [x] Configuration options to use your own stubs
Installation
Please refer to the full Psalm documentation for a more detailed guide on introducing Psalm into your project.
After Psalm is installed, install this package and enable the plugin:
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.
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
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
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.
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
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:
You could require WordPress' default constants functions but that requires a lot more boilerplating to allow those functions to effectively define constants.
Interested in contributing?
Feel free to open a PR to fix bugs or add features!
In addition, have a look at Psalm's contribution guidelines.
Who made this
Created by @joehoyle, maintained by the Psalm community.
All versions of psalm-plugin-wordpress with dependencies
wp-hooks/wordpress-core Version ^1.3.0
php-stubs/wordpress-stubs Version ^6.0
php-stubs/wordpress-globals Version ^0.2.0
php-stubs/wp-cli-stubs Version ^2.7
vimeo/psalm Version ^5 || ^6