Browse Source

Merge branch '1.11'

Conflicts:
	README.rst
	Symfony/CS/Fixer/Contrib/AlignDoubleArrowFixer.php
	Symfony/CS/Fixer/PSR2/BracesFixer.php
	Symfony/CS/Tests/Fixer/Contrib/PhpdocVarToTypeFixerTest.php
	Symfony/CS/Tests/Fixer/Symfony/PhpdocTypeToVarFixerTest.php
	Symfony/CS/Tests/FixerTest.php
Dariusz Ruminski 9 years ago
parent
commit
03a4316be7

+ 15 - 0
CHANGELOG.md

@@ -3,6 +3,21 @@ CHANGELOG for PHP CS Fixer
 
 This file contains changelogs for stable releases only.
 
+Changelog for v1.10.1
+---------------------
+
+* bug #1424 Fixed the import fixer priorities (GrahamCampbell)
+* bug #1444 OrderedUseFixer - fix next case (keradus)
+* bug #1441 BracesFixer - fix next case (keradus)
+* bug #1422 AlignDoubleArrowFixer - fix handling of nested array (SpacePossum)
+* bug #1425 PhpdocInlineTagFixerTest - fix case when met inalid PHPDoc (keradus)
+* bug #1419 AlignDoubleArrowFixer, AlignEqualsFixer - fix priorities (keradus)
+* bug #1415 BlanklineAfterOpenTagFixer - Do not add a line break if there is one already. (SpacePossum)
+* bug #1410 PhpdocIndentFixer - Fix for open tag (SpacePossum)
+* bug #1401 PhpdocVarWithoutNameFixer - Fixed the var without name fixer for inline docs (keradus, GrahamCampbell)
+* bug #1369 Fix not well-formed XML output (junichi11)
+* bug #1356 Psr0Fixer - disallow run on StdinFileInfo (keradus)
+
 Changelog for v1.10
 -------------------
 

+ 2 - 2
README.rst

@@ -208,7 +208,7 @@ Choose from the list of available fixers:
 
 * **double_arrow_multiline_whitespaces** [@Symfony]
                         Operator => should not be
-                        arounded by multi-line
+                        surrounded by multi-line
                         whitespaces.
 
 * **duplicate_semicolon** [@Symfony]
@@ -369,7 +369,7 @@ Choose from the list of available fixers:
 
 * **operators_spaces** [@Symfony]
                         Binary operators should be
-                        arounded by at least one
+                        surrounded by at least one
                         space.
 
 * **ordered_use**

+ 2 - 4
Symfony/CS/AbstractAlignFixer.php

@@ -67,14 +67,12 @@ abstract class AbstractAlignFixer extends AbstractFixer
                 }
             }
 
-            $i = 0;
             foreach ($linesWithPlaceholder as $group) {
-                if (1 === count($group)) {
+                if (count($group) < 1) {
                     continue;
                 }
-                ++$i;
-                $rightmostSymbol = 0;
 
+                $rightmostSymbol = 0;
                 foreach ($group as $index) {
                     $rightmostSymbol = max($rightmostSymbol, strpos(utf8_decode($lines[$index]), $placeholder));
                 }

+ 8 - 14
Symfony/CS/Fixer/Contrib/AlignDoubleArrowFixer.php

@@ -54,7 +54,7 @@ final class AlignDoubleArrowFixer extends AbstractAlignFixer
         // To handle that unwanted behavior we work on clone of Tokens collection and then override original collection with fixed collection.
         $tokensClone = clone $tokens;
 
-        $this->injectAlignmentPlaceholders($tokensClone);
+        $this->injectAlignmentPlaceholders($tokensClone, 0, count($tokens));
         $content = $this->replacePlaceholder($tokensClone);
 
         $tokens->setCode($content);
@@ -86,16 +86,8 @@ final class AlignDoubleArrowFixer extends AbstractAlignFixer
      *
      * @return array($code, $context_counter)
      */
-    private function injectAlignmentPlaceholders(Tokens $tokens, $startAt = null, $endAt = null)
+    private function injectAlignmentPlaceholders(Tokens $tokens, $startAt, $endAt)
     {
-        if (empty($startAt)) {
-            $startAt = 0;
-        }
-
-        if (empty($endAt)) {
-            $endAt = count($tokens);
-        }
-
         for ($index = $startAt; $index < $endAt; ++$index) {
             $token = $tokens[$index];
 
@@ -105,7 +97,7 @@ final class AlignDoubleArrowFixer extends AbstractAlignFixer
                 continue;
             }
 
-            if ($token->isGivenKind(T_ARRAY)) {
+            if ($token->isGivenKind(T_ARRAY)) { // don't use "$tokens->isArray()" here, short arrays are handled in the next case
                 $from = $tokens->getNextMeaningfulToken($index);
                 $until = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $from);
                 $index = $until;
@@ -155,10 +147,12 @@ final class AlignDoubleArrowFixer extends AbstractAlignFixer
             }
 
             if ($token->equals(',')) {
-                do {
+                for ($i = $index; $i < $endAt - 1; ++$i) {
+                    if ($tokens[$i + 1]->isGivenKind(array(T_ARRAY, CT_ARRAY_SQUARE_BRACE_OPEN)) || false !== strpos($tokens[$i - 1]->getContent(), "\n")) {
+                        break;
+                    }
                     ++$index;
-                    $token = $tokens[$index];
-                } while (false === strpos($token->getContent(), "\n"));
+                }
             }
         }
     }

+ 7 - 2
Symfony/CS/Fixer/Contrib/OrderedUseFixer.php

@@ -78,8 +78,8 @@ final class OrderedUseFixer extends AbstractFixer
      */
     public function getPriority()
     {
-        // should be run after the MultipleUseFixer
-        return -10;
+        // should be run after the MultipleUseFixer and RemoveLeadingSlashUseFixer
+        return -30;
     }
 
     /**
@@ -120,10 +120,15 @@ final class OrderedUseFixer extends AbstractFixer
 
             while ($index <= $endIndex) {
                 $token = $tokens[$index];
+
                 if ($index === $endIndex || $token->equals(',')) {
                     $indexes[$startIndex] = array($namespace, $startIndex, $index - 1);
                     $originalIndexes[] = $startIndex;
 
+                    if ($index === $endIndex) {
+                        break;
+                    }
+
                     $namespace = '';
                     $nextPartIndex = $tokens->getTokenNotOfKindSibling($index, 1, array(array(','), array(T_WHITESPACE)));
                     $startIndex = $nextPartIndex;

+ 2 - 0
Symfony/CS/Fixer/PSR2/BracesFixer.php

@@ -228,6 +228,8 @@ final class BracesFixer extends AbstractFixer
                         !$nextNonWhitespaceNestToken->isComment() &&
                         // and it is not a `$foo = function () {};` situation
                         !($nestToken->equals('}') && $nextNonWhitespaceNestToken->equalsAny(array(';', ',', ']', array(CT_ARRAY_SQUARE_BRACE_CLOSE)))) &&
+                        // and it is not a `Foo::{bar}()` situation
+                        !($nestToken->equals('}') && $nextNonWhitespaceNestToken->equals('(')) &&
                         // and it is not a `${"a"}->...` and `${"b{$foo}"}->...` situation
                         !($nestToken->equals('}') && $tokens[$nestIndex - 1]->equalsAny(array('"', "'", array(T_CONSTANT_ENCAPSED_STRING))))
                     ) {

+ 1 - 1
Symfony/CS/Fixer/Symfony/DoubleArrowMultilineWhitespacesFixer.php

@@ -53,7 +53,7 @@ final class DoubleArrowMultilineWhitespacesFixer extends AbstractFixer
      */
     public function getDescription()
     {
-        return 'Operator => should not be arounded by multi-line whitespaces.';
+        return 'Operator => should not be surrounded by multi-line whitespaces.';
     }
 
     /**

+ 1 - 1
Symfony/CS/Fixer/Symfony/OperatorsSpacesFixer.php

@@ -56,6 +56,6 @@ final class OperatorsSpacesFixer extends AbstractFixer
      */
     public function getDescription()
     {
-        return 'Binary operators should be arounded by at least one space.';
+        return 'Binary operators should be surrounded by at least one space.';
     }
 }

+ 1 - 1
Symfony/CS/Fixer/Symfony/PhpdocInlineTagFixer.php

@@ -44,7 +44,7 @@ final class PhpdocInlineTagFixer extends AbstractFixer
             // Make sure the tags are written in lower case, remove white space between end
             // of text and closing bracket and between the tag and inline comment.
             $content = preg_replace_callback(
-                '#(?:@{+|{+[ \t]*@)[ \t]*(example|id|internal|inheritdoc|link|source|toc|tutorial)s?([^}]*)(?:}*)#i',
+                '#(?:@{+|{+[ \t]*@)[ \t]*(example|id|internal|inheritdoc|link|source|toc|tutorial)s?([^}]*)(?:}+)#i',
                 function (array $matches) {
                     $doc = trim($matches[2]);
 

+ 70 - 0
Symfony/CS/Tests/Fixer/Contrib/AlignDoubleArrowFixerTest.php

@@ -41,6 +41,76 @@ final class AlignDoubleArrowFixerTest extends AbstractFixerTestBase
             ),
             array(
                 '<?php
+    $array = array(
+        "closure" => function ($param1, $param2) {
+            return;
+        }
+    );',
+            ),
+            array(
+                '<?php
+    return new JsonResponse(array(
+        "result" => "OK",
+        "html"   => 1, array(
+            "foo"    => "bar",
+            "foofoo" => array(
+                "a"  => 1,
+                "b"  => 2
+            )
+        ),)
+    );',
+                '<?php
+    return new JsonResponse(array(
+        "result" => "OK",
+        "html" => 1, array(
+            "foo" => "bar",
+            "foofoo" => array(
+                "a" => 1,
+                "b"  =>  2
+            )
+        ),)
+    );',
+            ),
+            array(
+                '<?php
+    return new JsonResponse([
+        "result" => "OK",
+        "html"   => renderView("views/my_view.html.twig", array(
+            "foo"    => "bar",
+            "foofoo" => 43,
+        )),
+    ]);',
+                '<?php
+    return new JsonResponse([
+        "result" => "OK",
+        "html" =>    renderView("views/my_view.html.twig", array(
+            "foo" => "bar",
+            "foofoo" => 43,
+        )),
+    ]);',
+            ),
+            array(
+                '<?php
+    return new JsonResponse([
+        "result" => "OK",
+        "html"   => renderView("views/my_view.html.twig", [
+            "foo"    => "bar",
+            "foofoo" => 42,
+        ]),
+        "baz" => "OK",
+    ]);',
+                '<?php
+    return new JsonResponse([
+        "result" => "OK",
+        "html" =>    renderView("views/my_view.html.twig", [
+            "foo" =>   "bar",
+            "foofoo" =>    42,
+        ]),
+        "baz" => "OK",
+    ]);',
+            ),
+            array(
+                '<?php
     $data = [
         "foo"  => "Bar",
         "main" => array(

Some files were not shown because too many files changed in this diff