Skip to content

Integrate Infection PHPStan checks into CI without a generated PHPStan baseline#168

Open
Copilot wants to merge 4 commits intomasterfrom
copilot/integrate-infection-into-ci
Open

Integrate Infection PHPStan checks into CI without a generated PHPStan baseline#168
Copilot wants to merge 4 commits intomasterfrom
copilot/integrate-infection-into-ci

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 2, 2026

This change adds Infection's PHPStan-backed static-analysis pass to CI on a supported PHP version and keeps the workflow green without committing a generated 2k+ line baseline. The repo-wide PHPStan pass is now scoped to production code, while the dedicated PHPStan fixture coverage remains separate.

  • CI / static-analysis integration

    • Enable Infection's staticAnalysisTool: "phpstan" integration.
    • Run PHPStan + Infection on the PHP 8.3 basic job in GitHub Actions.
    • Keep Infection installation local to the workflow job.
  • PHPStan scope cleanup

    • Remove the generated phpstan-baseline.neon.
    • Change the main phpstan.neon pass to analyze src/ only.
    • Keep fixture-style PHPStan assertions on phpstan-fixtures.neon so test fixtures still validate expected type behavior.
  • Targeted PHPStan debt reduction

    • Fix low-effort source issues in Json, AbstractCollection, Create, DetectFirstValueTypeCollection, TypeCheckCallback, and TypeCheckPhpDoc.
    • Replace blanket baseline suppression with a small set of focused ignore rules for remaining generic-analysis noise centered in src/Arrayy.php and the PHPStan runtime-reflection extension.
  • Typing improvements

    • Add iterable/value-type annotations for JSON mapper caches and handlers.
    • Tighten nullable handling and class-string/object mapping paths.
    • Improve return typing for helper methods and small collection/type-check utilities.

Example of the CI/static-analysis wiring:

{
  "phpUnit": {
    "customPath": "vendor/bin/phpunit"
  },
  "staticAnalysisTool": "phpstan"
}

This change is Reviewable

Copilot AI and others added 4 commits May 2, 2026 12:00
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 2, 2026

@coveralls
Copy link
Copy Markdown

coveralls commented May 2, 2026

Coverage Status

coverage: 92.382% (+0.002%) from 92.38% — copilot/integrate-infection-into-ci into master

@voku voku marked this pull request as ready for review May 2, 2026 13:06
@voku
Copy link
Copy Markdown
Owner

voku commented May 2, 2026

/gemini review

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 focuses on improving static analysis and type safety using PHPStan. Key changes include the introduction of a dedicated PHPStan configuration for fixtures, extensive updates to PHPDoc annotations for better type coverage (especially in Json.php), and the removal of unused properties in TypeCheckPhpDoc.php. Additionally, logic was added to handle non-traversable objects in the JSON mapper and to verify class existence before mapping. I have no feedback to provide.

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.

3 participants