@@ -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 | |
@@ -250,14 +250,14 @@ discard block |
||
| 250 | 250 | return new FixerConfigurationResolver([ |
| 251 | 251 | (new FixerOptionBuilder('elements', sprintf('Dictionary of `%s` => `%s` values.', implode('|', self::SUPPORTED_TYPES), implode('|', self::SUPPORTED_SPACINGS)))) |
| 252 | 252 | ->setAllowedTypes(['array']) |
| 253 | - ->setAllowedValues([static function (array $option) { |
|
| 253 | + ->setAllowedValues([static function(array $option) { |
|
| 254 | 254 | foreach ($option as $type => $spacing) { |
| 255 | 255 | if (!\in_array($type, self::SUPPORTED_TYPES, true)) { |
| 256 | 256 | throw new InvalidOptionsException( |
| 257 | 257 | sprintf( |
| 258 | 258 | 'Unexpected element type, expected any of "%s", got "%s".', |
| 259 | 259 | implode('", "', self::SUPPORTED_TYPES), |
| 260 | - \gettype($type).'#'.$type |
|
| 260 | + \gettype($type) . '#' . $type |
|
| 261 | 261 | ) |
| 262 | 262 | ); |
| 263 | 263 | } |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | 'Unexpected spacing for element type "%s", expected any of "%s", got "%s".', |
| 269 | 269 | $spacing, |
| 270 | 270 | implode('", "', self::SUPPORTED_SPACINGS), |
| 271 | - \is_object($spacing) ? \get_class($spacing) : (null === $spacing ? 'null' : \gettype($spacing).'#'.$spacing) |
|
| 271 | + \is_object($spacing) ? \get_class($spacing) : (null === $spacing ? 'null' : \gettype($spacing) . '#' . $spacing) |
|
| 272 | 272 | ) |
| 273 | 273 | ); |
| 274 | 274 | } |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | */ |
| 295 | 295 | private function fixSpaceBelowClassElement(Tokens $tokens, int $classEndIndex, int $elementEndIndex, string $spacing): void |
| 296 | 296 | { |
| 297 | - for ($nextNotWhite = $elementEndIndex + 1;; ++$nextNotWhite) { |
|
| 297 | + for ($nextNotWhite = $elementEndIndex + 1; ; ++$nextNotWhite) { |
|
| 298 | 298 | if (($tokens[$nextNotWhite]->isComment() || $tokens[$nextNotWhite]->isWhitespace()) && false === strpos($tokens[$nextNotWhite]->getContent(), "\n")) { |
| 299 | 299 | continue; |
| 300 | 300 | } |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | if ($lineBreakCount < $reqLineCount) { |
| 493 | 493 | $tokens[$startIndex] = new Token([ |
| 494 | 494 | T_WHITESPACE, |
| 495 | - str_repeat($lineEnding, $reqLineCount - $lineBreakCount).$tokens[$startIndex]->getContent(), |
|
| 495 | + str_repeat($lineEnding, $reqLineCount - $lineBreakCount) . $tokens[$startIndex]->getContent(), |
|
| 496 | 496 | ]); |
| 497 | 497 | |
| 498 | 498 | return; |