|
@@ -12,7 +12,7 @@
|
|
|
|
|
|
namespace PhpCsFixer\Fixer\Operator;
|
|
|
|
|
|
-use PhpCsFixer\AbstractFixer;
|
|
|
+use PhpCsFixer\Fixer\AbstractIncrementOperatorFixer;
|
|
|
use PhpCsFixer\Fixer\ConfigurationDefinitionFixerInterface;
|
|
|
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver;
|
|
|
use PhpCsFixer\FixerConfiguration\FixerOptionBuilder;
|
|
@@ -26,7 +26,7 @@ use PhpCsFixer\Tokenizer\TokensAnalyzer;
|
|
|
* @author Gregor Harlan <gharlan@web.de>
|
|
|
* @author Kuba Werłos <werlos@gmail.com>
|
|
|
*/
|
|
|
-final class IncrementStyleFixer extends AbstractFixer implements ConfigurationDefinitionFixerInterface
|
|
|
+final class IncrementStyleFixer extends AbstractIncrementOperatorFixer implements ConfigurationDefinitionFixerInterface
|
|
|
{
|
|
|
/**
|
|
|
* @internal
|
|
@@ -142,6 +142,7 @@ final class IncrementStyleFixer extends AbstractFixer implements ConfigurationDe
|
|
|
|
|
|
while ($nextToken->equalsAny([
|
|
|
'$',
|
|
|
+ '(',
|
|
|
'[',
|
|
|
[CT::T_DYNAMIC_PROP_BRACE_OPEN],
|
|
|
[CT::T_DYNAMIC_VAR_BRACE_OPEN],
|
|
@@ -170,48 +171,4 @@ final class IncrementStyleFixer extends AbstractFixer implements ConfigurationDe
|
|
|
|
|
|
return $index;
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * @param int $index
|
|
|
- *
|
|
|
- * @return int
|
|
|
- */
|
|
|
- private function findStart(Tokens $tokens, $index)
|
|
|
- {
|
|
|
- do {
|
|
|
- $index = $tokens->getPrevMeaningfulToken($index);
|
|
|
- $token = $tokens[$index];
|
|
|
-
|
|
|
- $blockType = Tokens::detectBlockType($token);
|
|
|
- if (null !== $blockType && !$blockType['isStart']) {
|
|
|
- $index = $tokens->findBlockStart($blockType['type'], $index);
|
|
|
- $token = $tokens[$index];
|
|
|
- }
|
|
|
- } while (!$token->equalsAny(['$', [T_VARIABLE]]));
|
|
|
-
|
|
|
- $prevIndex = $tokens->getPrevMeaningfulToken($index);
|
|
|
- $prevToken = $tokens[$prevIndex];
|
|
|
-
|
|
|
- if ($prevToken->equals('$')) {
|
|
|
- $index = $prevIndex;
|
|
|
- $prevIndex = $tokens->getPrevMeaningfulToken($index);
|
|
|
- $prevToken = $tokens[$prevIndex];
|
|
|
- }
|
|
|
-
|
|
|
- if ($prevToken->isGivenKind(T_OBJECT_OPERATOR)) {
|
|
|
- return $this->findStart($tokens, $prevIndex);
|
|
|
- }
|
|
|
-
|
|
|
- if ($prevToken->isGivenKind(T_PAAMAYIM_NEKUDOTAYIM)) {
|
|
|
- $prevPrevIndex = $tokens->getPrevMeaningfulToken($prevIndex);
|
|
|
- if (!$tokens[$prevPrevIndex]->isGivenKind([T_STATIC, T_STRING])) {
|
|
|
- return $this->findStart($tokens, $prevIndex);
|
|
|
- }
|
|
|
-
|
|
|
- $index = $tokens->getTokenNotOfKindSibling($prevIndex, -1, [[T_NS_SEPARATOR], [T_STATIC], [T_STRING]]);
|
|
|
- $index = $tokens->getNextMeaningfulToken($index);
|
|
|
- }
|
|
|
-
|
|
|
- return $index;
|
|
|
- }
|
|
|
}
|