Skip to content

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

Open
Copilot wants to merge 10 commits into
masterfrom
copilot/integrate-infection-into-ci
Open

Integrate Infection PHPStan checks into CI without a generated PHPStan baseline#168
Copilot wants to merge 10 commits into
masterfrom
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, TypeCheckPhpDoc, and Arrayy.
    • Replace blanket baseline suppression with a single targeted regex ignore for the recurring internal Arrayy::create() generic false positive in src/Arrayy.php.
    • Move the remaining PHPStan handling into source-level fixes and narrow inline suppressions where necessary, instead of broad config ignores.
  • 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.
    • Preserve the PHPStan meta/array-shape fixture behavior while cleaning up the repo-wide analysis configuration.

Example of the CI/static-analysis wiring:

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

This change is 


This change is Reviewable

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

coveralls commented May 2, 2026

Coverage Status

coverage: 92.359% (-0.02%) 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.

@voku
Copy link
Copy Markdown
Owner

voku commented May 9, 2026

@copilot do we really need to ignore all this phpstan errors in the config?

Copilot AI and others added 6 commits May 9, 2026 20:54
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/5032dd36-d337-4da8-a49a-056c117b63ff

Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/5032dd36-d337-4da8-a49a-056c117b63ff

Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/5032dd36-d337-4da8-a49a-056c117b63ff

Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/5032dd36-d337-4da8-a49a-056c117b63ff

Co-authored-by: voku <264695+voku@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 9, 2026

@copilot do we really need to ignore all this phpstan errors in the config?

No. I reduced it to a single targeted regex ignore for the recurring internal Arrayy::create() generic false positive and moved the rest into source fixes / local inline suppressions where needed. Latest commit: 64879e7.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 9, 2026

Copilot AI requested a review from voku May 9, 2026 21:09
Copilot finished work on behalf of voku May 9, 2026 21:09
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