wp-phpstan

Configure and run PHPStan with WordPress-specific typing for plugins and themes.

9|1|Updated Sep 10, 2022
One-click install
npx skills add https://github.com/WPdoaction/animal-shelter --skill wp-phpstan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: wp-phpstan
Source: https://github.com/WPdoaction/animal-shelter/tree/main/.claude/skills/wp-phpstan
Command: npx skills add https://github.com/WPdoaction/animal-shelter --skill wp-phpstan

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

WordPress projects often struggle with static analysis due to dynamic WP APIs and third‑party plugins. This skill guides configuring PHPStan for WordPress, establishing baselines, and applying WordPress‑specific typing to reduce false positives.

Core Features & Use Cases

  • PHPStan setup: create and maintain phpstan.neon and related configuration for WP plugins/themes.
  • Baseline management: generate and maintain a baseline to gradually fix legacy issues without blocking progress.
  • WP-specific typing: use WordPress stubs and annotations to improve type inferences for REST, hooks, and WP data structures.
  • Use Case: when working on a WordPress plugin, run PHPStan to catch type issues early and validate changes against the WP API surface.

Quick Start

Run the PHPStan inspection script to generate an initial analysis and baseline for your WordPress project: node skills/wp-phpstan/scripts/phpstan_inspect.mjs

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 reduce false positives?

Configuring PHPStan for a WordPress plugin involves creating a phpstan.neon file and installing WordPress stub packages. This setup applies WordPress-specific typing to REST APIs and hooks, reducing false positives from dynamic WP APIs.

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

A PHPStan baseline records existing static analysis errors so they do not block new development. You need a baseline for WordPress projects to gradually fix legacy type issues in plugins or themes without failing the current build.

Does PHPStan work with dynamic WordPress hooks and third-party plugin classes?

Yes, PHPStan works with dynamic WordPress hooks and third-party plugin classes when configured with WordPress stubs and specific annotations. This approach safely handles external classes and improves type inference for the WP API surface.

How do I generate an initial PHPStan baseline for an existing WordPress site?

You generate an initial PHPStan baseline for a WordPress site by running the inspection script. This script analyzes your project, creates the phpstan.neon configuration, and produces a baseline file to track legacy issues.

Do I need Composer to run PHPStan static analysis on WordPress themes?

Yes, you need a Composer-based PHPStan installation to run static analysis on WordPress themes. A Composer environment is required to manage the PHPStan dependency, install WordPress stub packages, and support the phpstan.neon configuration.