fix: MethodArgumentSpaceFixer - fix nested calls for ensure_fully_multiline option#8469
Merged
kubawerlos merged 10 commits intoPHP-CS-Fixer:masterfrom Mar 3, 2025
Merged
Conversation
The inner function call is indented first and then it was ignored when
the outer function call was being checked - only the function name
god indented, leading to:
```php
foo(
$x,
bar(
$foo,
$bar,
$baz
)
);
kubawerlos
requested changes
Mar 1, 2025
|
|
||
| $expectedTokens = [T_LIST, T_FUNCTION, CT::T_USE_LAMBDA, T_FN, T_CLASS]; | ||
|
|
||
| for ($index = $tokens->count() - 1; $index > 0; --$index) { |
Member
There was a problem hiding this comment.
Suggested change
| for ($index = $tokens->count() - 1; $index > 0; --$index) { | |
| $tokenCount = $tokens->count(); | |
| for ($index = 1; $index < $tokenCount; ++$index) { |
There is no need to introduce multilinedTokens, reversing this loop would be enough.
added 4 commits
March 1, 2025 19:06
The test would've failed just as well even if the inner function had only two variables instead of three.
The test would've failed just as well even if the inner function had only two variables instead of three.
added 5 commits
March 3, 2025 09:17
…ted calls As requested in PHP-CS-Fixer#8469 (comment)
Contributor
Author
|
@kubawerlos your suggestion works like a charm, I've removed Just in case, I've also added a test with two levels of nested calls to check that this is valid (it is). |
MethodArgumentSpaceFixer - fix nested calls for ensure_fully_multiline option
kubawerlos
approved these changes
Mar 3, 2025
Member
|
Thank you @geecu |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The inner function call is indented first and then it was ignored when the outer function call was being checked - only the function name god indented, leading to: