Skip to content

bug(formatter): fluent member access chains are not allowed to have multiple method calls after property access #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
innocenzi opened this issue Mar 18, 2025 · 1 comment
Assignees
Labels
Priority: High After critical issues are fixed, handle these before any further issues. Status: Closed This issue is closed and no more work is planned. Subject: Formatter An issue or PR related to the formatter. Type: Bug An issue causing unintended or problematic behavior.

Comments

@innocenzi
Copy link
Contributor

Image

Before

expect($response->dto()->get(2))
    ->id->toBe(21)
    ->name->toBe('Payslips')
    ->files->toHaveCount(1)
    ->files->first()->toBeInstanceOf(FileData::class);

After

expect($response->dto()->get(2))
    ->id
    ->toBe(21)
    ->name
    ->toBe('Payslips')
    ->files
    ->toHaveCount(1)
    ->files
    ->first()
    ->toBeInstanceOf(FileData::class);

Using Mago v0.20.2:

[format]
print_width = 180
tab_width = 4
use_tabs = false
null_type_hint = "question"
space_before_arrow_function_parameter_list_parenthesis = true
space_after_logical_not_unary_prefix_operator = true
always_break_named_arguments_list = false
preserve_breaking_member_access_chain = true
preserve_breaking_argument_list = true
preserve_breaking_array_like = true
preserve_breaking_parameter_list = true
preserve_breaking_attribute_list = true
preserve_breaking_conditional_expression = true
@azjezz azjezz self-assigned this Mar 18, 2025
@azjezz azjezz added Priority: High After critical issues are fixed, handle these before any further issues. Status: In Progress This issue is being worked on and has someone assigned. Type: Bug An issue causing unintended or problematic behavior. Subject: Formatter An issue or PR related to the formatter. labels Mar 18, 2025
@azjezz azjezz closed this as completed in 3c9d3ea Mar 18, 2025
@azjezz azjezz added Status: Closed This issue is closed and no more work is planned. and removed Status: In Progress This issue is being worked on and has someone assigned. labels Mar 18, 2025
@azjezz azjezz changed the title preserve_breaking_member_access_chain is not respected bug(formatter): fluent member access chains are not allowed to have multiple method calls after property access Mar 18, 2025
@azjezz
Copy link
Member

azjezz commented Mar 18, 2025

This is was not related to preserve_breaking_member_access_chain, the option is wheather or not the chain should be in multiple lines, and since it was before into multiple lines, it was also formatted in multiple lines, so the option works!

The problem was with our "fluent" style, which allows properties and methods to be on the same line, previously fluent worked if we have pattern of property access, followed by method call, repeating, we now expanded this to also support multiple method calls after the property access ( up to 3 method calls ), which means the given code is now considered fluent pattern, and is formatted correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High After critical issues are fixed, handle these before any further issues. Status: Closed This issue is closed and no more work is planned. Subject: Formatter An issue or PR related to the formatter. Type: Bug An issue causing unintended or problematic behavior.
Projects
None yet
Development

No branches or pull requests

2 participants