wp-phpstan

Configure PHPStan static analysis for WordPress plugin and theme repositories.

3|2|Updated Jun 9, 2021
One-click install
npx skills add https://github.com/artisanworkshop/Japanized-for-WooCommerce --skill wp-phpstan-artisanworkshop
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: wp-phpstan
Source: https://github.com/artisanworkshop/Japanized-for-WooCommerce/tree/main/.claude/skills/wp-phpstan
Command: npx skills add https://github.com/artisanworkshop/Japanized-for-WooCommerce --skill wp-phpstan-artisanworkshop

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

PHPStan can produce noisy or misleading results in WordPress projects because WordPress core APIs, hooks, REST request types, and third-party plugin classes are often resolved only at runtime. This skill helps you configure a WordPress-friendly PHPStan setup and fix type errors safely and precisely.

Core Features & Use Cases

  • WordPress-compatible PHPStan configuration: validate and tune phpstan.neon settings (paths, exclusions, ignoreErrors) for plugin/theme codebases.
  • Accurate WordPress typing guidance: add PHPDoc and phpstan-param annotations for REST requests, hook callbacks, database results, filters, and Action Scheduler args.
  • Third-party class handling: resolve unknown classes with targeted stubs where possible, or narrow ignoreErrors patterns when the dependency cannot be confirmed.

Quick Start

Use the wp-phpstan skill to inspect your existing PHPStan setup and recommend the safest way to run PHPStan and fix the highest-impact errors in your WordPress codebase.

Frequently Asked Questions about wp-phpstan

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

FAQPage Schema
How do I fix PHPStan false positives in WordPress plugins?

Fix PHPStan false positives in WordPress by adding WordPress-specific PHPDoc for REST requests, hook callbacks, database results, and filters, or by configuring targeted stub packages to resolve dynamic runtime APIs.

How do I configure phpstan.neon for a WordPress codebase?

Configure phpstan.neon for a WordPress codebase by validating paths, exclusions, and ignoreErrors settings, ensuring WordPress stub packages are present and referenced, and generating baseline files to manage existing errors.

Why does PHPStan report unknown classes for WordPress hooks and REST APIs?

PHPStan reports unknown classes for WordPress hooks and REST APIs because these core APIs, hook callbacks, and request types are often resolved only at runtime rather than statically, requiring specific PHPDoc annotations to resolve.

What is the best way to use a PHPStan baseline for WordPress migration?

The best way to use a PHPStan baseline for WordPress is as a temporary migration tool that tracks existing errors without masking new regressions, updating phpstan-baseline.neon while fixing errors with precise type corrections.

How do I add correct PHPStan types for Action Scheduler arguments?

Add correct PHPStan types for Action Scheduler arguments by applying WordPress-specific phpstan-param annotations to define precise argument shapes, preferring type corrections over broad ignoreErrors patterns to ensure reliable static analysis.

When should I use ignoreErrors instead of stubs for missing WordPress classes?

Use ignoreErrors instead of stubs for missing WordPress classes only when the third-party dependency cannot be confirmed, applying narrow ignoreErrors patterns rather than broad exclusions to maintain strict type checking where possible.