Skip to content

Builder interface methods should be static to support static analysis #14

@henriquemoody

Description

@henriquemoody

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.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions