| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Important
I build and maintain reliable web applications, with a focus on PHP, WordPress, and software quality.
If this package helps your team, feel free to reach out for consulting, development work, or sponsorship.
Static analysis for the WordPress ecosystem.
To use this extension, require it in Composer:
composer require --dev szepeviktor/phpstan-wordpressIf you also install phpstan/extension-installer then you're all set!
If you don't want to use phpstan/extension-installer, include extension.neon in your project's PHPStan config:
includes:
- vendor/szepeviktor/phpstan-wordpress/extension.neonNo additional setup is needed. 😃 Just configure PHPStan - for example - as shown below:
parameters:
level: 5
paths:
- plugin.php
- inc/For more details, visit the PHPStan Config Reference.
💡 Use the Composer autoloader or a custom autoloader!
Run the analysis with:
vendor/bin/phpstan analyzethen fix an error and GOTO 10!
You find further information in the examples directory, e.g. examples/phpstan.neon.dist
Refer to WooCommerce Stubs for specific guidance.
The WordPress ecosystem often uses PHPDoc docblocks in a non-standard way to document parameters passed to apply_filters(). Here’s an example:
/**
* Filters the page title when creating an HTML drop-down list of pages.
*
* @param string $title Page title.
* @param WP_Post $page Page data object.
*/
$title = apply_filters( 'list_pages', $title, $page );This extension reads these docblocks and instructs PHPStan to treat the filter’s return type as certain, based on the first @param tag. In this example, PHPStan interprets $title as string.
For best results, ensure the first @param tag in these docblocks is accurate.
WordPress uses conditional function and class definition to allow overrides. Use sed command to exclude function stubs when they are previously defined.
sed -i -e 's#function is_gd_image#function __is_gd_image#' vendor/php-stubs/wordpress-stubs/wordpress-stubs.php| Back | FazBrowse Home | New Git URL |