@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | return new FixerConfigurationResolver([ |
150 | 150 | (new FixerOptionBuilder('replacements', 'Mapping between replaced return types with new ones.')) |
151 | 151 | ->setAllowedTypes(['array']) |
152 | - ->setNormalizer(static function (Options $options, $value) use ($default) { |
|
152 | + ->setNormalizer(static function(Options $options, $value) use ($default) { |
|
153 | 153 | $normalizedValue = []; |
154 | 154 | foreach ($value as $from => $to) { |
155 | 155 | if (\is_string($from)) { |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | if (!isset($default[$from])) { |
160 | 160 | throw new InvalidOptionsException(sprintf( |
161 | 161 | 'Unknown key "%s", expected any of "%s".', |
162 | - \is_object($from) ? \get_class($from) : \gettype($from).(\is_resource($from) ? '' : '#'.$from), |
|
162 | + \is_object($from) ? \get_class($from) : \gettype($from) . (\is_resource($from) ? '' : '#' . $from), |
|
163 | 163 | implode('", "', array_keys($default)) |
164 | 164 | )); |
165 | 165 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | if (!\in_array($to, self::$toTypes, true)) { |
168 | 168 | throw new InvalidOptionsException(sprintf( |
169 | 169 | 'Unknown value "%s", expected any of "%s".', |
170 | - \is_object($to) ? \get_class($to) : \gettype($to).(\is_resource($to) ? '' : '#'.$to), |
|
170 | + \is_object($to) ? \get_class($to) : \gettype($to) . (\is_resource($to) ? '' : '#' . $to), |
|
171 | 171 | implode('", "', self::$toTypes) |
172 | 172 | )); |
173 | 173 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $regularExpression = sprintf( |
94 | 94 | '/({?@(?:%s).*?(?:(?=\s\*\/)|(?=\n)}?))/i', |
95 | 95 | implode('|', array_map( |
96 | - function (string $tag) { |
|
96 | + function(string $tag) { |
|
97 | 97 | return preg_quote($tag, '/'); |
98 | 98 | }, |
99 | 99 | array_keys($this->configuration['tags']) |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | } |
132 | 132 | |
133 | 133 | if ('inline' === $this->configuration['tags'][$tagName]) { |
134 | - $parts[$i] = '{'.$tag.'}'; |
|
134 | + $parts[$i] = '{' . $tag . '}'; |
|
135 | 135 | |
136 | 136 | continue; |
137 | 137 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | return new FixerConfigurationResolver([ |
154 | 154 | (new FixerOptionBuilder('tags', 'The list of tags to fix')) |
155 | 155 | ->setAllowedTypes(['array']) |
156 | - ->setAllowedValues([function ($value) { |
|
156 | + ->setAllowedValues([function($value) { |
|
157 | 157 | foreach ($value as $type) { |
158 | 158 | if (!\in_array($type, ['annotation', 'inline'], true)) { |
159 | 159 | throw new InvalidOptionsException("Unknown tag type \"{$type}\"."); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | 'var' => 'annotation', |
186 | 186 | 'version' => 'annotation', |
187 | 187 | ]) |
188 | - ->setNormalizer(function (Options $options, $value) { |
|
188 | + ->setNormalizer(function(Options $options, $value) { |
|
189 | 189 | $normalized = []; |
190 | 190 | foreach ($value as $tag => $type) { |
191 | 191 | $normalized[strtolower($tag)] = $type; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | // start index of the sequence is always 1 here, 0 is always open tag |
136 | 136 | // transform "<?php\n" to "<?php " if needed |
137 | 137 | if (false !== strpos($tokens[0]->getContent(), "\n")) { |
138 | - $tokens[0] = new Token([$tokens[0]->getId(), trim($tokens[0]->getContent()).' ']); |
|
138 | + $tokens[0] = new Token([$tokens[0]->getId(), trim($tokens[0]->getContent()) . ' ']); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | if ($endIndex === \count($tokens) - 1) { |
@@ -150,6 +150,6 @@ discard block |
||
150 | 150 | } |
151 | 151 | |
152 | 152 | $content = $tokens[1 + $endIndex]->getContent(); |
153 | - $tokens[1 + $endIndex] = new Token([T_WHITESPACE, $lineEnding.ltrim($content, " \t")]); |
|
153 | + $tokens[1 + $endIndex] = new Token([T_WHITESPACE, $lineEnding . ltrim($content, " \t")]); |
|
154 | 154 | } |
155 | 155 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | 'PHP code MUST use only UTF-8 without BOM (remove BOM).', |
50 | 50 | [ |
51 | 51 | new CodeSample( |
52 | - $this->BOM.'<?php |
|
52 | + $this->BOM . '<?php |
|
53 | 53 | |
54 | 54 | echo "Hello!"; |
55 | 55 | ' |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | 'Remove Zero-width space (ZWSP), Non-breaking space (NBSP) and other invisible unicode symbols.', |
72 | 72 | [ |
73 | 73 | new CodeSample( |
74 | - '<?php echo "'.pack('H*', 'e2808b').'Hello'.pack('H*', 'e28087').'World'.pack('H*', 'c2a0')."!\";\n" |
|
74 | + '<?php echo "' . pack('H*', 'e2808b') . 'Hello' . pack('H*', 'e28087') . 'World' . pack('H*', 'c2a0') . "!\";\n" |
|
75 | 75 | ), |
76 | 76 | new VersionSpecificCodeSample( |
77 | - '<?php echo "'.pack('H*', 'e2808b').'Hello'.pack('H*', 'e28087').'World'.pack('H*', 'c2a0')."!\";\n", |
|
77 | + '<?php echo "' . pack('H*', 'e2808b') . 'Hello' . pack('H*', 'e28087') . 'World' . pack('H*', 'c2a0') . "!\";\n", |
|
78 | 78 | new VersionSpecification(70000), |
79 | 79 | ['use_escape_sequences_in_strings' => false] |
80 | 80 | ), |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | (new FixerOptionBuilder('use_escape_sequences_in_strings', 'Whether characters should be replaced with escape sequences in strings.')) |
110 | 110 | ->setAllowedTypes(['bool']) |
111 | 111 | ->setDefault(true) |
112 | - ->setNormalizer(static function (Options $options, $value) { |
|
112 | + ->setNormalizer(static function(Options $options, $value) { |
|
113 | 113 | if (\PHP_VERSION_ID < 70000 && $value) { |
114 | 114 | throw new InvalidOptionsForEnvException('Escape sequences require PHP 7.0+.'); |
115 | 115 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | |
131 | 131 | foreach ($this->symbolsReplace as $character => [$replacement, $codepoint]) { |
132 | 132 | $replacements[$character] = $replacement; |
133 | - $escapeSequences[$character] = '\u{'.$codepoint.'}'; |
|
133 | + $escapeSequences[$character] = '\u{' . $codepoint . '}'; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | foreach ($tokens as $index => $token) { |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $this->configuration['use_escape_sequences_in_strings'] |
141 | 141 | && $token->isGivenKind([T_CONSTANT_ENCAPSED_STRING, T_ENCAPSED_AND_WHITESPACE]) |
142 | 142 | ) { |
143 | - if (!Preg::match('/'.implode('|', array_keys($escapeSequences)).'/', $content)) { |
|
143 | + if (!Preg::match('/' . implode('|', array_keys($escapeSequences)) . '/', $content)) { |
|
144 | 144 | continue; |
145 | 145 | } |
146 | 146 |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | |
218 | 218 | if ($originalNamespace !== $newNamespace && strtolower($originalNamespace) === strtolower($newNamespace)) { |
219 | 219 | $tokens->clearRange($namespaceStartIndex, $namespaceEndIndex); |
220 | - $namespace = substr($namespace, 0, -\strlen($newNamespace)).$newNamespace; |
|
220 | + $namespace = substr($namespace, 0, -\strlen($newNamespace)) . $newNamespace; |
|
221 | 221 | |
222 | - $newNamespace = Tokens::fromCode('<?php namespace '.$namespace.';'); |
|
222 | + $newNamespace = Tokens::fromCode('<?php namespace ' . $namespace . ';'); |
|
223 | 223 | $newNamespace->clearRange(0, 2); |
224 | 224 | $newNamespace->clearEmptyTokens(); |
225 | 225 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | $maxNamespace = $this->calculateMaxNamespace($file, $namespace); |
235 | 235 | |
236 | 236 | if (null !== $this->configuration['dir']) { |
237 | - return ('' !== $maxNamespace ? (str_replace('\\', '_', $maxNamespace).'_') : '').$name; |
|
237 | + return ('' !== $maxNamespace ? (str_replace('\\', '_', $maxNamespace) . '_') : '') . $name; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | $namespaceParts = array_reverse(explode('\\', $maxNamespace)); |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $previousToken = $tokens[$i - 1]; |
242 | 242 | $tokens[$i] = $previousToken; |
243 | 243 | if ($tokens[$i]->isWhitespace() && $tokens[$i + 1]->isWhitespace()) { |
244 | - $tokens[$i] = new Token([T_WHITESPACE, $tokens[$i]->getContent().$tokens[$i + 1]->getContent()]); |
|
244 | + $tokens[$i] = new Token([T_WHITESPACE, $tokens[$i]->getContent() . $tokens[$i + 1]->getContent()]); |
|
245 | 245 | $tokens->clearAt($i + 1); |
246 | 246 | } |
247 | 247 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $index - 1, |
278 | 278 | 1, |
279 | 279 | self::LINE_NEXT === $this->configuration['position_after_control_structures'] ? |
280 | - $this->whitespacesConfig->getLineEnding().WhitespacesAnalyzer::detectIndent($tokens, $index) |
|
280 | + $this->whitespacesConfig->getLineEnding() . WhitespacesAnalyzer::detectIndent($tokens, $index) |
|
281 | 281 | : ' ' |
282 | 282 | ); |
283 | 283 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | $controlTokens = $this->getControlTokens(); |
314 | 314 | $indentTokens = array_filter( |
315 | 315 | array_merge($classyAndFunctionTokens, $controlTokens), |
316 | - static function (int $item) { |
|
316 | + static function(int $item) { |
|
317 | 317 | return T_SWITCH !== $item; |
318 | 318 | } |
319 | 319 | ); |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | $indent = WhitespacesAnalyzer::detectIndent($tokens, $index); |
402 | 402 | |
403 | 403 | // fix indent near closing brace |
404 | - $tokens->ensureWhitespaceAtIndex($endBraceIndex - 1, 1, $this->whitespacesConfig->getLineEnding().$indent); |
|
404 | + $tokens->ensureWhitespaceAtIndex($endBraceIndex - 1, 1, $this->whitespacesConfig->getLineEnding() . $indent); |
|
405 | 405 | |
406 | 406 | // fix indent between braces |
407 | 407 | $lastCommaIndex = $tokens->getPrevTokenOfKind($endBraceIndex - 1, [';', '}']); |
@@ -500,10 +500,10 @@ discard block |
||
500 | 500 | } |
501 | 501 | } |
502 | 502 | |
503 | - $whitespace = $nextWhitespace.$this->whitespacesConfig->getLineEnding().$indent; |
|
503 | + $whitespace = $nextWhitespace . $this->whitespacesConfig->getLineEnding() . $indent; |
|
504 | 504 | |
505 | 505 | if (!$nextNonWhitespaceNestToken->equals('}')) { |
506 | - $determineIsIndentableBlockContent = static function (int $contentIndex) use ($tokens): bool { |
|
506 | + $determineIsIndentableBlockContent = static function(int $contentIndex) use ($tokens): bool { |
|
507 | 507 | if (!$tokens[$contentIndex]->isComment()) { |
508 | 508 | return true; |
509 | 509 | } |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | |
562 | 562 | // fix indent near opening brace |
563 | 563 | if (isset($tokens[$startBraceIndex + 2]) && $tokens[$startBraceIndex + 2]->equals('}')) { |
564 | - $tokens->ensureWhitespaceAtIndex($startBraceIndex + 1, 0, $this->whitespacesConfig->getLineEnding().$indent); |
|
564 | + $tokens->ensureWhitespaceAtIndex($startBraceIndex + 1, 0, $this->whitespacesConfig->getLineEnding() . $indent); |
|
565 | 565 | } else { |
566 | 566 | $nextToken = $tokens[$startBraceIndex + 1]; |
567 | 567 | $nextNonWhitespaceToken = $tokens[$tokens->getNextNonWhitespace($startBraceIndex)]; |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | $this->ensureWhitespaceAtIndexAndIndentMultilineComment( |
575 | 575 | $tokens, |
576 | 576 | $startBraceIndex + 1, |
577 | - $this->whitespacesConfig->getLineEnding().$indent.$this->whitespacesConfig->getIndent() |
|
577 | + $this->whitespacesConfig->getLineEnding() . $indent . $this->whitespacesConfig->getIndent() |
|
578 | 578 | ); |
579 | 579 | } |
580 | 580 | } |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | if (self::LINE_SAME === $this->configuration['position_after_functions_and_oop_constructs'] && !$tokens[$tokens->getPrevNonWhitespace($startBraceIndex)]->isComment()) { |
584 | 584 | $ensuredWhitespace = ' '; |
585 | 585 | } else { |
586 | - $ensuredWhitespace = $this->whitespacesConfig->getLineEnding().$indent; |
|
586 | + $ensuredWhitespace = $this->whitespacesConfig->getLineEnding() . $indent; |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | $tokens->ensureWhitespaceAtIndex($startBraceIndex - 1, 1, $ensuredWhitespace); |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | ) { |
627 | 627 | $ensuredWhitespace = ' '; |
628 | 628 | } else { |
629 | - $ensuredWhitespace = $this->whitespacesConfig->getLineEnding().$indent; |
|
629 | + $ensuredWhitespace = $this->whitespacesConfig->getLineEnding() . $indent; |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | $tokens->ensureWhitespaceAtIndex($startBraceIndex - 1, 1, $ensuredWhitespace); |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | $index + 1, |
719 | 719 | 0, |
720 | 720 | self::LINE_NEXT === $this->configuration['position_after_control_structures'] && !$tokens[$nextNonWhitespaceIndex]->equals('(') ? |
721 | - $this->whitespacesConfig->getLineEnding().WhitespacesAnalyzer::detectIndent($tokens, $index) |
|
721 | + $this->whitespacesConfig->getLineEnding() . WhitespacesAnalyzer::detectIndent($tokens, $index) |
|
722 | 722 | : ' ' |
723 | 723 | ); |
724 | 724 | } |
@@ -899,8 +899,8 @@ discard block |
||
899 | 899 | $previousToken->isWhitespace() |
900 | 900 | && 1 === Preg::match('/\R$/', $previousToken->getContent()) |
901 | 901 | && ( |
902 | - (0 === strpos($nextTokenContent, '//'.$this->whitespacesConfig->getIndent()) || '//' === $nextTokenContent) |
|
903 | - || (0 === strpos($nextTokenContent, '#'.$this->whitespacesConfig->getIndent()) || '#' === $nextTokenContent) |
|
902 | + (0 === strpos($nextTokenContent, '//' . $this->whitespacesConfig->getIndent()) || '//' === $nextTokenContent) |
|
903 | + || (0 === strpos($nextTokenContent, '#' . $this->whitespacesConfig->getIndent()) || '#' === $nextTokenContent) |
|
904 | 904 | ) |
905 | 905 | ) { |
906 | 906 | return; |
@@ -909,8 +909,8 @@ discard block |
||
909 | 909 | $tokens[$nextTokenIndex] = new Token([ |
910 | 910 | $nextToken->getId(), |
911 | 911 | Preg::replace( |
912 | - '/(\R)'.WhitespacesAnalyzer::detectIndent($tokens, $nextTokenIndex).'(\h*\S+.*)/', |
|
913 | - '$1'.Preg::replace('/^.*\R(\h*)$/s', '$1', $whitespace).'$2', |
|
912 | + '/(\R)' . WhitespacesAnalyzer::detectIndent($tokens, $nextTokenIndex) . '(\h*\S+.*)/', |
|
913 | + '$1' . Preg::replace('/^.*\R(\h*)$/s', '$1', $whitespace) . '$2', |
|
914 | 914 | $nextToken->getContent() |
915 | 915 | ), |
916 | 916 | ]); |
@@ -32,7 +32,7 @@ |
||
32 | 32 | |
33 | 33 | foreach (['namespace Foo \\ Bar;', 'echo foo /* comment */ \\ bar();'] as $sample) { |
34 | 34 | $samples[] = new VersionSpecificCodeSample( |
35 | - "<?php\n".$sample."\n", |
|
35 | + "<?php\n" . $sample . "\n", |
|
36 | 36 | new VersionSpecification(null, 80000 - 1) |
37 | 37 | ); |
38 | 38 | } |
@@ -128,9 +128,9 @@ |
||
128 | 128 | { |
129 | 129 | $ending = $this->whitespacesConfig->getLineEnding(); |
130 | 130 | |
131 | - $emptyLines = $isLastIndex ? $ending : $ending.$ending; |
|
131 | + $emptyLines = $isLastIndex ? $ending : $ending . $ending; |
|
132 | 132 | $indent = 1 === Preg::match('/^.*\R( *)$/s', $currentContent, $matches) ? $matches[1] : ''; |
133 | 133 | |
134 | - return new Token([T_WHITESPACE, $emptyLines.$indent]); |
|
134 | + return new Token([T_WHITESPACE, $emptyLines . $indent]); |
|
135 | 135 | } |
136 | 136 | } |