Browse Source

bug #4809 Fix "braces" and "method_argument_space" priority (julienfalque)

This PR was merged into the 2.15 branch.

Discussion
----------

Fix "braces" and "method_argument_space" priority

Fixes #4657.

Commits
-------

b15f4c3f Fix "braces" and "method_argument_space" priority
SpacePossum 5 years ago
parent
commit
c8933cc0eb

+ 1 - 1
src/Fixer/Basic/BracesFixer.php

@@ -124,7 +124,7 @@ class Foo
     /**
      * {@inheritdoc}
      *
-     * Must run before ArrayIndentationFixer, MethodChainingIndentationFixer.
+     * Must run before ArrayIndentationFixer, MethodArgumentSpaceFixer, MethodChainingIndentationFixer.
      * Must run after ClassAttributesSeparationFixer, ElseifFixer, LineEndingFixer, MethodSeparationFixer, NoAlternativeSyntaxFixer, NoEmptyStatementFixer, NoUselessElseFixer, SingleTraitInsertPerStatementFixer.
      */
     public function getPriority()

+ 2 - 2
src/Fixer/FunctionNotation/MethodArgumentSpaceFixer.php

@@ -128,11 +128,11 @@ SAMPLE
     /**
      * {@inheritdoc}
      *
-     * Must run after CombineNestedDirnameFixer, ImplodeCallFixer, PowToExponentiationFixer.
+     * Must run after BracesFixer, CombineNestedDirnameFixer, ImplodeCallFixer, PowToExponentiationFixer.
      */
     public function getPriority()
     {
-        return -2;
+        return -26;
     }
 
     /**

+ 1 - 0
tests/AutoReview/FixerFactoryTest.php

@@ -69,6 +69,7 @@ final class FixerFactoryTest extends TestCase
             [$fixers['backtick_to_shell_exec'], $fixers['explicit_string_variable']],
             [$fixers['blank_line_after_opening_tag'], $fixers['no_blank_lines_before_namespace']],
             [$fixers['braces'], $fixers['array_indentation']],
+            [$fixers['braces'], $fixers['method_argument_space']],
             [$fixers['braces'], $fixers['method_chaining_indentation']],
             [$fixers['class_attributes_separation'], $fixers['braces']],
             [$fixers['class_attributes_separation'], $fixers['indentation_type']],

+ 24 - 0
tests/Fixtures/Integration/priority/braces,method_argument_space.test

@@ -0,0 +1,24 @@
+--TEST--
+Integration of fixers: braces,method_argument_space.
+--RULESET--
+{"method_argument_space": {"on_multiline": "ensure_fully_multiline"}, "braces": true}
+--EXPECT--
+<?php
+
+function foo()
+{
+    return bar(
+        'foo',
+        'bar'
+    );
+}
+
+--INPUT--
+<?php
+
+function foo(){
+  return bar(
+    'foo',
+    'bar'
+  );
+}