@@ -60,7 +60,7 @@ |
||
60 | 60 | $types = []; |
61 | 61 | |
62 | 62 | foreach (self::$loops as $loop) { |
63 | - $types[] = (array) $loop['lookupTokens']; |
|
63 | + $types[] = (array)$loop['lookupTokens']; |
|
64 | 64 | } |
65 | 65 | $types = array_merge(...$types); |
66 | 66 |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | (new FixerOptionBuilder('comment_text', 'The text to use in the added comment and to detect it.')) |
101 | 101 | ->setAllowedTypes(['string']) |
102 | 102 | ->setAllowedValues([ |
103 | - static function (string $value) { |
|
103 | + static function(string $value) { |
|
104 | 104 | if (Preg::match('/\R/', $value)) { |
105 | 105 | throw new InvalidOptionsException('The comment text must not contain new lines.'); |
106 | 106 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | return true; |
109 | 109 | }, |
110 | 110 | ]) |
111 | - ->setNormalizer(static function (Options $options, $value) { |
|
111 | + ->setNormalizer(static function(Options $options, $value) { |
|
112 | 112 | return rtrim($value); |
113 | 113 | }) |
114 | 114 | ->setDefault('no break') |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | ++$nbNewlines; |
236 | 236 | |
237 | 237 | if (!Preg::match('/\R/', $newlineToken->getContent())) { |
238 | - $tokens[$newlinePosition] = new Token([$newlineToken->getId(), $lineEnding.$newlineToken->getContent()]); |
|
238 | + $tokens[$newlinePosition] = new Token([$newlineToken->getId(), $lineEnding . $newlineToken->getContent()]); |
|
239 | 239 | } |
240 | 240 | } |
241 | 241 | |
@@ -243,11 +243,11 @@ discard block |
||
243 | 243 | Preg::match('/^(.*?)(\R\h*)$/s', $newlineToken->getContent(), $matches); |
244 | 244 | |
245 | 245 | $indent = WhitespacesAnalyzer::detectIndent($tokens, $newlinePosition - 1); |
246 | - $tokens[$newlinePosition] = new Token([$newlineToken->getId(), $matches[1].$lineEnding.$indent]); |
|
246 | + $tokens[$newlinePosition] = new Token([$newlineToken->getId(), $matches[1] . $lineEnding . $indent]); |
|
247 | 247 | $tokens->insertAt(++$newlinePosition, new Token([T_WHITESPACE, $matches[2]])); |
248 | 248 | } |
249 | 249 | |
250 | - $tokens->insertAt($newlinePosition, new Token([T_COMMENT, '// '.$this->configuration['comment_text']])); |
|
250 | + $tokens->insertAt($newlinePosition, new Token([T_COMMENT, '// ' . $this->configuration['comment_text']])); |
|
251 | 251 | $this->ensureNewLineAt($tokens, $newlinePosition); |
252 | 252 | } |
253 | 253 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | private function ensureNewLineAt(Tokens $tokens, int $position): int |
258 | 258 | { |
259 | 259 | $lineEnding = $this->whitespacesConfig->getLineEnding(); |
260 | - $content = $lineEnding.WhitespacesAnalyzer::detectIndent($tokens, $position); |
|
260 | + $content = $lineEnding . WhitespacesAnalyzer::detectIndent($tokens, $position); |
|
261 | 261 | $whitespaceToken = $tokens[$position - 1]; |
262 | 262 | |
263 | 263 | if (!$whitespaceToken->isGivenKind(T_WHITESPACE)) { |
@@ -68,7 +68,7 @@ |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | $ternariesCount = 0; |
71 | - for ($colonIndex = $index + 1;; ++$colonIndex) { |
|
71 | + for ($colonIndex = $index + 1; ; ++$colonIndex) { |
|
72 | 72 | // We have to skip ternary case for colons. |
73 | 73 | if ($tokens[$colonIndex]->equals('?')) { |
74 | 74 | ++$ternariesCount; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | { |
83 | 83 | if (self::STYLE_BRACES === $this->configuration['style']) { |
84 | 84 | $analyzer = new TokensAnalyzer($tokens); |
85 | - $fixLoop = static function (int $index, int $endIndex) use ($tokens, $analyzer): void { |
|
85 | + $fixLoop = static function(int $index, int $endIndex) use ($tokens, $analyzer): void { |
|
86 | 86 | if ($tokens[$index]->isGivenKind(T_WHILE) && $analyzer->isWhilePartOfDoWhile($index)) { |
87 | 87 | return; |
88 | 88 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $tokens->insertAt($semiColonIndex + 1, new Token('}')); |
98 | 98 | }; |
99 | 99 | } else { |
100 | - $fixLoop = static function (int $index, int $endIndex) use ($tokens): void { |
|
100 | + $fixLoop = static function(int $index, int $endIndex) use ($tokens): void { |
|
101 | 101 | $braceOpenIndex = $tokens->getNextMeaningfulToken($endIndex); |
102 | 102 | |
103 | 103 | if (!$tokens[$braceOpenIndex]->equals('{')) { |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | (new FixerOptionBuilder('after_heredoc', 'Whether a trailing comma should also be placed after heredoc end.')) |
112 | 112 | ->setAllowedTypes(['bool']) |
113 | 113 | ->setDefault(false) |
114 | - ->setNormalizer(static function (Options $options, $value) { |
|
114 | + ->setNormalizer(static function(Options $options, $value) { |
|
115 | 115 | if (\PHP_VERSION_ID < 70300 && $value) { |
116 | 116 | throw new InvalidOptionsForEnvException('"after_heredoc" option can only be enabled with PHP 7.3+.'); |
117 | 117 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | ->setAllowedTypes(['array']) |
124 | 124 | ->setAllowedValues([new AllowedValueSubset([self::ELEMENTS_ARRAYS, self::ELEMENTS_ARGUMENTS, self::ELEMENTS_PARAMETERS])]) |
125 | 125 | ->setDefault([self::ELEMENTS_ARRAYS]) |
126 | - ->setNormalizer(static function (Options $options, $value) { |
|
126 | + ->setNormalizer(static function(Options $options, $value) { |
|
127 | 127 | if (\PHP_VERSION_ID < 70300 && \in_array(self::ELEMENTS_ARGUMENTS, $value, true)) { |
128 | 128 | throw new InvalidOptionsForEnvException(sprintf('"%s" option can only be enabled with PHP 7.3+.', self::ELEMENTS_ARGUMENTS)); |
129 | 129 | } |
@@ -424,22 +424,22 @@ discard block |
||
424 | 424 | |
425 | 425 | if (null === $tokens) { |
426 | 426 | $tokens = [ |
427 | - T_BOOLEAN_AND, // && |
|
428 | - T_BOOLEAN_OR, // || |
|
429 | - T_CASE, // case |
|
427 | + T_BOOLEAN_AND, // && |
|
428 | + T_BOOLEAN_OR, // || |
|
429 | + T_CASE, // case |
|
430 | 430 | T_DOUBLE_ARROW, // => |
431 | - T_ECHO, // echo |
|
432 | - T_GOTO, // goto |
|
433 | - T_LOGICAL_AND, // and |
|
434 | - T_LOGICAL_OR, // or |
|
435 | - T_LOGICAL_XOR, // xor |
|
436 | - T_OPEN_TAG, // <?php |
|
431 | + T_ECHO, // echo |
|
432 | + T_GOTO, // goto |
|
433 | + T_LOGICAL_AND, // and |
|
434 | + T_LOGICAL_OR, // or |
|
435 | + T_LOGICAL_XOR, // xor |
|
436 | + T_OPEN_TAG, // <?php |
|
437 | 437 | T_OPEN_TAG_WITH_ECHO, |
438 | - T_PRINT, // print |
|
439 | - T_RETURN, // return |
|
440 | - T_THROW, // throw |
|
438 | + T_PRINT, // print |
|
439 | + T_RETURN, // return |
|
440 | + T_THROW, // throw |
|
441 | 441 | T_COALESCE, |
442 | - T_YIELD, // yield |
|
442 | + T_YIELD, // yield |
|
443 | 443 | ]; |
444 | 444 | } |
445 | 445 | |
@@ -465,18 +465,18 @@ discard block |
||
465 | 465 | |
466 | 466 | if (null === $tokens) { |
467 | 467 | $tokens = [ |
468 | - T_AND_EQUAL, // &= |
|
468 | + T_AND_EQUAL, // &= |
|
469 | 469 | T_CONCAT_EQUAL, // .= |
470 | - T_DIV_EQUAL, // /= |
|
471 | - T_MINUS_EQUAL, // -= |
|
472 | - T_MOD_EQUAL, // %= |
|
473 | - T_MUL_EQUAL, // *= |
|
474 | - T_OR_EQUAL, // |= |
|
475 | - T_PLUS_EQUAL, // += |
|
476 | - T_POW_EQUAL, // **= |
|
477 | - T_SL_EQUAL, // <<= |
|
478 | - T_SR_EQUAL, // >>= |
|
479 | - T_XOR_EQUAL, // ^= |
|
470 | + T_DIV_EQUAL, // /= |
|
471 | + T_MINUS_EQUAL, // -= |
|
472 | + T_MOD_EQUAL, // %= |
|
473 | + T_MUL_EQUAL, // *= |
|
474 | + T_OR_EQUAL, // |= |
|
475 | + T_PLUS_EQUAL, // += |
|
476 | + T_POW_EQUAL, // **= |
|
477 | + T_SL_EQUAL, // <<= |
|
478 | + T_SR_EQUAL, // >>= |
|
479 | + T_XOR_EQUAL, // ^= |
|
480 | 480 | ]; |
481 | 481 | |
482 | 482 | // @TODO: drop condition when PHP 7.4+ is required |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | return false; |
667 | 667 | } |
668 | 668 | |
669 | - if ($token->isGivenKind([T_ARRAY, CT::T_ARRAY_SQUARE_BRACE_OPEN])) { |
|
669 | + if ($token->isGivenKind([T_ARRAY, CT::T_ARRAY_SQUARE_BRACE_OPEN])) { |
|
670 | 670 | $expectArrayOnly = true; |
671 | 671 | |
672 | 672 | continue; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | continue; // This might be attribute on PHP8, do not change |
139 | 139 | } |
140 | 140 | |
141 | - $tokens[$index] = new Token([$token->getId(), '//'.substr($content, 1)]); |
|
141 | + $tokens[$index] = new Token([$token->getId(), '//' . substr($content, 1)]); |
|
142 | 142 | |
143 | 143 | continue; |
144 | 144 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | |
165 | 165 | $content = '//'; |
166 | 166 | if (1 === Preg::match('/[^\s\*]/', $commentContent)) { |
167 | - $content = '// '.Preg::replace('/[\s\*]*([^\s\*](?:.+[^\s\*])?)[\s\*]*/', '\1', $commentContent); |
|
167 | + $content = '// ' . Preg::replace('/[\s\*]*([^\s\*](?:.+[^\s\*])?)[\s\*]*/', '\1', $commentContent); |
|
168 | 168 | } |
169 | 169 | $tokens[$index] = new Token([$token->getId(), $content]); |
170 | 170 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | parent::configure($configuration); |
92 | 92 | |
93 | 93 | $this->ignoredTags = array_map( |
94 | - static function (string $tag) { |
|
94 | + static function(string $tag) { |
|
95 | 95 | return strtolower($tag); |
96 | 96 | }, |
97 | 97 | $this->configuration['ignored_tags'] |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | { |
151 | 151 | return array_reduce( |
152 | 152 | $indices, |
153 | - function (bool $carry, int $index) use ($tokens) { |
|
153 | + function(bool $carry, int $index) use ($tokens) { |
|
154 | 154 | if ($carry) { |
155 | 155 | return true; |
156 | 156 | } |
@@ -181,14 +181,14 @@ discard block |
||
181 | 181 | $message = $this->getMessage($tokens[$index]->getContent()); |
182 | 182 | |
183 | 183 | if ('' !== trim(substr($message, 0, 1))) { |
184 | - $message = ' '.$message; |
|
184 | + $message = ' ' . $message; |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | if ('' !== trim(substr($message, -1))) { |
188 | 188 | $message .= ' '; |
189 | 189 | } |
190 | 190 | |
191 | - $tokens[$index] = new Token([T_DOC_COMMENT, '/**'.$message.'*/']); |
|
191 | + $tokens[$index] = new Token([T_DOC_COMMENT, '/**' . $message . '*/']); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $startIndex = reset($indices); |
200 | 200 | $indent = Utils::calculateTrailingWhitespaceIndent($tokens[$startIndex - 1]); |
201 | 201 | |
202 | - $newContent = '/**'.$this->whitespacesConfig->getLineEnding(); |
|
202 | + $newContent = '/**' . $this->whitespacesConfig->getLineEnding(); |
|
203 | 203 | $count = max($indices); |
204 | 204 | |
205 | 205 | for ($index = $startIndex; $index <= $count; ++$index) { |
@@ -211,16 +211,16 @@ discard block |
||
211 | 211 | } |
212 | 212 | $message = $this->getMessage($tokens[$index]->getContent()); |
213 | 213 | if ('' !== trim(substr($message, 0, 1))) { |
214 | - $message = ' '.$message; |
|
214 | + $message = ' ' . $message; |
|
215 | 215 | } |
216 | - $newContent .= $indent.' *'.$message.$this->whitespacesConfig->getLineEnding(); |
|
216 | + $newContent .= $indent . ' *' . $message . $this->whitespacesConfig->getLineEnding(); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | for ($index = $startIndex; $index <= $count; ++$index) { |
220 | 220 | $tokens->clearAt($index); |
221 | 221 | } |
222 | 222 | |
223 | - $newContent .= $indent.' */'; |
|
223 | + $newContent .= $indent . ' */'; |
|
224 | 224 | |
225 | 225 | $tokens->insertAt($startIndex, new Token([T_DOC_COMMENT, $newContent])); |
226 | 226 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | return new FixerConfigurationResolver([ |
205 | 205 | (new FixerOptionBuilder('header', 'Proper header content.')) |
206 | 206 | ->setAllowedTypes(['string']) |
207 | - ->setNormalizer(static function (Options $options, $value) use ($fixerName) { |
|
207 | + ->setNormalizer(static function(Options $options, $value) use ($fixerName) { |
|
208 | 208 | if ('' === trim($value)) { |
209 | 209 | return ''; |
210 | 210 | } |
@@ -237,14 +237,14 @@ discard block |
||
237 | 237 | private function getHeaderAsComment(): string |
238 | 238 | { |
239 | 239 | $lineEnding = $this->whitespacesConfig->getLineEnding(); |
240 | - $comment = (self::HEADER_COMMENT === $this->configuration['comment_type'] ? '/*' : '/**').$lineEnding; |
|
240 | + $comment = (self::HEADER_COMMENT === $this->configuration['comment_type'] ? '/*' : '/**') . $lineEnding; |
|
241 | 241 | $lines = explode("\n", str_replace("\r", '', $this->configuration['header'])); |
242 | 242 | |
243 | 243 | foreach ($lines as $line) { |
244 | - $comment .= rtrim(' * '.$line).$lineEnding; |
|
244 | + $comment .= rtrim(' * ' . $line) . $lineEnding; |
|
245 | 245 | } |
246 | 246 | |
247 | - return $comment.' */'; |
|
247 | + return $comment . ' */'; |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | private function findHeaderCommentCurrentIndex(Tokens $tokens, int $headerNewIndex): ?int |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | $missing = str_repeat($lineEnding, $expectedLineCount - $lineBreakCount); |
358 | 358 | |
359 | 359 | if ($tokens[$headerIndex + 1]->isWhitespace()) { |
360 | - $tokens[$headerIndex + 1] = new Token([T_WHITESPACE, $missing.$tokens[$headerIndex + 1]->getContent()]); |
|
360 | + $tokens[$headerIndex + 1] = new Token([T_WHITESPACE, $missing . $tokens[$headerIndex + 1]->getContent()]); |
|
361 | 361 | } else { |
362 | 362 | $tokens->insertAt($headerIndex + 1, new Token([T_WHITESPACE, $missing])); |
363 | 363 | } |