wp-phpstan

Configures and troubleshoots PHPStan static analysis for WordPress projects.

1|Updated Apr 20, 2025
One-click install
npx skills add https://github.com/j7-dev/wp-power-checkout --skill wp-phpstan-j7-dev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: wp-phpstan
Source: https://github.com/j7-dev/wp-power-checkout/tree/main/.github/skills/wp-phpstan
Command: npx skills add https://github.com/j7-dev/wp-power-checkout --skill wp-phpstan-j7-dev

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill simplifies the setup, execution, and debugging of PHPStan static analysis specifically within WordPress projects, ensuring code quality and catching potential errors early.

Core Features & Use Cases

  • Configuration: Assists in setting up phpstan.neon and phpstan-baseline.neon files.
  • Error Resolution: Guides on fixing PHPStan errors using WordPress-specific PHPDoc annotations.
  • Third-Party Integration: Provides strategies for handling classes from external plugins and themes.
  • Use Case: You've just installed PHPStan for your WordPress plugin and need to configure it to ignore specific vendor classes while ensuring WordPress core functions are correctly typed.

Quick Start

Use the wp-phpstan skill to inspect the current PHPStan setup in the project.

Frequently Asked Questions about wp-phpstan

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

FAQPage Schema
How do I configure PHPStan for a WordPress plugin to ignore vendor classes?

To configure PHPStan for WordPress, you set up a `phpstan.neon` file to define analysis rules and a `phpstan-baseline.neon` to manage ignored vendor classes, ensuring WordPress core functions are typed correctly.

How do I fix PHPStan errors for WordPress hooks and REST APIs?

Fix PHPStan errors for WordPress hooks and REST APIs by using WordPress-specific PHPDoc annotations, which provide the strict typing rules necessary for static analysis to validate dynamic hook structures correctly.

Does PHPStan require Composer for static analysis in WordPress 6.9+?

Yes, running PHPStan static analysis in a WordPress 6.9+ environment requires a Composer-based installation to manage dependencies properly and ensure the static analysis tool functions correctly.

What is a PHPStan baseline and when do I need it for WordPress development?

A PHPStan baseline is a configuration file that records existing errors to ignore, and you need it for WordPress development when you want to introduce static analysis gradually without fixing all legacy code errors immediately.

Why does PHPStan report missing classes from third-party WordPress plugins?

PHPStan reports missing classes from third-party WordPress plugins because it cannot automatically discover external code structures, requiring specific configuration strategies to handle external theme and plugin classes properly.