@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $indent = $this->indent; |
102 | 102 | |
103 | 103 | // change indent to expected one |
104 | - $content = Preg::replaceCallback('/^(?: )+/m', function (array $matches) use ($indent) { |
|
104 | + $content = Preg::replaceCallback('/^(?: )+/m', function(array $matches) use ($indent) { |
|
105 | 105 | return $this->getExpectedIndent($matches[0], $indent); |
106 | 106 | }, $content); |
107 | 107 | |
@@ -115,19 +115,19 @@ discard block |
||
115 | 115 | |
116 | 116 | // @TODO this can be removed when we have a transformer for "T_OPEN_TAG" to "T_OPEN_TAG + T_WHITESPACE" |
117 | 117 | if (false !== strpos($tokens[$index - 1]->getContent(), "\n")) { |
118 | - $content = "\n".$content; |
|
118 | + $content = "\n" . $content; |
|
119 | 119 | $previousTokenHasTrailingLinebreak = true; |
120 | 120 | } |
121 | 121 | |
122 | 122 | $indent = $this->indent; |
123 | 123 | $newContent = Preg::replaceCallback( |
124 | 124 | '/(\R)(\h+)/', // find indent |
125 | - function (array $matches) use ($indent) { |
|
125 | + function(array $matches) use ($indent) { |
|
126 | 126 | // normalize mixed indent |
127 | 127 | $content = Preg::replace('/(?:(?<! ) {1,3})?\t/', ' ', $matches[2]); |
128 | 128 | |
129 | 129 | // change indent to expected one |
130 | - return $matches[1].$this->getExpectedIndent($content, $indent); |
|
130 | + return $matches[1] . $this->getExpectedIndent($content, $indent); |
|
131 | 131 | }, |
132 | 132 | $content |
133 | 133 | ); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | |
89 | 89 | $expectedIndent = $this->getExpectedIndentAt($tokens, $index); |
90 | 90 | if ($currentIndent !== $expectedIndent) { |
91 | - $tokens[$index - 1] = new Token([T_WHITESPACE, $lineEnding.$expectedIndent]); |
|
91 | + $tokens[$index - 1] = new Token([T_WHITESPACE, $lineEnding . $expectedIndent]); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | if ($this->currentLineRequiresExtraIndentLevel($tokens, $i, $index)) { |
115 | - return $currentIndent.$indent; |
|
115 | + return $currentIndent . $indent; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | return $currentIndent; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | $content = $tokens[$index]->getContent(); |
166 | 166 | |
167 | 167 | if ($tokens[$index]->isWhitespace() && $tokens[$index - 1]->isGivenKind(T_OPEN_TAG)) { |
168 | - $content = $tokens[$index - 1]->getContent().$content; |
|
168 | + $content = $tokens[$index - 1]->getContent() . $content; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | if (Preg::match('/\R/', $content)) { |
@@ -75,7 +75,7 @@ |
||
75 | 75 | && 1 === Preg::match('/(.*)\h$/', $token->getContent(), $openTagMatches) |
76 | 76 | && 1 === Preg::match('/^(\R)(.*)$/s', $tokens[$index + 1]->getContent(), $whitespaceMatches) |
77 | 77 | ) { |
78 | - $tokens[$index] = new Token([T_OPEN_TAG, $openTagMatches[1].$whitespaceMatches[1]]); |
|
78 | + $tokens[$index] = new Token([T_OPEN_TAG, $openTagMatches[1] . $whitespaceMatches[1]]); |
|
79 | 79 | if ('' === $whitespaceMatches[2]) { |
80 | 80 | $tokens->clearAt($index + 1); |
81 | 81 | } else { |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | continue; |
74 | 74 | } |
75 | 75 | |
76 | - [$previousUnset, , $previousUnsetBraceEnd] = $previousUnsetCall; |
|
76 | + [$previousUnset,, $previousUnsetBraceEnd] = $previousUnsetCall; |
|
77 | 77 | |
78 | 78 | // Merge the tokens inside the 'unset' call into the previous one 'unset' call. |
79 | 79 | $tokensAddCount = $this->moveTokens( |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | $added = 0; |
177 | 177 | for ($i = $start + 1; $i < $end; $i += 2) { |
178 | 178 | if ($tokens[$i]->isWhitespace() && $tokens[$to + 1]->isWhitespace()) { |
179 | - $tokens[$to + 1] = new Token([T_WHITESPACE, $tokens[$to + 1]->getContent().$tokens[$i]->getContent()]); |
|
179 | + $tokens[$to + 1] = new Token([T_WHITESPACE, $tokens[$to + 1]->getContent() . $tokens[$i]->getContent()]); |
|
180 | 180 | } else { |
181 | 181 | $tokens->insertAt(++$to, clone $tokens[$i]); |
182 | 182 | ++$end; |
@@ -36,9 +36,9 @@ |
||
36 | 36 | 'Properties should be set to `null` instead of using `unset`.', |
37 | 37 | [new CodeSample("<?php\nunset(\$this->a);\n")], |
38 | 38 | null, |
39 | - 'Risky when relying on attributes to be removed using `unset` rather than be set to `null`.'. |
|
40 | - ' Changing variables to `null` instead of unsetting means these still show up when looping over class variables'. |
|
41 | - ' and reference properties remain unbroken.'. |
|
39 | + 'Risky when relying on attributes to be removed using `unset` rather than be set to `null`.' . |
|
40 | + ' Changing variables to `null` instead of unsetting means these still show up when looping over class variables' . |
|
41 | + ' and reference properties remain unbroken.' . |
|
42 | 42 | ' With PHP 7.4, this rule might introduce `null` assignments to properties whose type declaration does not allow it.' |
43 | 43 | ); |
44 | 44 | } |
@@ -116,7 +116,7 @@ |
||
116 | 116 | protected function applyFix(\SplFileInfo $file, Tokens $tokens): void |
117 | 117 | { |
118 | 118 | $functionsAnalyzer = new FunctionsAnalyzer(); |
119 | - $excludedFunctions = array_map(static function (string $function) { |
|
119 | + $excludedFunctions = array_map(static function(string $function) { |
|
120 | 120 | return strtolower($function); |
121 | 121 | }, $this->configuration[self::OPTION_NOISE_REMAINING_USAGES_EXCLUDE]); |
122 | 122 |
@@ -137,7 +137,7 @@ |
||
137 | 137 | $braceOpenCount = 1; |
138 | 138 | $meaningfulTokenIndexes = [$openIndex]; |
139 | 139 | |
140 | - for ($i = $openIndex + 1;; ++$i) { |
|
140 | + for ($i = $openIndex + 1; ; ++$i) { |
|
141 | 141 | if ($tokens[$i]->isWhitespace() || $tokens[$i]->isComment()) { |
142 | 142 | continue; |
143 | 143 | } |
@@ -124,19 +124,19 @@ discard block |
||
124 | 124 | if ($tokens[$index]->isGivenKind(CT::T_GROUP_IMPORT_BRACE_OPEN)) { |
125 | 125 | $groupEndIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_GROUP_IMPORT_BRACE, $index); |
126 | 126 | $groupImports = array_map( |
127 | - static function (string $import) { |
|
127 | + static function(string $import) { |
|
128 | 128 | return trim($import); |
129 | 129 | }, |
130 | 130 | explode(',', $tokens->generatePartialCode($index + 1, $groupEndIndex - 1)) |
131 | 131 | ); |
132 | 132 | foreach ($groupImports as $groupImport) { |
133 | - $groupImportParts = array_map(static function (string $import) { |
|
133 | + $groupImportParts = array_map(static function(string $import) { |
|
134 | 134 | return trim($import); |
135 | 135 | }, explode(' as ', $groupImport)); |
136 | 136 | if (2 === \count($groupImportParts)) { |
137 | - $this->imports[$groupImportParts[1]] = $import.$groupImportParts[0]; |
|
137 | + $this->imports[$groupImportParts[1]] = $import . $groupImportParts[0]; |
|
138 | 138 | } else { |
139 | - $this->imports[] = $import.$groupImport; |
|
139 | + $this->imports[] = $import . $groupImport; |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | } elseif ($tokens[$index]->isGivenKind(T_AS)) { |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | |
224 | 224 | $tokens->insertAt($classBeginIndex, new Token([ |
225 | 225 | T_CONSTANT_ENCAPSED_STRING, |
226 | - "'".$this->makeClassFQN($namespacePrefix, $classImport, $classString)."'", |
|
226 | + "'" . $this->makeClassFQN($namespacePrefix, $classImport, $classString) . "'", |
|
227 | 227 | ])); |
228 | 228 | } |
229 | 229 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | private function makeClassFQN(string $namespacePrefix, $classImport, string $classString): string |
234 | 234 | { |
235 | 235 | if (false === $classImport) { |
236 | - return ('' !== $namespacePrefix ? ($namespacePrefix.'\\') : '').$classString; |
|
236 | + return ('' !== $namespacePrefix ? ($namespacePrefix . '\\') : '') . $classString; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | $classStringArray = explode('\\', $classString); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $declarationTokens = Tokens::fromCode( |
226 | 226 | sprintf( |
227 | 227 | '<?php use %s%s;', |
228 | - self::IMPORT_TYPE_CLASS === $use['importType'] ? '' : ' '.$use['importType'].' ', |
|
228 | + self::IMPORT_TYPE_CLASS === $use['importType'] ? '' : ' ' . $use['importType'] . ' ', |
|
229 | 229 | $use['namespace'] |
230 | 230 | ) |
231 | 231 | ); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | ->getOption(), |
265 | 265 | (new FixerOptionBuilder('imports_order', 'Defines the order of import types.')) |
266 | 266 | ->setAllowedTypes(['array', 'null']) |
267 | - ->setAllowedValues([static function (?array $value) use ($supportedSortTypes) { |
|
267 | + ->setAllowedValues([static function(?array $value) use ($supportedSortTypes) { |
|
268 | 268 | if (null !== $value) { |
269 | 269 | $missing = array_diff($supportedSortTypes, $value); |
270 | 270 | if (\count($missing)) { |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | */ |
320 | 320 | private function sortByLength(array $first, array $second): int |
321 | 321 | { |
322 | - $firstNamespace = (self::IMPORT_TYPE_CLASS === $first['importType'] ? '' : $first['importType'].' ').$this->prepareNamespace($first['namespace']); |
|
323 | - $secondNamespace = (self::IMPORT_TYPE_CLASS === $second['importType'] ? '' : $second['importType'].' ').$this->prepareNamespace($second['namespace']); |
|
322 | + $firstNamespace = (self::IMPORT_TYPE_CLASS === $first['importType'] ? '' : $first['importType'] . ' ') . $this->prepareNamespace($first['namespace']); |
|
323 | + $secondNamespace = (self::IMPORT_TYPE_CLASS === $second['importType'] ? '' : $second['importType'] . ' ') . $this->prepareNamespace($second['namespace']); |
|
324 | 324 | |
325 | 325 | $firstNamespaceLength = \strlen($firstNamespace); |
326 | 326 | $secondNamespaceLength = \strlen($secondNamespace); |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | for ($k1 = $k + 1; $k1 < $namespaceTokensCount; ++$k1) { |
400 | 400 | $comment = ''; |
401 | 401 | $namespacePart = ''; |
402 | - for ($k2 = $k1;; ++$k2) { |
|
402 | + for ($k2 = $k1; ; ++$k2) { |
|
403 | 403 | if ($namespaceTokens[$k2]->equalsAny([',', [CT::T_GROUP_IMPORT_BRACE_CLOSE]])) { |
404 | 404 | break; |
405 | 405 | } |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | && false !== strpos($namespaceTokens[$k2]->getContent(), $lineEnding) |
418 | 418 | ) { |
419 | 419 | $lastIndent = $lineEnding; |
420 | - $firstIndent = $lineEnding.$this->whitespacesConfig->getIndent(); |
|
421 | - $separator = ','.$firstIndent; |
|
420 | + $firstIndent = $lineEnding . $this->whitespacesConfig->getIndent(); |
|
421 | + $separator = ',' . $firstIndent; |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | $namespacePart .= $namespaceTokens[$k2]->getContent(); |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | |
434 | 434 | $comment = trim($comment); |
435 | 435 | if ('' !== $comment) { |
436 | - $namespacePart .= ' '.$comment; |
|
436 | + $namespacePart .= ' ' . $comment; |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | $parts[] = $namespacePart; |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | if ($sortedParts === $parts) { |
449 | 449 | $namespace = Tokens::fromArray($namespaceTokens)->generateCode(); |
450 | 450 | } else { |
451 | - $namespace .= $firstIndent.implode($separator, $parts).($hasGroupTrailingComma ? ',' : '').$lastIndent.'}'; |
|
451 | + $namespace .= $firstIndent . implode($separator, $parts) . ($hasGroupTrailingComma ? ',' : '') . $lastIndent . '}'; |
|
452 | 452 | } |
453 | 453 | } else { |
454 | 454 | $namespace = Tokens::fromArray($namespaceTokens)->generateCode(); |