wp-phpstan

Configures WordPress-specific PHPStan checks and typing patterns for plugins and themes.

Updated Sep 22, 2024
One-click install
npx skills add https://github.com/WordPressBugBounty/plugins-woocommerce-for-japan --skill wp-phpstan-wordpressbugbounty
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: wp-phpstan
Source: https://github.com/WordPressBugBounty/plugins-woocommerce-for-japan/tree/main/woocommerce-for-japan/.claude/skills/wp-phpstan
Command: npx skills add https://github.com/WordPressBugBounty/plugins-woocommerce-for-japan --skill wp-phpstan-wordpressbugbounty

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

PHPStan often produces noisy or misleading errors in WordPress/WooCommerce codebases due to dynamic runtime behavior, WordPress-specific APIs, and optional third-party integrations.

Core Features & Use Cases

  • WordPress-friendly PHPStan setup: Helps configure phpstan.neon/phpstan.neon.dist, scope analysis to first-party code, and manage ignoreErrors safely.
  • Static typing for WP patterns: Guides adding accurate PHPDoc for REST requests, hook callbacks, database result shapes, and Action Scheduler argument arrays.
  • Third-party class handling: Prefer stubs for WordPress/WooCommerce/ACF APIs, and only use targeted ignore patterns when dependencies are truly unavailable.

Quick Start

Run the inspection and then use the recommended Composer-based command to configure PHPStan and fix the most critical WordPress typing errors in your plugin or theme.

Frequently Asked Questions about wp-phpstan

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does PHPStan report false positives in my WordPress plugin code?

PHPStan reports false positives in WordPress plugin code due to dynamic runtime behavior and WordPress-specific APIs. Applying WordPress-specific configuration and accurate PHPDoc typing patterns resolves these misleading static analysis errors.

How do I configure PHPStan for a WordPress theme to avoid missing-type errors?

To configure PHPStan for a WordPress theme, set up phpstan.neon using Composer-based entrypoints, validate WordPress stub availability, and scope analysis to first-party code. Add narrow ignoreErrors and stubs for third-party integrations instead of blanket baselining.

What is the best way to fix PHPStan errors for WordPress REST API requests and hook callbacks?

The best way to fix PHPStan errors for WordPress REST API requests and hook callbacks is by adding accurate PHPDoc typing patterns. This provides static analysis with exact type expectations for dynamic WordPress core functions.

Can I use PHPStan with WooCommerce or ACF if they are optional dependencies?

You can use PHPStan with WooCommerce or ACF optional dependencies by managing third-party class discovery. Prefer adding stubs for these APIs and only use targeted ignore patterns when the dependencies are truly unavailable.

Should I use a baseline workflow when setting up PHPStan in a WordPress project?

You should avoid blanket baseline workflows when setting up PHPStan in a WordPress project. Instead, update the phpstan configuration with narrow ignoreErrors and added stubs to properly resolve false positives and missing-type issues.

How do I type Action Scheduler argument arrays for PHPStan in WooCommerce?

To type Action Scheduler argument arrays for PHPStan in WooCommerce, apply WordPress-specific PHPDoc typing patterns. This guides static analysis by defining the exact data shapes expected by scheduled action hooks.