VOOZH about

URL: https://deepwiki.com/WordPress/mcp-adapter/8.2-phpstan-configuration

⇱ PHPStan Configuration | WordPress/mcp-adapter | DeepWiki


Loading...
Menu

Static Analysis Configuration

This document covers the PHPStan static analysis configuration used in the MCP Adapter plugin to ensure code quality and type safety. PHPStan performs static analysis on PHP code to detect bugs, type errors, and other issues before runtime.

For general code quality practices and standards, see Code Quality. For information about how static analysis integrates with automated testing, see CI/CD Pipeline.

Configuration Overview

The MCP Adapter plugin uses PHPStan at the highest strictness level to maintain code quality. The configuration is defined in phpstan.neon.dist and focuses on comprehensive type checking across the entire codebase.


Sources: phpstan.neon.dist1-36

Analysis Rules and Strictness

PHPStan is configured with maximum strictness (level 8) and comprehensive rule enforcement to catch potential issues early in development.

Core Analysis Rules

RuleSettingPurpose
level8Maximum strictness level for comprehensive analysis
treatPhpDocTypesAsCertainfalseTreat PHPDoc types as uncertain for stricter checking
inferPrivatePropertyTypeFromConstructortrueAutomatically infer private property types from constructor
checkExplicitMixedMissingReturntrueRequire explicit mixed type declarations
checkFunctionNameCasetrueVerify function name casing consistency
checkInternalClassCaseSensitivitytrueCheck internal PHP class name casing

Advanced Type Checking

The configuration enables several advanced type checking features:

  • Return Type Analysis: checkTooWideReturnTypesInProtectedAndPublicMethods ensures return types are as specific as possible
  • Loop Analysis: polluteScopeWithAlwaysIterableForeach and polluteScopeWithLoopInitialAssignments are disabled for cleaner scope analysis
  • Conditional Reporting: reportAlwaysTrueInLastCondition catches logical issues in conditional statements
  • Method Signatures: reportStaticMethodSignatures validates static method declarations

Sources: phpstan.neon.dist2-13

PHP Version Compatibility

The static analysis enforces compatibility across multiple PHP versions to ensure the plugin works in diverse WordPress environments.


The version range from PHP 7.4 to 8.4 ensures compatibility with current and future WordPress installations while maintaining support for legacy environments.

Sources: phpstan.neon.dist17-19

Path Configuration and Analysis Scope

PHPStan analyzes specific directories while excluding development and dependency files to focus on production code quality.

Bootstrap and Entry Points

The configuration specifies mcp-adapter.php as the bootstrap file, ensuring PHPStan understands the plugin's initialization context and autoloading setup.

Analysis Paths


Path Configuration Details

Path TypeDirectoriesAnalysis Level
Primary Analysissrc/Full type checking and rule enforcement
Scan Directories../abilities-apiSymbol discovery without full analysis
Excluded Pathstests/, vendor/, node_modulesNo analysis performed

Sources: phpstan.neon.dist20-31

Error Handling and Suppressions

The configuration includes selective error suppression for known issues that don't impact code quality.

Ignored Error Patterns

Currently, the configuration suppresses missingType.iterableValue errors which are noted as "too noisy" and planned for future restoration. This allows development to proceed while maintaining overall code quality standards.


This approach maintains strict analysis while avoiding noise from specific rule violations that are planned to be addressed systematically.

Sources: phpstan.neon.dist33-36

Integration with Development Workflow

PHPStan static analysis integrates with the broader development and quality assurance process to maintain code standards throughout the development lifecycle.

Development Tool Integration

The static analysis configuration works alongside other quality tools:

  • Composer Scripts: PHPStan runs as part of automated quality checks
  • CI/CD Pipeline: Analysis results block merges when errors are detected
  • Local Development: Developers can run analysis before committing changes
  • IDE Integration: Many editors support real-time PHPStan feedback

Configuration Management

The .dist file extension indicates this is a distribution template that can be customized locally while maintaining version control of the base configuration. Developers can create a local phpstan.neon file to override specific settings for their development environment.

Sources: phpstan.neon.dist1-36