Skip to content

Added schema.json for PHPStan configuration file validation#14856

Draft
fadrian06 wants to merge 1 commit into
phpstan:2.2.xfrom
fadrian06:add-schema
Draft

Added schema.json for PHPStan configuration file validation#14856
fadrian06 wants to merge 1 commit into
phpstan:2.2.xfrom
fadrian06:add-schema

Conversation

@fadrian06

@fadrian06 fadrian06 commented Jun 21, 2026

Copy link
Copy Markdown

Add JSON schema for PhpStan configuration validation

This PR introduces a schema.json file to validate the structure of the PhpStan configuration file (*.neon).

Motivation

  • Improves developer experience by providing real-time validation and autocompletion in IDEs that support JSON schemas (e.g., PhpStorm, VSCode).
  • Reduces configuration errors by catching typos, invalid keys, or incorrect value types early.
  • Standardizes the expected configuration format across the project.

Changes

  • Added schema.json in the phpstan directory.
  • Schema covers all top-level keys: parameters and includes.
  • Supports common PhpStan options like level, paths, excludePaths, ignoreErrors, reportUnmatchedIgnoredErrors, checkMissingIterableValueType, etc.
  • Includes type definitions, default values, and descriptions for better clarity.

How to test

  1. Link the schema to your PhpStan config file (e.g., via # yaml-language-server: $schema=https://raw.githubusercontent.com/fadrian06/phpstan/refs/heads/add-schema/schema.json).
  2. Open the config file in a compatible IDE and verify that validation and autocompletion work as expected.
  3. Intentionally introduce an invalid key or value to confirm that the schema catches the error.

Checklist

  • Schema has been tested with a valid PhpStan configuration.
  • Schema catches common misconfigurations.
  • Documentation (if any) has been updated to reference the schema.

@ondrejmirtes

Copy link
Copy Markdown
Member

Please show me a screenshot how an IDE takes advantage of this schema file when editing project's phpstan.neon.

@fadrian06

Copy link
Copy Markdown
Author
image image image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants