Browse Source

Merge branch '1.12'

Conflicts:
	README.rst
	Symfony/CS/Fixer.php
	Symfony/CS/Fixer/Symfony/NoEmptyCommentFixer.php
	Symfony/CS/Tests/Fixer/AbstractFixerTestBase.php
	src/Tokenizer/Token.php
	src/Tokenizer/Tokens.php
Dariusz Ruminski 8 years ago
parent
commit
ea6aa70f41

+ 5 - 0
README.rst

@@ -567,6 +567,11 @@ Choose from the list of available fixers:
                          @type phpdoc tags must be
                          aligned vertically.
 
+* **phpdoc_annotation_without_dot** [@Symfony]
+                         Phpdocs annotation
+                         descriptions should not end
+                         with a full stop.
+
 * **phpdoc_indent** [@Symfony]
                          Docblocks should have the
                          same indentation as the

+ 2 - 2
src/Fixer/Alias/EregToPregFixer.php

@@ -23,7 +23,7 @@ final class EregToPregFixer extends AbstractFixer
 {
     /**
      * @var array the list of the ext/ereg function names, their preg equivalent and the preg modifier(s), if any
-     *            all condensed in an array of arrays.
+     *            all condensed in an array of arrays
      */
     private static $functions = array(
         array('ereg', 'preg_match', ''),
@@ -35,7 +35,7 @@ final class EregToPregFixer extends AbstractFixer
     );
 
     /**
-     * @var array the list of preg delimiters, in order of preference.
+     * @var array the list of preg delimiters, in order of preference
      */
     private static $delimiters = array('/', '#', '!');
 

+ 1 - 1
src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php

@@ -326,7 +326,7 @@ final class NoPhp4ConstructorFixer extends AbstractFixer
      *     - endIndex (int): The index of the function/method end.
      *     - bodyIndex (int): The index of the function/method body.
      *     - modifiers (array): The modifiers as array keys and their index as
-     *       the values, e.g. array(T_PUBLIC => 10).
+     *       the values, e.g. array(T_PUBLIC => 10)
      */
     private function findFunction(Tokens $tokens, $name, $startIndex, $endIndex)
     {

+ 1 - 1
src/Fixer/ControlStructure/NoUnneededControlParenthesesFixer.php

@@ -25,7 +25,7 @@ final class NoUnneededControlParenthesesFixer extends AbstractFixer
     /**
      * To be removed when PHP support will be 5.5+.
      *
-     * @var string[] List of statements to fix.
+     * @var string[] List of statements to fix
      */
     private $controlStatements = array(
         'break',

+ 1 - 1
src/Fixer/ControlStructure/NoUselessElseFixer.php

@@ -204,7 +204,7 @@ final class NoUselessElseFixer extends AbstractFixer
     /**
      * @param Tokens $tokens
      * @param int    $index           Index of the token to check
-     * @param int    $lowerLimitIndex Lower limit index. Since the token to check will always be in a conditional we must stop checking at this index.
+     * @param int    $lowerLimitIndex Lower limit index. Since the token to check will always be in a conditional we must stop checking at this index
      *
      * @return bool
      */

+ 1 - 1
src/Fixer/FunctionNotation/NoSpacesAfterFunctionNameFixer.php

@@ -100,7 +100,7 @@ final class NoSpacesAfterFunctionNameFixer extends AbstractFixer
     /**
      * Gets the token kinds which can work as function calls.
      *
-     * @return int[] Token names.
+     * @return int[] Token names
      */
     private function getFunctionyTokenKinds()
     {

+ 2 - 2
src/Fixer/PhpUnit/PhpUnitDedicateAssertFixer.php

@@ -149,9 +149,9 @@ final class PhpUnitDedicateAssertFixer extends AbstractFixer
 
     /**
      * @param Tokens $tokens
-     * @param int    $assertCallIndex Token index of assert method call.
+     * @param int    $assertCallIndex Token index of assert method call
      *
-     * @return int|int[] indexes of assert call, test call and positive flag, or last index checked.
+     * @return int|int[] indexes of assert call, test call and positive flag, or last index checked
      */
     private function getAssertCandidate(Tokens $tokens, $assertCallIndex)
     {

+ 66 - 0
src/Fixer/Phpdoc/PhpdocAnnotationWithoutDotFixer.php

@@ -0,0 +1,66 @@
+<?php
+
+/*
+ * This file is part of PHP CS Fixer.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *     Dariusz Rumiński <dariusz.ruminski@gmail.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace PhpCsFixer\Fixer\Phpdoc;
+
+use PhpCsFixer\AbstractFixer;
+use PhpCsFixer\DocBlock\DocBlock;
+use PhpCsFixer\Tokenizer\Tokens;
+
+/**
+ * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
+ */
+final class PhpdocAnnotationWithoutDotFixer extends AbstractFixer
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function isCandidate(Tokens $tokens)
+    {
+        return $tokens->isTokenKindFound(T_DOC_COMMENT);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function fix(\SplFileInfo $file, Tokens $tokens)
+    {
+        foreach ($tokens as $token) {
+            if (!$token->isGivenKind(T_DOC_COMMENT)) {
+                continue;
+            }
+
+            $doc = new DocBlock($token->getContent());
+            $annotations = $doc->getAnnotations();
+
+            if (empty($annotations)) {
+                continue;
+            }
+
+            foreach ($annotations as $annotation) {
+                if ($annotation->getTag()->valid()) {
+                    $line = $doc->getLine($annotation->getEnd());
+                    $line->setContent(preg_replace('/[.。](\s+)$/u', '\1', $line->getContent()));
+                }
+            }
+            $token->setContent($doc->getContent());
+        }
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getDescription()
+    {
+        return 'Phpdocs annotation descriptions should not end with a full stop.';
+    }
+}

+ 2 - 2
src/Fixer/ReturnNotation/NoUselessReturnFixer.php

@@ -64,8 +64,8 @@ final class NoUselessReturnFixer extends AbstractFixer
 
     /**
      * @param Tokens $tokens
-     * @param int    $start  Token index of the opening brace token of the function.
-     * @param int    $end    Token index of the closing brace token of the function.
+     * @param int    $start  Token index of the opening brace token of the function
+     * @param int    $end    Token index of the closing brace token of the function
      */
     private function fixFunction(Tokens $tokens, $start, $end)
     {

+ 1 - 1
src/FixerFactory.php

@@ -39,7 +39,7 @@ final class FixerFactory
     /**
      * Fixers by name.
      *
-     * @var FixerInterface[] Associative array of fixers with names as keys.
+     * @var FixerInterface[] Associative array of fixers with names as keys
      */
     private $fixersByName = array();
 

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