Skip to content

Comments

feat(printer): add per-node NEWLINE_ON_FLUENT_CALL attribute to BetterStandardPrinter#7910

Open
MrPunyapal wants to merge 3 commits intorectorphp:mainfrom
MrPunyapal:feat/printer-newline-on-fluent-call-attribute
Open

feat(printer): add per-node NEWLINE_ON_FLUENT_CALL attribute to BetterStandardPrinter#7910
MrPunyapal wants to merge 3 commits intorectorphp:mainfrom
MrPunyapal:feat/printer-newline-on-fluent-call-attribute

Conversation

@MrPunyapal
Copy link

@MrPunyapal MrPunyapal commented Feb 23, 2026

Summary

Add a per-node attribute AttributeKey::NEWLINE_ON_FLUENT_CALL so individual MethodCall nodes can opt into newline-on-fluent formatting without enabling the global newLineOnFluentCall() option.

Motivation

The printer currently only checks the global Option::NEW_LINE_ON_FLUENT_CALL flag. When a rule enables that option globally, every fluent chain across the processed codebase is reformatted. This causes undesirable, wide-ranging formatting changes. A per-node attribute lets rules request one-method-per-line formatting for specific nodes (for example, expect() chains) without affecting unrelated code.

Example

When creating a MethodCall node in a Rector rule, tag it to enable newline formatting:

use Rector\NodeTypeResolver\Node\AttributeKey;

$methodCall = new MethodCall($receiver, 'and', [$arg]);
$methodCall->setAttribute(AttributeKey::NEWLINE_ON_FLUENT_CALL, true);

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.

1 participant