Skip to content

Declare Builder mixin methods as static for static analysis support#16

Merged
henriquemoody merged 5 commits intomainfrom
copilot/fix-builder-interface-methods
Feb 7, 2026
Merged

Declare Builder mixin methods as static for static analysis support#16
henriquemoody merged 5 commits intomainfrom
copilot/fix-builder-interface-methods

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

Plan to Fix Builder Interface Static Methods

  • Explore repository structure and understand the issue
  • Identify the difference between Builder and Chain mixins
  • Update Builder interface methods from instance to static
  • Address code review feedback (remove test cache from git)
  • Run security scan (CodeQL) - no issues found
  • Revert platform-check configuration change
  • Complete implementation

Summary

Successfully resolved the issue where static analysis tools couldn't discover static method calls on FormatterBuilder by updating the Builder mixin interface.

Changes Made

  1. src/Mixin/Builder.php: Changed all 12 method declarations from public function to public static function to match the actual usage pattern via __callStatic magic method. This enables PHPStan, Psalm, and IDE autocomplete to properly discover and validate static method calls like FormatterBuilder::mask('1-3').

  2. .gitignore: Added .phpunit.result.cache to prevent test execution artifacts from being committed.

Key Points

  • No breaking changes: Only interface declarations changed; actual implementation behavior is unchanged
  • Static analysis support: Tools can now properly discover FormatterBuilder::method() calls
  • Chain mixin unchanged: Instance methods remain for chaining pattern $builder->method()
  • Security: CodeQL scan completed with no issues found
  • Backward compatible: Existing code continues to work without modification
Original prompt

This section details on the original issue you should resolve

<issue_title>Builder interface methods should be static to support static analysis</issue_title>
<issue_description>## Problem

The Builder mixin interface defines all methods as instance methods, but it's intended to help static analysis tools discover static method calls on FormatterBuilder.

Current Behavior

Methods in src/Mixin/Builder.php are declared as:

public function area(string $unit): FormatterBuilder;

But when using the builder, methods are called statically:

FormatterBuilder::area('')

Expected Behavior

Methods in Builder should be declared as public static to match the actual usage pattern and help static analysis tools correctly identify these methods:

public static function area(string $unit): FormatterBuilder;

Difference Between Builder and Chain Mixins

  • Builder mix: Should enable static method calls on FormatterBuilder (e.g., FormatterBuilder::area())
  • Chain mix: Enables chaining instance methods after a builder is created (e.g., $builder->area()->lowercase())

Impact

Static analysis tools (PHPStan, Psalm, IDE autocomplete) cannot discover or validate static method calls on FormatterBuilder because the interface declares them as instance methods.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits February 6, 2026 21:50
Co-authored-by: henriquemoody <154023+henriquemoody@users.noreply.github.com>
Co-authored-by: henriquemoody <154023+henriquemoody@users.noreply.github.com>
Co-authored-by: henriquemoody <154023+henriquemoody@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Builder interface methods to be static for static analysis Declare Builder mixin methods as static for static analysis support Feb 6, 2026
Copilot AI requested a review from henriquemoody February 6, 2026 21:54
composer.json Outdated
},
"sort-packages": true
"sort-packages": true,
"platform-check": false
Copy link
Member

Choose a reason for hiding this comment

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

Revert that change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted in a80f98d

Co-authored-by: henriquemoody <154023+henriquemoody@users.noreply.github.com>
Copilot AI requested a review from henriquemoody February 7, 2026 08:47
@henriquemoody henriquemoody marked this pull request as ready for review February 7, 2026 08:50
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.47%. Comparing base (3a9d71c) to head (a80f98d).

Additional details and impacted files
@@            Coverage Diff            @@
##               main      #16   +/-   ##
=========================================
  Coverage     99.47%   99.47%           
  Complexity      163      163           
=========================================
  Files            24       24           
  Lines           382      382           
=========================================
  Hits            380      380           
  Misses            2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@henriquemoody henriquemoody merged commit 1a07f89 into main Feb 7, 2026
8 checks passed
@henriquemoody henriquemoody deleted the copilot/fix-builder-interface-methods branch February 7, 2026 08:53
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.

Builder interface methods should be static to support static analysis

3 participants