Skip to content

Integrate Respect/Fluent and FluentGen#21

Open
alganet wants to merge 1 commit intoRespect:mainfrom
alganet:fluent
Open

Integrate Respect/Fluent and FluentGen#21
alganet wants to merge 1 commit intoRespect:mainfrom
alganet:fluent

Conversation

@alganet
Copy link
Member

@alganet alganet commented Mar 23, 2026

FormatterBuilder now extends Fluent's Append with #[FluentNamespace] attribute, replacing the manual __call/__callStatic reflection logic. Mixin generation uses FluentGen via a LintMixinCommand. Mixins moved from src/Mixin/ to src/Mixins/ to match the Validation's output convention.


See: Respect/Validation#1729

This also serves as reusability proof of Fluent and FluentGen. Some aspects of it, such as the LintMixinCommand are still not fully grown as an idea (would require formalizing diff abstractions, linter abstractions better), so they are copied (it's kind of a smaller price to pay than copy the entire CodeGen or the older procedural mixin generator).

Similarly to Validation's PR, this also unlocks full fluent static analysis for StringFormatter fluent usage using the FluentAnalysis project, but shipping fluent.neon and wiring the extensibility is out of scope for this PR now.

FormatterBuilder now extends Fluent's Append with #[FluentNamespace] attribute,
replacing the manual __call/__callStatic reflection logic. Mixin generation
uses FluentGen via a LintMixinCommand. Mixins moved from src/Mixin/ to
src/Mixins/ to match the Validation's output convention.
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.54%. Comparing base (ed3f6a2) to head (e47ccf0).

Additional details and impacted files
@@             Coverage Diff              @@
##               main      #21      +/-   ##
============================================
- Coverage     99.55%   99.54%   -0.01%     
+ Complexity      199      196       -3     
============================================
  Files            29       29              
  Lines           446      439       -7     
============================================
- Hits            444      437       -7     
  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.

Copy link

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 migrates FormatterBuilder to use Respect/Fluent for fluent formatter resolution, and introduces FluentGen-based tooling to generate/validate the fluent mixin interfaces under src/Mixins.

Changes:

  • Replace FormatterBuilder’s manual __call/__callStatic reflection logic with Respect/Fluent’s Append builder + #[FluentNamespace] lookup.
  • Add a Symfony Console devtool command (lint:mixin) powered by FluentGen to (re)generate and validate mixin interfaces.
  • Move/adjust mixin interfaces to Respect\StringFormatter\Mixins and update method signatures to match formatter constructors.

Reviewed changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Integration/FormatterBuilderTest.php Updates exception expectations to align with Fluent-based resolution errors.
src/FormatterBuilder.php Switches builder implementation to Respect\Fluent\Builders\Append with attribute-based namespace lookup.
src/Internal/CompiledPattern.php Minor tweak to quantifier compilation fallback handling.
src/Mixins/Chain.php Updates fluent chain interface namespace and method signatures.
src/Mixins/Builder.php Updates fluent static builder interface namespace and method signatures.
src-dev/Commands/LintMixinCommand.php Adds a dev command to generate/compare mixin interfaces using FluentGen.
bin/console Adds a CLI entrypoint for running dev console commands.
phpcs.xml.dist Adds exclusions (line length) for generated mixin files (and a tests path).
composer.json Adds Respect/Fluent (runtime) and FluentGen + Symfony Console (dev) dependencies; adds dev autoload for DevTools.
composer.lock Locks new dependencies and updated versions.
Comments suppressed due to low confidence (2)

src/Mixins/Chain.php:45

  • The mixin signature allows placeholder(..., Modifier|null $modifier = null), but PlaceholderFormatter::__construct() requires a non-null Modifier (it has a default instance, but passing explicit null will cause a TypeError). Either update PlaceholderFormatter to accept ?Modifier and substitute the default when null is passed, or change the mixin signature so it doesn't advertise null as a valid value.
    src/Mixins/Builder.php:46
  • The mixin signature allows placeholder(..., Modifier|null $modifier = null), but PlaceholderFormatter::__construct() requires a non-null Modifier (it has a default instance, but passing explicit null will cause a TypeError). Either update PlaceholderFormatter to accept ?Modifier and substitute the default when null is passed, or change the mixin signature so it doesn't advertise null as a valid value.

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

Comment on lines +18 to +22

<!-- Exclusions -->
<rule ref="Generic.Files.LineLength.TooLong">
<exclude-pattern>src/Mixins/</exclude-pattern>
<exclude-pattern>tests/feature/</exclude-pattern>
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

tests/feature/ is excluded from line-length checks, but there is no tests/feature directory in this repo (current test dirs are tests/Helper, tests/Integration, tests/Unit). If this is meant to exclude a real path, update it to the correct directory; otherwise it should be removed to avoid stale config. Also consider removing the trailing whitespace on the blank line above the exclusions.

Suggested change
<!-- Exclusions -->
<rule ref="Generic.Files.LineLength.TooLong">
<exclude-pattern>src/Mixins/</exclude-pattern>
<exclude-pattern>tests/feature/</exclude-pattern>
<!-- Exclusions -->
<rule ref="Generic.Files.LineLength.TooLong">
<exclude-pattern>src/Mixins/</exclude-pattern>

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

Fair enough. I'll wait fore more reviews and batch this change with other possible suggestions.

@alganet alganet marked this pull request as ready for review March 23, 2026 23:28
@alganet alganet requested a review from henriquemoody March 23, 2026 23:28
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