diff --git a/.github/workflows/blink_parity_mautic.yaml b/.github/workflows/blink_parity_mautic.yaml index c18b354024..3f61d1805c 100644 --- a/.github/workflows/blink_parity_mautic.yaml +++ b/.github/workflows/blink_parity_mautic.yaml @@ -95,7 +95,7 @@ jobs: - name: Compare the two trees run: | # ratchet gate: fail once the differing share crosses this; lower it as parity improves - MAX_DIFF_PERCENT=0.6 + MAX_DIFF_PERCENT=0.5 total=0 differ=0 differing_files="" diff --git a/blink/internal/fixer/rules/method_argument_space.go b/blink/internal/fixer/rules/method_argument_space.go index c0bdc238ac..08313d7c97 100644 --- a/blink/internal/fixer/rules/method_argument_space.go +++ b/blink/internal/fixer/rules/method_argument_space.go @@ -403,7 +403,7 @@ func reflowMultilineArgs(s *tokens.Stream) bool { if closeIdx < 0 || !argListIsMultiline(s, open, closeIdx) { continue } - if !isCallOrDeclParen(s, open) { + if !isCallOrDeclParen(s, open) && !isGroupingReflowParen(s, open) { continue } if sigNext(s, open) == closeIdx { @@ -416,6 +416,19 @@ func reflowMultilineArgs(s *tokens.Stream) bool { return changed } +// isGroupingReflowParen reports whether the "(" at open is a grouping parenthesis +// after a boolean operator ("!(", "&& (", "|| ("). php-cs-fixer's MethodArgumentSpace +// processes such parens like an argument list and, when multiline, breaks the first +// operand onto its own line. +func isGroupingReflowParen(s *tokens.Stream, open int) bool { + p := sigPrev(s, open) + if p < 0 { + return false + } + t := s.At(p) + return t.Kind == token.Punct && (t.Value == "!" || t.Value == "&&" || t.Value == "||") +} + // isAttributeComment reports whether t is a "#[...]" attribute (the lexer keeps // it as one comment token), as opposed to a "//" or "#" line comment. func isAttributeComment(t token.Token) bool { diff --git a/blink/internal/fixer/rules/method_argument_space_test.go b/blink/internal/fixer/rules/method_argument_space_test.go index 409f3961d7..3e1fd66dfd 100644 --- a/blink/internal/fixer/rules/method_argument_space_test.go +++ b/blink/internal/fixer/rules/method_argument_space_test.go @@ -23,6 +23,10 @@ func TestMethodArgumentSpace(t *testing.T) { {"newline only inside a nested arg is left alone", "