docs: add PHPStan 2.x migration guide and baseline reduction strategy#9
docs: add PHPStan 2.x migration guide and baseline reduction strategy#9
Conversation
- 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
Summary of ChangesHello @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 Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
Use is_array() runtime check instead of PHPDoc @var annotation, consistent with the "genuine fixes over suppressions" philosophy.
Summary
Adds two new sections to the PHPStan compliance reference:
@phpstan-ignoresuppressions (is_string/is_array guards, step-by-step JSON/YAML validation, return type covariance, type-specific parameters)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-ignoreannotations.Test plan