Skip to content

Add initial PHPStan config#486

Merged
swissspidy merged 17 commits intomainfrom
fix/phpstan
Apr 8, 2026
Merged

Add initial PHPStan config#486
swissspidy merged 17 commits intomainfrom
fix/phpstan

Conversation

@swissspidy
Copy link
Copy Markdown
Member

No description provided.

@github-actions github-actions bot added the scope:testing Related to testing label Apr 2, 2026
@github-actions

This comment was marked as resolved.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

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

This pull request introduces PHPStan for static analysis, adding a configuration file, stubs, and comprehensive PHPDoc type hints throughout the project. It also migrates path-related utility calls to the "WP_CLI\Path" class and refactors type checks to use "instanceof". Key feedback points include the potential for compilation errors due to the removal of Blade component tag handling in "BladeGettextExtractor" and the breaking of inheritance and backward compatibility caused by renaming "multilineQuote" in "PotGenerator".

@swissspidy swissspidy added this to the 2.7.2 milestone Apr 2, 2026
@swissspidy swissspidy marked this pull request as ready for review April 8, 2026 11:18
@swissspidy swissspidy requested a review from a team as a code owner April 8, 2026 11:18
Copilot AI review requested due to automatic review settings April 8, 2026 11:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces an initial PHPStan setup for the i18n command package, along with a set of code/docblock adjustments and defensive runtime checks intended to make the codebase pass stricter static analysis.

Changes:

  • Add a baseline phpstan.neon.dist configuration plus scan/stub files to model WP-CLI/Gettext types for analysis.
  • Wire PHPStan into the composer test script.
  • Update multiple command/extractor/generator classes with tighter PHPDoc types and additional runtime guards (e.g., is_array() / is_scalar() checks) to satisfy PHPStan at a higher level.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
phpstan.neon.dist Adds initial PHPStan configuration (level, scan paths/files, stub files).
composer.json Adds @phpstan to the test script pipeline.
tests/phpstan/scan-files.php Provides scan-time symbols/constants (e.g., WP_CLI_VERSION, Requests_Response) for PHPStan.
stubs/Gettext.stub Adds Gettext stubs to help PHPStan understand third-party types.
src/*.php (multiple) Adds PHPDoc generics/return types and defensive checks to reduce PHPStan noise and improve type safety.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

swissspidy and others added 2 commits April 8, 2026 13:54
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@swissspidy swissspidy merged commit a52a6ad into main Apr 8, 2026
72 of 73 checks passed
@swissspidy swissspidy deleted the fix/phpstan branch April 8, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants