Skip to content

docs: add PHPStan 2.x migration guide and baseline reduction strategy#9

Merged
CybotTM merged 2 commits intomainfrom
docs/phpstan-2-migration
Feb 22, 2026
Merged

docs: add PHPStan 2.x migration guide and baseline reduction strategy#9
CybotTM merged 2 commits intomainfrom
docs/phpstan-2-migration

Conversation

@CybotTM
Copy link
Copy Markdown
Member

@CybotTM CybotTM commented Feb 22, 2026

Summary

Adds two new sections to the PHPStan compliance reference:

  • Baseline Reduction Strategy — patterns for genuinely fixing PHPStan errors instead of using @phpstan-ignore suppressions (is_string/is_array guards, step-by-step JSON/YAML validation, return type covariance, type-specific parameters)
  • PHPStan 1.x to 2.x Migration — breaking changes table (config renames, new error identifiers, symplify/phpstan-rules 14.x dropped rules) and step-by-step migration checklist

Based on real-world experience upgrading render-guides (TYPO3-Documentation/render-guides) from PHPStan 1.x to 2.x, reducing baseline from 41 to 9 entries with zero @phpstan-ignore annotations.

Test plan

  • Content is valid markdown
  • Code examples are syntactically correct
  • Renders correctly in skill documentation

- PHPStan 1.x→2.x breaking changes (config renames, new error identifiers)
- Baseline reduction strategy: genuine code fixes over @phpstan-ignore
- Fix patterns for mixed types (is_string guards, step-by-step validation,
  return type covariance, type-specific parameters)
- Migration steps checklist
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @CybotTM, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the PHPStan compliance reference documentation by adding two crucial sections. The first provides a strategic approach to reducing PHPStan baselines through genuine code fixes, aiming to minimize the reliance on @phpstan-ignore annotations. The second offers a detailed migration guide for upgrading projects from PHPStan 1.x to 2.x, outlining breaking changes and a clear checklist to facilitate a smooth transition. These additions aim to improve code quality and streamline the upgrade process for PHP projects.

Highlights

  • Baseline Reduction Strategy: Added a new section detailing patterns for genuinely fixing PHPStan errors, emphasizing code fixes over suppressions. This includes strategies for handling mixed types using is_string()/is_array() guards, step-by-step validation for json_decode()/Yaml::parse(), return type narrowing (covariance), and using type-specific parameters.
  • PHPStan 1.x to 2.x Migration Guide: Introduced a comprehensive guide for migrating from PHPStan 1.x to 2.x. This covers breaking changes such as config renames (strictCalls to strictFunctionCalls), stricter mixed type handling, new error identifiers, and dropped rules from symplify/phpstan-rules. It also provides a step-by-step migration checklist.
Changelog
  • skills/php-modernization/references/phpstan-compliance.md
    • Added a new section 'Baseline Reduction Strategy' with code examples.
    • Added a new section 'PHPStan 1.x to 2.x Migration' including breaking changes and migration steps.
Activity
  • No human activity has occurred on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request provides a clear and helpful guide for migrating to PHPStan 2.x and managing the baseline. The strategies for fixing mixed types are well-explained and align with modern PHP development practices. I have suggested a small refinement to the JSON validation example to replace a PHPDoc type hint with a runtime guard, which is more robust and consistent with the 'genuine fix' philosophy described in the document.

Comment thread skills/php-modernization/references/phpstan-compliance.md Outdated
Use is_array() runtime check instead of PHPDoc @var annotation,
consistent with the "genuine fixes over suppressions" philosophy.
@CybotTM CybotTM merged commit 29f325e into main Feb 22, 2026
5 checks passed
@CybotTM CybotTM deleted the docs/phpstan-2-migration branch February 22, 2026 15:15
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.

1 participant