@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | private function importConstants(Tokens $tokens, array $useDeclarations): array |
178 | 178 | { |
179 | - [$global, $other] = $this->filterUseDeclarations($useDeclarations, static function (NamespaceUseAnalysis $declaration) { |
|
179 | + [$global, $other] = $this->filterUseDeclarations($useDeclarations, static function(NamespaceUseAnalysis $declaration) { |
|
180 | 180 | return $declaration->isConstant(); |
181 | 181 | }, true); |
182 | 182 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | */ |
249 | 249 | private function importFunctions(Tokens $tokens, array $useDeclarations): array |
250 | 250 | { |
251 | - [$global, $other] = $this->filterUseDeclarations($useDeclarations, static function (NamespaceUseAnalysis $declaration) { |
|
251 | + [$global, $other] = $this->filterUseDeclarations($useDeclarations, static function(NamespaceUseAnalysis $declaration) { |
|
252 | 252 | return $declaration->isFunction(); |
253 | 253 | }, false); |
254 | 254 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | */ |
300 | 300 | private function importClasses(Tokens $tokens, array $useDeclarations): array |
301 | 301 | { |
302 | - [$global, $other] = $this->filterUseDeclarations($useDeclarations, static function (NamespaceUseAnalysis $declaration) { |
|
302 | + [$global, $other] = $this->filterUseDeclarations($useDeclarations, static function(NamespaceUseAnalysis $declaration) { |
|
303 | 303 | return $declaration->isClass(); |
304 | 304 | }, false); |
305 | 305 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | if ($token->isGivenKind(T_DOC_COMMENT)) { |
315 | 315 | $docBlocks[$index] = new DocBlock($token->getContent()); |
316 | 316 | |
317 | - $this->traverseDocBlockTypes($docBlocks[$index], static function (string $type) use ($global, &$other): void { |
|
317 | + $this->traverseDocBlockTypes($docBlocks[$index], static function(string $type) use ($global, &$other): void { |
|
318 | 318 | if (false !== strpos($type, '\\')) { |
319 | 319 | return; |
320 | 320 | } |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | $imports = []; |
379 | 379 | |
380 | 380 | foreach ($docBlocks as $index => $docBlock) { |
381 | - $changed = $this->traverseDocBlockTypes($docBlock, static function (string $type) use ($global, $other, &$imports) { |
|
381 | + $changed = $this->traverseDocBlockTypes($docBlock, static function(string $type) use ($global, $other, &$imports) { |
|
382 | 382 | if ('\\' !== $type[0]) { |
383 | 383 | return $type; |
384 | 384 | } |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | return; |
491 | 491 | } |
492 | 492 | |
493 | - [$global] = $this->filterUseDeclarations($useDeclarations, static function (NamespaceUseAnalysis $declaration) { |
|
493 | + [$global] = $this->filterUseDeclarations($useDeclarations, static function(NamespaceUseAnalysis $declaration) { |
|
494 | 494 | return $declaration->isConstant() && !$declaration->isAliased(); |
495 | 495 | }, true); |
496 | 496 | |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | return; |
533 | 533 | } |
534 | 534 | |
535 | - [$global] = $this->filterUseDeclarations($useDeclarations, static function (NamespaceUseAnalysis $declaration) { |
|
535 | + [$global] = $this->filterUseDeclarations($useDeclarations, static function(NamespaceUseAnalysis $declaration) { |
|
536 | 536 | return $declaration->isFunction() && !$declaration->isAliased(); |
537 | 537 | }, false); |
538 | 538 | |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | return; |
575 | 575 | } |
576 | 576 | |
577 | - [$global] = $this->filterUseDeclarations($useDeclarations, static function (NamespaceUseAnalysis $declaration) { |
|
577 | + [$global] = $this->filterUseDeclarations($useDeclarations, static function(NamespaceUseAnalysis $declaration) { |
|
578 | 578 | return $declaration->isClass() && !$declaration->isAliased(); |
579 | 579 | }, false); |
580 | 580 | |
@@ -590,12 +590,12 @@ discard block |
||
590 | 590 | if ($token->isGivenKind(T_DOC_COMMENT)) { |
591 | 591 | $doc = new DocBlock($token->getContent()); |
592 | 592 | |
593 | - $changed = $this->traverseDocBlockTypes($doc, static function (string $type) use ($global) { |
|
593 | + $changed = $this->traverseDocBlockTypes($doc, static function(string $type) use ($global) { |
|
594 | 594 | if (!isset($global[strtolower($type)])) { |
595 | 595 | return $type; |
596 | 596 | } |
597 | 597 | |
598 | - return '\\'.$type; |
|
598 | + return '\\' . $type; |
|
599 | 599 | }); |
600 | 600 | |
601 | 601 | if ($changed) { |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $comment = ''; |
88 | 88 | $groupOpenIndex = null; |
89 | 89 | |
90 | - for ($i = $index + 1;; ++$i) { |
|
90 | + for ($i = $index + 1; ; ++$i) { |
|
91 | 91 | if ($tokens[$i]->isGivenKind(CT::T_GROUP_IMPORT_BRACE_OPEN)) { |
92 | 92 | $groupOpenIndex = $i; |
93 | 93 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | } |
137 | 137 | |
138 | 138 | if ($token->equalsAny([',', [CT::T_GROUP_IMPORT_BRACE_CLOSE]])) { |
139 | - $statements[] = 'use'.$statement.';'; |
|
139 | + $statements[] = 'use' . $statement . ';'; |
|
140 | 140 | $statement = $groupPrefix; |
141 | 141 | |
142 | 142 | continue; |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | $statement .= ' as '; |
150 | 150 | $i += 2; |
151 | 151 | } elseif ($tokens[$j]->equals([T_FUNCTION])) { |
152 | - $statement = ' function'.$statement; |
|
152 | + $statement = ' function' . $statement; |
|
153 | 153 | $i += 2; |
154 | 154 | } elseif ($tokens[$j]->equals([T_CONST])) { |
155 | - $statement = ' const'.$statement; |
|
155 | + $statement = ' const' . $statement; |
|
156 | 156 | $i += 2; |
157 | 157 | } |
158 | 158 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | if ('' !== $comment) { |
168 | - $statements[0] .= ' '.$comment; |
|
168 | + $statements[0] .= ' ' . $comment; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | return $statements; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | } |
187 | 187 | |
188 | 188 | $ending = $this->whitespacesConfig->getLineEnding(); |
189 | - $importTokens = Tokens::fromCode('<?php '.implode($ending, $statements)); |
|
189 | + $importTokens = Tokens::fromCode('<?php ' . implode($ending, $statements)); |
|
190 | 190 | $importTokens->clearAt(0); |
191 | 191 | $importTokens->clearEmptyTokens(); |
192 | 192 | |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | $indent = WhitespacesAnalyzer::detectIndent($tokens, $index); |
232 | 232 | |
233 | 233 | if ($tokens[$i - 1]->isWhitespace()) { |
234 | - $tokens[$i - 1] = new Token([T_WHITESPACE, $ending.$indent]); |
|
234 | + $tokens[$i - 1] = new Token([T_WHITESPACE, $ending . $indent]); |
|
235 | 235 | } elseif (false === strpos($tokens[$i - 1]->getContent(), "\n")) { |
236 | - $tokens->insertAt($i, new Token([T_WHITESPACE, $ending.$indent])); |
|
236 | + $tokens->insertAt($i, new Token([T_WHITESPACE, $ending . $indent])); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | |
165 | 165 | if ($token->isComment() |
166 | 166 | && Preg::match( |
167 | - '/(?<![[:alnum:]\$])(?<!\\\\)'.$import->getShortName().'(?![[:alnum:]])/i', |
|
167 | + '/(?<![[:alnum:]\$])(?<!\\\\)' . $import->getShortName() . '(?![[:alnum:]])/i', |
|
168 | 168 | $token->getContent() |
169 | 169 | ) |
170 | 170 | ) { |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | } |
249 | 249 | |
250 | 250 | if ($prevToken->isWhitespace() && $nextToken->isWhitespace()) { |
251 | - $content = $prevToken->getContent().$nextToken->getContent(); |
|
251 | + $content = $prevToken->getContent() . $nextToken->getContent(); |
|
252 | 252 | |
253 | 253 | if ('' !== $content) { |
254 | 254 | $tokens[$nextIndex] = new Token([T_WHITESPACE, $content]); |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | private function removeUsesInSameNamespace(Tokens $tokens, array $useDeclarations, NamespaceAnalysis $namespaceDeclaration): void |
264 | 264 | { |
265 | 265 | $namespace = $namespaceDeclaration->getFullName(); |
266 | - $nsLength = \strlen($namespace.'\\'); |
|
266 | + $nsLength = \strlen($namespace . '\\'); |
|
267 | 267 | |
268 | 268 | foreach ($useDeclarations as $useDeclaration) { |
269 | 269 | if ($useDeclaration->isAliased()) { |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | |
273 | 273 | $useDeclarationFullName = ltrim($useDeclaration->getFullName(), '\\'); |
274 | 274 | |
275 | - if (0 !== strpos($useDeclarationFullName, $namespace.'\\')) { |
|
275 | + if (0 !== strpos($useDeclarationFullName, $namespace . '\\')) { |
|
276 | 276 | continue; |
277 | 277 | } |
278 | 278 |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | if ($semicolonIndex === \count($tokens) - 1) { |
122 | - $tokens->insertAt($insertIndex + 1, new Token([T_WHITESPACE, $ending.$ending.$indent])); |
|
122 | + $tokens->insertAt($insertIndex + 1, new Token([T_WHITESPACE, $ending . $ending . $indent])); |
|
123 | 123 | ++$added; |
124 | 124 | } else { |
125 | 125 | $newline = $ending; |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | $nextMeaningfulAfterUseIndex = $tokens->getNextMeaningfulToken($insertIndex); |
147 | 147 | if (null !== $nextMeaningfulAfterUseIndex && $tokens[$nextMeaningfulAfterUseIndex]->isGivenKind(T_USE)) { |
148 | 148 | if (substr_count($nextToken->getContent(), "\n") < 1) { |
149 | - $tokens[$insertIndex] = new Token([T_WHITESPACE, $newline.$indent.ltrim($nextToken->getContent())]); |
|
149 | + $tokens[$insertIndex] = new Token([T_WHITESPACE, $newline . $indent . ltrim($nextToken->getContent())]); |
|
150 | 150 | } |
151 | 151 | } else { |
152 | - $tokens[$insertIndex] = new Token([T_WHITESPACE, $newline.$indent.ltrim($nextToken->getContent())]); |
|
152 | + $tokens[$insertIndex] = new Token([T_WHITESPACE, $newline . $indent . ltrim($nextToken->getContent())]); |
|
153 | 153 | } |
154 | 154 | } else { |
155 | - $tokens->insertAt($insertIndex, new Token([T_WHITESPACE, $newline.$indent])); |
|
155 | + $tokens->insertAt($insertIndex, new Token([T_WHITESPACE, $newline . $indent])); |
|
156 | 156 | ++$added; |
157 | 157 | } |
158 | 158 | } |
@@ -83,24 +83,24 @@ |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | $allNamespaceAndType = array_map( |
86 | - function (NamespaceUseAnalysis $useDeclaration) { |
|
87 | - return $this->getNamespaceNameWithSlash($useDeclaration).$useDeclaration->getType(); |
|
86 | + function(NamespaceUseAnalysis $useDeclaration) { |
|
87 | + return $this->getNamespaceNameWithSlash($useDeclaration) . $useDeclaration->getType(); |
|
88 | 88 | }, |
89 | 89 | $useDeclarations |
90 | 90 | ); |
91 | 91 | |
92 | - $sameNamespaces = array_filter(array_count_values($allNamespaceAndType), function (int $count) { |
|
92 | + $sameNamespaces = array_filter(array_count_values($allNamespaceAndType), function(int $count) { |
|
93 | 93 | return $count > 1; |
94 | 94 | }); |
95 | 95 | $sameNamespaces = array_keys($sameNamespaces); |
96 | 96 | |
97 | - $sameNamespaceAnalysis = array_filter($useDeclarations, function (NamespaceUseAnalysis $useDeclaration) use ($sameNamespaces) { |
|
98 | - $namespaceNameAndType = $this->getNamespaceNameWithSlash($useDeclaration).$useDeclaration->getType(); |
|
97 | + $sameNamespaceAnalysis = array_filter($useDeclarations, function(NamespaceUseAnalysis $useDeclaration) use ($sameNamespaces) { |
|
98 | + $namespaceNameAndType = $this->getNamespaceNameWithSlash($useDeclaration) . $useDeclaration->getType(); |
|
99 | 99 | |
100 | 100 | return \in_array($namespaceNameAndType, $sameNamespaces, true); |
101 | 101 | }); |
102 | 102 | |
103 | - usort($sameNamespaceAnalysis, function (NamespaceUseAnalysis $a, NamespaceUseAnalysis $b) { |
|
103 | + usort($sameNamespaceAnalysis, function(NamespaceUseAnalysis $a, NamespaceUseAnalysis $b) { |
|
104 | 104 | $namespaceA = $this->getNamespaceNameWithSlash($a); |
105 | 105 | $namespaceB = $this->getNamespaceNameWithSlash($b); |
106 | 106 |
@@ -96,7 +96,7 @@ |
||
96 | 96 | // if there is more than one new line in the whitespace, then we need to fix it |
97 | 97 | if (substr_count($content, "\n") > 1) { |
98 | 98 | // the final bit of the whitespace must be the next statement's indentation |
99 | - $tokens[$index] = new Token([T_WHITESPACE, $this->whitespacesConfig->getLineEnding().substr($content, strrpos($content, "\n") + 1)]); |
|
99 | + $tokens[$index] = new Token([T_WHITESPACE, $this->whitespacesConfig->getLineEnding() . substr($content, strrpos($content, "\n") + 1)]); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | 'static' => false, |
304 | 304 | ]; |
305 | 305 | |
306 | - for ($i = $startIndex;; ++$i) { |
|
306 | + for ($i = $startIndex; ; ++$i) { |
|
307 | 307 | $token = $tokens[$i]; |
308 | 308 | |
309 | 309 | // class end |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | } |
459 | 459 | |
460 | 460 | if (\in_array($type, ['constant', 'property', 'method'], true)) { |
461 | - $type .= '_'.$element['visibility']; |
|
461 | + $type .= '_' . $element['visibility']; |
|
462 | 462 | if ($element['abstract']) { |
463 | 463 | $type .= '_abstract'; |
464 | 464 | } |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | } |
472 | 472 | unset($element); |
473 | 473 | |
474 | - usort($elements, function (array $a, array $b) { |
|
474 | + usort($elements, function(array $a, array $b) { |
|
475 | 475 | if ($a['position'] === $b['position']) { |
476 | 476 | return $this->sortGroupElements($a, $b); |
477 | 477 | } |
@@ -180,7 +180,7 @@ |
||
180 | 180 | $interfaces[$interfaceIndex]['originalIndex'] = $interfaceIndex; |
181 | 181 | } |
182 | 182 | |
183 | - usort($interfaces, function (array $first, array $second) { |
|
183 | + usort($interfaces, function(array $first, array $second) { |
|
184 | 184 | $score = self::ORDER_LENGTH === $this->configuration[self::OPTION_ORDER] |
185 | 185 | ? \strlen($first['normalized']) - \strlen($second['normalized']) |
186 | 186 | : strcasecmp($first['normalized'], $second['normalized']); |
@@ -165,7 +165,7 @@ |
||
165 | 165 | if ($tokens[$startIndex - 1]->isWhitespace()) { |
166 | 166 | $divisionContent = $tokens[$startIndex - 1]->getContent(); |
167 | 167 | if (Preg::match('#(\n|\r\n)#', $divisionContent, $matches)) { |
168 | - $divisionContent = $matches[0].trim($divisionContent, "\r\n"); |
|
168 | + $divisionContent = $matches[0] . trim($divisionContent, "\r\n"); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 |