Browse Source

Merge branch 'master' into 3.0

* master:
  fix test
  PHP8 - Constructor Property Promotion support
  PHP8 - Constructor Property Promotion support
  remove not supported verbose options
  prepared the 2.15.10 release
  TernaryToNullCoalescingFixer - concat precedence fix
  PHP8 - update sets
  Fix PHPDoc line span fixer when property has array typehint
SpacePossum 4 years ago
parent
commit
3cf3a4c0ee

+ 27 - 0
CHANGELOG.md

@@ -274,6 +274,33 @@ Changelog for v2.16.0
 * minor #4619 Fix PHP 7.3 strict mode warnings (keradus)
 * minor #4621 Add single_line_throw to Symfony ruleset (keradus)
 
+Changelog for v2.15.10
+----------------------
+
+* bug #5095 Annotation - fix for Windows line endings (SpacePossum)
+* bug #5221 NoSuperfluousPhpdocTagsFixer - fix for single line PHPDoc (kubawerlos)
+* bug #5225 TernaryOperatorSpacesFixer - fix for alternative control structures (kubawerlos)
+* bug #5235 ArrayIndentationFixer - fix for nested arrays (kubawerlos)
+* bug #5248 NoBreakCommentFixer - fix throw detect (SpacePossum)
+* bug #5250 SwitchAnalyzer - fix for semicolon after case/default (kubawerlos)
+* bug #5253 IO - fix cache info message (SpacePossum)
+* bug #5274 TernaryToNullCoalescingFixer - concat precedence fix (SpacePossum)
+* feature #5216 Add RuleSets to docs (SpacePossum)
+* minor #5226 Applied CS fixes from 2.17-dev (GrahamCampbell)
+* minor #5229 Fixed incorrect phpdoc (GrahamCampbell)
+* minor #5231 CS: unify styling with younger branches (keradus)
+* minor #5232 PHP8 - throw expression support (SpacePossum)
+* minor #5233 DX: simplify check_file_permissions.sh (kubawerlos)
+* minor #5236 Improve handling of unavailable code samples (julienfalque, keradus)
+* minor #5239 PHP8 - Allow trailing comma in parameter list support (SpacePossum)
+* minor #5254 PHP8 - mixed type support (SpacePossum)
+* minor #5255 Tests: do not skip documentation test (keradus)
+* minor #5261 Do not update Composer twice (sanmai)
+* minor #5263 PHP8 support (SpacePossum)
+* minor #5266 PhpUnitTestCaseStaticMethodCallsFixer - PHPUnit 9.x support (sanmai)
+* minor #5267 Improve InstallViaComposerTest (sanmai)
+* minor #5276 PHP8 - add NoUnreachableDefaultArgumentValueFixer to risky set (SpacePossum)
+
 Changelog for v2.15.9
 ---------------------
 

+ 2 - 0
doc/ruleSets/PHP80MigrationRisky.rst

@@ -12,4 +12,6 @@ Rules
 - `no_alias_functions <./../rules/alias/no_alias_functions.rst>`_
   config:
   ``['sets' => ['@all']]``
+- `no_php4_constructor <./../rules/class_notation/no_php4_constructor.rst>`_
 - `no_unneeded_final_method <./../rules/class_notation/no_unneeded_final_method.rst>`_
+- `no_unreachable_default_argument_value <./../rules/function_notation/no_unreachable_default_argument_value.rst>`_

+ 3 - 0
doc/rules/class_notation/no_php4_constructor.rst

@@ -34,6 +34,9 @@ Rule sets
 
 The rule is part of the following rule sets:
 
+@PHP80Migration:risky
+  Using the `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_ rule set will enable the ``no_php4_constructor`` rule.
+
 @PhpCsFixer:risky
   Using the `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_ rule set will enable the ``no_php4_constructor`` rule.
 

+ 4 - 1
doc/rules/function_notation/no_unreachable_default_argument_value.rst

@@ -29,7 +29,10 @@ Example #1
 Rule sets
 ---------
 
-The rule is part of the following rule set:
+The rule is part of the following rule sets:
+
+@PHP80Migration:risky
+  Using the `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_ rule set will enable the ``no_unreachable_default_argument_value`` rule.
 
 @PhpCsFixer:risky
   Using the `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_ rule set will enable the ``no_unreachable_default_argument_value`` rule.

+ 3 - 4
doc/usage.rst

@@ -31,10 +31,9 @@ The ``--verbose`` option will show the applied rules. When using the ``txt`` for
 
 NOTE: if there is an error like "errors reported during linting after fixing", you can use this to be even more verbose for debugging purpose
 
-* ``--verbose=0`` or no option: normal
-* ``--verbose``, ``--verbose=1``, ``-v``: verbose
-* ``--verbose=2``, ``-vv``: very verbose
-* ``--verbose=3``, ``-vvv``: debug
+* `-v`: verbose
+* `-vv`: very verbose
+* `-vvv`: debug
 
 The ``--rules`` option limits the rules to apply to the
 project:

+ 4 - 0
phpstan.neon

@@ -43,4 +43,8 @@ parameters:
         - # https://github.com/phpstan/phpstan/issues/1215
             message: '/^Strict comparison using === between false and string will always evaluate to false\.$/'
             path: src/Fixer/StringNotation/NoTrailingWhitespaceInStringFixer.php
+        -
+            message: '/^Property .*::\$indicator .* does not accept null\.$/'
+            path: tests/Indicator/PhpUnitTestCaseIndicatorTest.php
+
     tipsOfTheDay: false

+ 3 - 4
src/Console/Command/HelpCommand.php

