@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | EOT |
45 | 45 | )], |
46 | 46 | 'The reasoning behind this rule is the following:' |
47 | - ."\n".'- When there are two valid ways of doing the same thing, using both is confusing, there should be a coding standard to follow' |
|
48 | - ."\n".'- PHP manual marks `"$var"` syntax as implicit and `"${var}"` syntax as explicit: explicit code should always be preferred' |
|
49 | - ."\n".'- Explicit syntax allows word concatenation inside strings, e.g. `"${var}IsAVar"`, implicit doesn\'t' |
|
50 | - ."\n".'- Explicit syntax is easier to detect for IDE/editors and therefore has colors/highlight with higher contrast, which is easier to read' |
|
51 | - ."\n".'Backtick operator is skipped because it is harder to handle; you can use `backtick_to_shell_exec` fixer to normalize backticks to strings' |
|
47 | + ."\n" . '- When there are two valid ways of doing the same thing, using both is confusing, there should be a coding standard to follow' |
|
48 | + ."\n" . '- PHP manual marks `"$var"` syntax as implicit and `"${var}"` syntax as explicit: explicit code should always be preferred' |
|
49 | + ."\n" . '- Explicit syntax allows word concatenation inside strings, e.g. `"${var}IsAVar"`, implicit doesn\'t' |
|
50 | + ."\n" . '- Explicit syntax is easier to detect for IDE/editors and therefore has colors/highlight with higher contrast, which is easier to read' |
|
51 | + ."\n" . 'Backtick operator is skipped because it is harder to handle; you can use `backtick_to_shell_exec` fixer to normalize backticks to strings' |
|
52 | 52 | ); |
53 | 53 | } |
54 | 54 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | if ($variablePartToken->isGivenKind(T_STRING) && $tokens[$variablePartIndex + 1]->equals(']')) { |
149 | - $tokens[$variablePartIndex] = new Token([T_CONSTANT_ENCAPSED_STRING, "'".$variablePartToken->getContent()."'"]); |
|
149 | + $tokens[$variablePartIndex] = new Token([T_CONSTANT_ENCAPSED_STRING, "'" . $variablePartToken->getContent() . "'"]); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 |
@@ -100,7 +100,7 @@ |
||
100 | 100 | ) { |
101 | 101 | $content = substr($content, 1, -1); |
102 | 102 | $content = str_replace(['\\"', '\\$', '\''], ['"', '$', '\\\''], $content); |
103 | - $tokens[$index] = new Token([T_CONSTANT_ENCAPSED_STRING, $prefix.'\''.$content.'\'']); |
|
103 | + $tokens[$index] = new Token([T_CONSTANT_ENCAPSED_STRING, $prefix . '\'' . $content . '\'']); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | } |
@@ -90,7 +90,7 @@ |
||
90 | 90 | $prev = $index - 1; |
91 | 91 | |
92 | 92 | if ($tokens[$prev]->equals([T_CLOSE_TAG, '?>']) && Preg::match('/^\R/', $content, $match)) { |
93 | - $tokens[$prev] = new Token([T_CLOSE_TAG, $tokens[$prev]->getContent().$match[0]]); |
|
93 | + $tokens[$prev] = new Token([T_CLOSE_TAG, $tokens[$prev]->getContent() . $match[0]]); |
|
94 | 94 | $content = substr($content, \strlen($match[0])); |
95 | 95 | $content = false === $content ? '' : $content; // @phpstan-ignore-line due to https://github.com/phpstan/phpstan/issues/1215 , awaiting PHP8 as min requirement of Fixer |
96 | 96 | } |
@@ -101,14 +101,14 @@ |
||
101 | 101 | $stringContent = $tokenOfStringBeforeToken->getContent(); |
102 | 102 | |
103 | 103 | if ('$' === substr($stringContent, -1) && '\\$' !== substr($stringContent, -2)) { |
104 | - $newContent = substr($stringContent, 0, -1).'\\$'; |
|
104 | + $newContent = substr($stringContent, 0, -1) . '\\$'; |
|
105 | 105 | $tokenOfStringBeforeToken = new Token([T_ENCAPSED_AND_WHITESPACE, $newContent]); |
106 | 106 | } |
107 | 107 | |
108 | 108 | $tokens->overrideRange($index - 1, $index + 2, [ |
109 | 109 | $tokenOfStringBeforeToken, |
110 | 110 | new Token([T_CURLY_OPEN, '{']), |
111 | - new Token([T_VARIABLE, '$'.$varnameToken->getContent()]), |
|
111 | + new Token([T_VARIABLE, '$' . $varnameToken->getContent()]), |
|
112 | 112 | new Token([CT::T_CURLY_CLOSE, '}']), |
113 | 113 | ]); |
114 | 114 | } |
@@ -80,7 +80,7 @@ |
||
80 | 80 | $token = $tokens[$index]; |
81 | 81 | |
82 | 82 | if ($token->isWhitespace() && !$token->isWhitespace(" \t")) { |
83 | - $tokens[$index] = new Token([T_WHITESPACE, rtrim($token->getContent()).' ']); |
|
83 | + $tokens[$index] = new Token([T_WHITESPACE, rtrim($token->getContent()) . ' ']); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | } |
@@ -90,7 +90,7 @@ |
||
90 | 90 | (new FixerOptionBuilder('after_heredoc', 'Whether the whitespace between heredoc end and comma should be removed.')) |
91 | 91 | ->setAllowedTypes(['bool']) |
92 | 92 | ->setDefault(false) |
93 | - ->setNormalizer(static function (Options $options, $value) { |
|
93 | + ->setNormalizer(static function(Options $options, $value) { |
|
94 | 94 | if (\PHP_VERSION_ID < 70300 && $value) { |
95 | 95 | throw new InvalidOptionsForEnvException('"after_heredoc" option can only be enabled with PHP 7.3+.'); |
96 | 96 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | $split = $this->sortFlags(Preg::split('#([^\+]\+?)#', $mode, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE)); |
86 | - $newContent = $binPrefix.$contentQuote.implode('', $split).$contentQuote; |
|
86 | + $newContent = $binPrefix . $contentQuote . implode('', $split) . $contentQuote; |
|
87 | 87 | |
88 | 88 | if ($content !== $newContent) { |
89 | 89 | $tokens[$argumentFlagIndex] = new Token([T_CONSTANT_ENCAPSED_STRING, $newContent]); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | { |
100 | 100 | usort( |
101 | 101 | $flags, |
102 | - static function (string $flag1, string $flag2) { |
|
102 | + static function(string $flag1, string $flag2) { |
|
103 | 103 | if ($flag1 === $flag2) { |
104 | 104 | return 0; |
105 | 105 | } |
@@ -105,7 +105,7 @@ |
||
105 | 105 | $mode = str_replace('b', '', $mode); |
106 | 106 | } |
107 | 107 | |
108 | - $newContent = $binPrefix.$contentQuote.$mode.$contentQuote; |
|
108 | + $newContent = $binPrefix . $contentQuote . $mode . $contentQuote; |
|
109 | 109 | |
110 | 110 | if ($content !== $newContent) { |
111 | 111 | $tokens[$argumentFlagIndex] = new Token([T_CONSTANT_ENCAPSED_STRING, $newContent]); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $lambdaOpenIndex = $tokens->getNextTokenOfKind($lambdaUseCloseBraceIndex, ['{']); |
132 | 132 | $curlyBracesLevel = 0; |
133 | 133 | |
134 | - for ($index = $lambdaOpenIndex;; ++$index) { // go through the body of the lambda and keep count of the (possible) usages of the imported variables |
|
134 | + for ($index = $lambdaOpenIndex; ; ++$index) { // go through the body of the lambda and keep count of the (possible) usages of the imported variables |
|
135 | 135 | $token = $tokens[$index]; |
136 | 136 | |
137 | 137 | if ($token->equals('{')) { |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | } |
180 | 180 | |
181 | 181 | if ($token->isGivenKind(T_STRING_VARNAME)) { |
182 | - $content = '$'.$token->getContent(); |
|
182 | + $content = '$' . $token->getContent(); |
|
183 | 183 | |
184 | 184 | if (isset($imports[$content])) { |
185 | 185 | unset($imports[$content]); |