@@ -151,12 +151,12 @@ |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | if ($tokens[$i]->isGivenKind([ |
154 | - T_INCLUDE, // loading additional symbols we cannot analyze here |
|
155 | - T_INCLUDE_ONCE, // " |
|
156 | - T_REQUIRE, // " |
|
157 | - T_REQUIRE_ONCE, // " |
|
154 | + T_INCLUDE, // loading additional symbols we cannot analyze here |
|
155 | + T_INCLUDE_ONCE, // " |
|
156 | + T_REQUIRE, // " |
|
157 | + T_REQUIRE_ONCE, // " |
|
158 | 158 | CT::T_DYNAMIC_VAR_BRACE_OPEN, // "$h = ${$g};" case |
159 | - T_EVAL, // "$c = eval('return $this;');" case |
|
159 | + T_EVAL, // "$c = eval('return $this;');" case |
|
160 | 160 | ])) { |
161 | 161 | return true; |
162 | 162 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | (new FixerOptionBuilder('after_heredoc', 'Whether the whitespace between heredoc end and comma should be removed.')) |
189 | 189 | ->setAllowedTypes(['bool']) |
190 | 190 | ->setDefault(false) |
191 | - ->setNormalizer(static function (Options $options, $value) { |
|
191 | + ->setNormalizer(static function(Options $options, $value) { |
|
192 | 192 | if (\PHP_VERSION_ID < 70300 && $value) { |
193 | 193 | throw new InvalidOptionsForEnvException('"after_heredoc" option can only be enabled with PHP 7.3+.'); |
194 | 194 | } |
@@ -333,13 +333,13 @@ discard block |
||
333 | 333 | ; |
334 | 334 | } |
335 | 335 | |
336 | - $indentation = $existingIndentation.$this->whitespacesConfig->getIndent(); |
|
336 | + $indentation = $existingIndentation . $this->whitespacesConfig->getIndent(); |
|
337 | 337 | $endFunctionIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $startFunctionIndex); |
338 | 338 | |
339 | 339 | $wasWhitespaceBeforeEndFunctionAddedAsNewToken = $tokens->ensureWhitespaceAtIndex( |
340 | 340 | $tokens[$endFunctionIndex - 1]->isWhitespace() ? $endFunctionIndex - 1 : $endFunctionIndex, |
341 | 341 | 0, |
342 | - $this->whitespacesConfig->getLineEnding().$existingIndentation |
|
342 | + $this->whitespacesConfig->getLineEnding() . $existingIndentation |
|
343 | 343 | ); |
344 | 344 | |
345 | 345 | if ($wasWhitespaceBeforeEndFunctionAddedAsNewToken) { |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | if ($tokens[$index + 2]->isComment()) { |
394 | 394 | $nextMeaningfulTokenIndex = $tokens->getNextMeaningfulToken($index + 2); |
395 | 395 | if (!$this->isNewline($tokens[$nextMeaningfulTokenIndex - 1])) { |
396 | - $tokens->ensureWhitespaceAtIndex($nextMeaningfulTokenIndex, 0, $this->whitespacesConfig->getLineEnding().$indentation); |
|
396 | + $tokens->ensureWhitespaceAtIndex($nextMeaningfulTokenIndex, 0, $this->whitespacesConfig->getLineEnding() . $indentation); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | return; |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | return; |
405 | 405 | } |
406 | 406 | |
407 | - $tokens->ensureWhitespaceAtIndex($index + 1, 0, $this->whitespacesConfig->getLineEnding().$indentation); |
|
407 | + $tokens->ensureWhitespaceAtIndex($index + 1, 0, $this->whitespacesConfig->getLineEnding() . $indentation); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | /** |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | $info['secondArgument'] = $next; |
190 | - $info['levels'] = (int) $tokens[$next]->getContent(); |
|
190 | + $info['levels'] = (int)$tokens[$next]->getContent(); |
|
191 | 191 | |
192 | 192 | $next = $tokens->getNextMeaningfulToken($next); |
193 | 193 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | - $levelsToken = new Token([T_LNUMBER, (string) $levels]); |
|
223 | + $levelsToken = new Token([T_LNUMBER, (string)$levels]); |
|
224 | 224 | |
225 | 225 | if (isset($outerDirnameInfo['secondArgument'])) { |
226 | 226 | $tokens[$outerDirnameInfo['secondArgument']] = $levelsToken; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | private const REMOVE_WHITESPACE_AFTER_TOKENS = ['[']; |
31 | 31 | private const REMOVE_WHITESPACE_AROUND_TOKENS = ['(', [T_DOUBLE_COLON]]; |
32 | - private const REMOVE_WHITESPACE_BEFORE_TOKENS = [')', ']', ',', ';']; |
|
32 | + private const REMOVE_WHITESPACE_BEFORE_TOKENS = [')', ']', ',', ';']; |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * {@inheritdoc} |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | $endCandidateIndex = $tokens->getNextMeaningfulToken($index); |
76 | 76 | |
77 | - while (!$tokens[$endCandidateIndex]->equalsAny([')', ']', ',', ';'])) { |
|
77 | + while (!$tokens[$endCandidateIndex]->equalsAny([')', ']', ',', ';'])) { |
|
78 | 78 | $blockType = Tokens::detectBlockType($tokens[$endCandidateIndex]); |
79 | 79 | if (null !== $blockType) { |
80 | 80 | if (Tokens::BLOCK_TYPE_CURLY_BRACE === $blockType['type']) { |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | |
97 | 97 | if ($tokens[$index]->isGivenKind(T_COMMENT)) { |
98 | 98 | if (0 === strpos($content, '//')) { |
99 | - $content = '/*'.substr($content, 2).' */'; |
|
99 | + $content = '/*' . substr($content, 2) . ' */'; |
|
100 | 100 | $tokens->clearAt($index + 1); |
101 | 101 | } elseif (0 === strpos($content, '#')) { |
102 | - $content = '/*'.substr($content, 1).' */'; |
|
102 | + $content = '/*' . substr($content, 1) . ' */'; |
|
103 | 103 | $tokens->clearAt($index + 1); |
104 | 104 | } elseif (false !== Preg::match('/\R/', $content)) { |
105 | 105 | $content = Preg::replace('/\R/', ' ', $content); |
@@ -118,7 +118,7 @@ |
||
118 | 118 | return; // first argument is an expression like `call_user_func("foo"."bar", ...)`, not supported! |
119 | 119 | } |
120 | 120 | |
121 | - $newCallTokens = Tokens::fromCode('<?php '.substr(str_replace('\\\\', '\\', $firstArgToken->getContent()), 1, -1).'();'); |
|
121 | + $newCallTokens = Tokens::fromCode('<?php ' . substr(str_replace('\\\\', '\\', $firstArgToken->getContent()), 1, -1) . '();'); |
|
122 | 122 | $newCallTokensSize = $newCallTokens->count(); |
123 | 123 | $newCallTokens->clearAt(0); |
124 | 124 | $newCallTokens->clearRange($newCallTokensSize - 3, $newCallTokensSize - 1); |
@@ -189,7 +189,7 @@ |
||
189 | 189 | if ( |
190 | 190 | // skip anonymous classes |
191 | 191 | ($tokens[$i]->isGivenKind(T_CLASS) && $tokensAnalyzer->isAnonymousClass($i)) |
192 | - // skip lambda functions |
|
192 | + // skip lambda functions |
|
193 | 193 | || ($tokens[$i]->isGivenKind(T_FUNCTION) && $tokensAnalyzer->isLambda($i)) |
194 | 194 | ) { |
195 | 195 | $i = $tokens->getNextTokenOfKind($i, ['{']); |
@@ -44,18 +44,18 @@ |
||
44 | 44 | '{', |
45 | 45 | '}', |
46 | 46 | [CT::T_ARRAY_INDEX_CURLY_BRACE_OPEN], |
47 | - [T_AND_EQUAL], // &= |
|
47 | + [T_AND_EQUAL], // &= |
|
48 | 48 | [T_CONCAT_EQUAL], // .= |
49 | - [T_DIV_EQUAL], // /= |
|
50 | - [T_MINUS_EQUAL], // -= |
|
51 | - [T_MOD_EQUAL], // %= |
|
52 | - [T_MUL_EQUAL], // *= |
|
53 | - [T_OR_EQUAL], // |= |
|
54 | - [T_PLUS_EQUAL], // += |
|
55 | - [T_POW_EQUAL], // **= |
|
56 | - [T_SL_EQUAL], // <<= |
|
57 | - [T_SR_EQUAL], // >>= |
|
58 | - [T_XOR_EQUAL], // ^= |
|
49 | + [T_DIV_EQUAL], // /= |
|
50 | + [T_MINUS_EQUAL], // -= |
|
51 | + [T_MOD_EQUAL], // %= |
|
52 | + [T_MUL_EQUAL], // *= |
|
53 | + [T_OR_EQUAL], // |= |
|
54 | + [T_PLUS_EQUAL], // += |
|
55 | + [T_POW_EQUAL], // **= |
|
56 | + [T_SL_EQUAL], // <<= |
|
57 | + [T_SR_EQUAL], // >>= |
|
58 | + [T_XOR_EQUAL], // ^= |
|
59 | 59 | ]; |
60 | 60 | |
61 | 61 | /** |
@@ -314,14 +314,14 @@ discard block |
||
314 | 314 | ->getOption(), |
315 | 315 | (new FixerOptionBuilder('operators', 'Dictionary of `binary operator` => `fix strategy` values that differ from the default strategy.')) |
316 | 316 | ->setAllowedTypes(['array']) |
317 | - ->setAllowedValues([static function (array $option) { |
|
317 | + ->setAllowedValues([static function(array $option) { |
|
318 | 318 | foreach ($option as $operator => $value) { |
319 | 319 | if (!\in_array($operator, self::SUPPORTED_OPERATORS, true)) { |
320 | 320 | throw new InvalidOptionsException( |
321 | 321 | sprintf( |
322 | 322 | 'Unexpected "operators" key, expected any of "%s", got "%s".', |
323 | 323 | implode('", "', self::SUPPORTED_OPERATORS), |
324 | - \gettype($operator).'#'.$operator |
|
324 | + \gettype($operator) . '#' . $operator |
|
325 | 325 | ) |
326 | 326 | ); |
327 | 327 | } |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | 'Unexpected value for operator "%s", expected any of "%s", got "%s".', |
333 | 333 | $operator, |
334 | 334 | implode('", "', self::$allowedValues), |
335 | - \is_object($value) ? \get_class($value) : (null === $value ? 'null' : \gettype($value).'#'.$value) |
|
335 | + \is_object($value) ? \get_class($value) : (null === $value ? 'null' : \gettype($value) . '#' . $value) |
|
336 | 336 | ) |
337 | 337 | ); |
338 | 338 | } |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | && $this->tokensAnalyzer->isBinaryOperator($index) |
539 | 539 | && ('=' !== $content || !$this->isEqualPartOfDeclareStatement($tokens, $index)) |
540 | 540 | ) { |
541 | - $tokens[$index] = new Token(sprintf(self::ALIGN_PLACEHOLDER, $this->deepestLevel).$content); |
|
541 | + $tokens[$index] = new Token(sprintf(self::ALIGN_PLACEHOLDER, $this->deepestLevel) . $content); |
|
542 | 542 | |
543 | 543 | continue; |
544 | 544 | } |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | } |
603 | 603 | |
604 | 604 | if ($token->isGivenKind(T_DOUBLE_ARROW)) { // no need to analyze for `isBinaryOperator` (always true), nor if part of declare statement (not valid PHP) |
605 | - $tokenContent = sprintf(self::ALIGN_PLACEHOLDER, $this->currentLevel).$token->getContent(); |
|
605 | + $tokenContent = sprintf(self::ALIGN_PLACEHOLDER, $this->currentLevel) . $token->getContent(); |
|
606 | 606 | |
607 | 607 | $nextToken = $tokens[$index + 1]; |
608 | 608 | if (!$nextToken->isWhitespace()) { |
@@ -723,11 +723,11 @@ discard block |
||
723 | 723 | } |
724 | 724 | } elseif (self::ALIGN_SINGLE_SPACE_MINIMAL === $alignStrategy) { |
725 | 725 | if (1 !== Preg::match('/^\h+$/', $before)) { // if indent; do not move, leave to other fixer |
726 | - $before = rtrim($before).' '; |
|
726 | + $before = rtrim($before) . ' '; |
|
727 | 727 | } |
728 | 728 | } |
729 | 729 | |
730 | - $lines[$index] = $before.substr($lines[$index], $currentPosition); |
|
730 | + $lines[$index] = $before . substr($lines[$index], $currentPosition); |
|
731 | 731 | } |
732 | 732 | } |
733 | 733 | |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | $delta = abs($rightmostSymbol - $currentSymbol); |
743 | 743 | |
744 | 744 | if ($delta > 0) { |
745 | - $line = str_replace($placeholder, str_repeat(' ', $delta).$placeholder, $line); |
|
745 | + $line = str_replace($placeholder, str_repeat(' ', $delta) . $placeholder, $line); |
|
746 | 746 | $lines[$index] = $line; |
747 | 747 | } |
748 | 748 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | private function getCasesColonsForSwitch(Tokens $tokens, int $switchIndex): array |
185 | 185 | { |
186 | 186 | return array_map( |
187 | - static function (CaseAnalysis $caseAnalysis) { |
|
187 | + static function(CaseAnalysis $caseAnalysis) { |
|
188 | 188 | return $caseAnalysis->getColonIndex(); |
189 | 189 | }, |
190 | 190 | (new SwitchAnalyzer())->getSwitchAnalysis($tokens, $switchIndex)->getCases() |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | private function getReplacementsAndClear(Tokens $tokens, array $indices, int $direction): array |
282 | 282 | { |
283 | 283 | return array_map( |
284 | - static function (int $index) use ($tokens, $direction) { |
|
284 | + static function(int $index) use ($tokens, $direction) { |
|
285 | 285 | $clone = $tokens[$index]; |
286 | 286 | if ($tokens[$index + $direction]->isWhitespace()) { |
287 | 287 | $tokens->clearAt($index + $direction); |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | [T_MOD_EQUAL], [T_MUL_EQUAL], [T_OR_EQUAL], [T_PAAMAYIM_NEKUDOTAYIM], [T_PLUS_EQUAL], [T_POW], |
316 | 316 | [T_POW_EQUAL], [T_SL], [T_SL_EQUAL], [T_SR], [T_SR_EQUAL], [T_XOR_EQUAL], |
317 | 317 | ], |
318 | - array_map(function ($id) { return [$id]; }, Token::getObjectOperatorKinds()) |
|
318 | + array_map(function($id) { return [$id]; }, Token::getObjectOperatorKinds()) |
|
319 | 319 | ); |
320 | 320 | } |
321 | 321 | } |