@@ -77,10 +77,9 @@ The <comment>--verbose</comment> option will show the applied rules. When using
 
 NOTE: if there is an error like "errors reported during linting after fixing", you can use this to be even more verbose for debugging purpose
 
-* `--verbose=0` or no option: normal
-* `--verbose`, `--verbose=1`, `-v`: verbose
-* `--verbose=2`, `-vv`: very verbose
-* `--verbose=3`, `-vvv`: debug
+* `-v`: verbose
+* `-vv`: very verbose
+* `-vvv`: debug
 
 The <comment>--rules</comment> option limits the rules to apply to the
 project:

+ 17 - 6
src/Fixer/Alias/PowToExponentiationFixer.php

@@ -30,7 +30,7 @@ final class PowToExponentiationFixer extends AbstractFunctionReferenceFixer
      */
     public function isCandidate(Tokens $tokens)
     {
-        // minimal candidate to fix is seven tokens: pow(x,x);
+        // minimal candidate to fix is seven tokens: pow(x,y);
         return $tokens->count() > 7 && $tokens->isTokenKindFound(T_STRING);
     }
 
@@ -68,9 +68,9 @@ final class PowToExponentiationFixer extends AbstractFunctionReferenceFixer
     {
         $candidates = $this->findPowCalls($tokens);
         $argumentsAnalyzer = new ArgumentsAnalyzer();
-
         $numberOfTokensAdded = 0;
         $previousCloseParenthesisIndex = \count($tokens);
+
         foreach (array_reverse($candidates) as $candidate) {
             // if in the previous iteration(s) tokens were added to the collection and this is done within the tokens
             // indexes of the current candidate than the index of the close ')' of the candidate has moved and so
@@ -84,10 +84,17 @@ final class PowToExponentiationFixer extends AbstractFunctionReferenceFixer
             }
 
             $arguments = $argumentsAnalyzer->getArguments($tokens, $candidate[1], $candidate[2]);
+
             if (2 !== \count($arguments)) {
                 continue;
             }
 
+            for ($i = $candidate[1]; $i < $candidate[2]; ++$i) {
+                if ($tokens[$i]->isGivenKind(T_ELLIPSIS)) {
+                    continue 2;
+                }
+            }
+
             $numberOfTokensAdded += $this->fixPowToExponentiation(
                 $tokens,
                 $candidate[0], // functionNameIndex,
@@ -105,12 +112,13 @@ final class PowToExponentiationFixer extends AbstractFunctionReferenceFixer
     {
         $candidates = [];
 
-        // Minimal candidate to fix is seven tokens: pow(x,x);
+        // Minimal candidate to fix is seven tokens: pow(x,y);
         $end = \count($tokens) - 6;
 
         // First possible location is after the open token: 1
         for ($i = 1; $i < $end; ++$i) {
             $candidate = $this->find('pow', $tokens, $i, $end);
+
             if (null === $candidate) {
                 break;
             }
@@ -139,11 +147,13 @@ final class PowToExponentiationFixer extends AbstractFunctionReferenceFixer
         // clean up the function call tokens prt. I
         $tokens->clearAt($closeParenthesisIndex);
         $previousIndex = $tokens->getPrevMeaningfulToken($closeParenthesisIndex);
+
         if ($tokens[$previousIndex]->equals(',')) {
             $tokens->clearAt($previousIndex); // trailing ',' in function call (PHP 7.3)
         }
 
         $added = 0;
+
         // check if the arguments need to be wrapped in parenthesis
         foreach (array_reverse($arguments, true) as $argumentStartIndex => $argumentEndIndex) {
             if ($this->isParenthesisNeeded($tokens, $argumentStartIndex, $argumentEndIndex)) {
@@ -157,9 +167,10 @@ final class PowToExponentiationFixer extends AbstractFunctionReferenceFixer
         $tokens->clearAt($openParenthesisIndex);
         $tokens->clearAt($functionNameIndex);
 
-        $prev = $tokens->getPrevMeaningfulToken($functionNameIndex);
-        if ($tokens[$prev]->isGivenKind(T_NS_SEPARATOR)) {
-            $tokens->clearAt($prev);
+        $prevMeaningfulTokenIndex = $tokens->getPrevMeaningfulToken($functionNameIndex);
+
+        if ($tokens[$prevMeaningfulTokenIndex]->isGivenKind(T_NS_SEPARATOR)) {
+            $tokens->clearAt($prevMeaningfulTokenIndex);
         }
 
         return $added;

+ 12 - 0
src/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixer.php

@@ -114,6 +114,18 @@ final class SingleSpaceAfterConstructFixer extends AbstractFixer implements Conf
         foreach ($this->configuration['constructs'] as $key) {
             $this->fixTokenMap[$key] = self::$tokenMap[$key];
         }
+
+        if (isset($this->fixTokenMap['public'])) {
+            $this->fixTokenMap['constructor_public'] = CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PUBLIC;
+        }
+
+        if (isset($this->fixTokenMap['protected'])) {
+            $this->fixTokenMap['constructor_protected'] = CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PROTECTED;
+        }
+
+        if (isset($this->fixTokenMap['private'])) {
+            $this->fixTokenMap['constructor_private'] = CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PRIVATE;
+        }
     }
 
     /**

+ 1 - 0
src/Fixer/Operator/TernaryToNullCoalescingFixer.php

@@ -182,6 +182,7 @@ final class TernaryToNullCoalescingFixer extends AbstractFixer
             '^',
             '|',
             '~',
+            '.',
         ];
 
         return isset($operatorsPerId[$token->getId()]) || $token->equalsAny($operatorsPerContent);

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