Browse Source

Merge branch '1.12'

Conflicts:
	Symfony/CS/Tests/FixerTest.php
	src/Fixer/FunctionNotation/FunctionDeclarationFixer.php
Dariusz Ruminski 8 years ago
parent
commit
0d6f568ca2

+ 3 - 3
src/Fixer/FunctionNotation/FunctionDeclarationFixer.php

@@ -72,12 +72,12 @@ final class FunctionDeclarationFixer extends AbstractFixer
             $afterParenthesisToken = $tokens[$afterParenthesisIndex];
 
             if ($afterParenthesisToken->isGivenKind(CT_USE_LAMBDA)) {
+                // fix whitespace after CT_USE_LAMBDA (we might add a token, so do this before determining start and end parenthesis)
+                $tokens->ensureWhitespaceAtIndex($afterParenthesisIndex + 1, 0, ' ');
+
                 $useStartParenthesisIndex = $tokens->getNextTokenOfKind($afterParenthesisIndex, array('('));
                 $useEndParenthesisIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $useStartParenthesisIndex);
 
-                // fix whitespace after CT_USE_LAMBDA
-                $tokens->ensureWhitespaceAtIndex($afterParenthesisIndex + 1, 0, ' ');
-
                 // remove single-line edge whitespaces inside use parentheses
                 $this->fixParenthesisInnerEdge($tokens, $useStartParenthesisIndex, $useEndParenthesisIndex);
 

+ 9 - 0
src/Fixer/Phpdoc/NoBlankLinesAfterPhpdocFixer.php

@@ -67,6 +67,15 @@ final class NoBlankLinesAfterPhpdocFixer extends AbstractFixer
         return 'There should not be blank lines between docblock and the documented element.';
     }
 
+    /**
+     * {@inheritdoc}
+     */
+    public function getPriority()
+    {
+        // should be ran before the SingleBlankLineBeforeNamespaceFixer.
+        return 1;
+    }
+
     /**
      * Cleanup a whitespace token.
      *

+ 1 - 0
src/Fixer/Phpdoc/PhpdocToCommentFixer.php

@@ -118,6 +118,7 @@ final class PhpdocToCommentFixer extends AbstractFixer
             T_PRIVATE,
             T_PROTECTED,
             T_PUBLIC,
+            T_VAR,
             T_FUNCTION,
             T_ABSTRACT,
             T_CONST,

+ 12 - 0
tests/Fixer/FunctionNotation/FunctionDeclarationFixerTest.php

@@ -78,6 +78,18 @@ foo () {}',
                 '<?php function ($a) use ($b) {};',
                 '<?php function ($a) use ($b)     {};',
             ),
+            array(
+                '<?php $foo = function ($foo) use ($bar, $baz) {};',
+                '<?php $foo = function ($foo) use($bar, $baz) {};',
+            ),
+            array(
+                '<?php $foo = function ($foo) use ($bar, $baz) {};',
+                '<?php $foo = function ($foo)use ($bar, $baz) {};',
+            ),
+            array(
+                '<?php $foo = function ($foo) use ($bar, $baz) {};',
+                '<?php $foo = function ($foo)use($bar, $baz) {};',
+            ),
             array(
                 '<?php function &foo($a) {}',
                 '<?php function &foo( $a ) {}',

+ 5 - 0
tests/Fixer/Phpdoc/PhpdocToCommentFixerTest.php

@@ -64,6 +64,11 @@ class DocBlocks
      */
     protected $indent = false;
 
+    /**
+     * Do not convert this
+     */
+    var $oldPublicStyle;
+
     /**
      * Do not convert this
      */

+ 1 - 0
tests/FixerFactoryTest.php

@@ -276,6 +276,7 @@ final class FixerFactoryTest extends \PHPUnit_Framework_TestCase
             array($fixers['short_array_syntax'], $fixers['unalign_equals']), // tested also in: short_array_syntax,unalign_equals.test
             array($fixers['short_array_syntax'], $fixers['ternary_operator_spaces']), // tested also in: short_array_syntax,ternary_operator_spaces.test
             array($fixers['class_keyword_remove'], $fixers['no_unused_imports']), // tested also in: class_keyword_remove,no_unused_imports.test
+            array($fixers['no_blank_lines_after_phpdoc'], $fixers['single_blank_line_before_namespace']), // tested also in: no_blank_lines_after_phpdoc,single_blank_line_before_namespace.test
         );
 
         // prepare bulk tests for phpdoc fixers to test that:

+ 24 - 0
tests/Fixtures/Integration/priority/no_blank_lines_after_phpdoc,single_blank_line_before_namespace.test

@@ -0,0 +1,24 @@
+--TEST--
+Integration of fixers: no_blank_lines_after_phpdoc,single_blank_line_before_namespace.
+--RULESET--
+{"no_blank_lines_after_phpdoc": true, "single_blank_line_before_namespace": true}
+--EXPECT--
+<?php
+/**
+ * Header
+ */
+
+namespace A\B;
+
+class A {}
+
+--INPUT--
+<?php
+/**
+ * Header
+ */
+
+
+namespace A\B;
+
+class A {}