Skip to content

Commit ecaa85d

Browse files
committed
Merge branch '2.14'
* 2.14: StrictParamFixer - Don't detect functions in use statements Do not pull close tag onto same line as a comment
2 parents 110bc11 + afcd4dc commit ecaa85d

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

src/Fixer/Basic/BracesFixer.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,16 @@ static function ($item) {
342342
continue;
343343
}
344344

345+
$nextNonWhitespaceIndex = $tokens->getNextNonWhitespace($startBraceIndex, " \t");
346+
$nextNonWhitespace = $tokens[$nextNonWhitespaceIndex];
347+
345348
/* if CLOSE_TAG is after { on the same line, do not indent. e.g. <?php if ($condition) { ?> */
346-
if ($tokens[$tokens->getNextNonWhitespace($startBraceIndex, " \t")]->isGivenKind(T_CLOSE_TAG)) {
349+
if ($nextNonWhitespace->isGivenKind(T_CLOSE_TAG)) {
350+
continue;
351+
}
352+
353+
/* if CLOSE_TAG is after { on the next line and a comment on this line, do not indent. e.g. <?php if ($condition) { // \n?> */
354+
if ($nextNonWhitespace->isComment() && $tokens[$tokens->getNextMeaningfulToken($nextNonWhitespaceIndex)]->isGivenKind(T_CLOSE_TAG)) {
347355
continue;
348356
}
349357

src/Fixer/Strict/StrictParamFixer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
7575
for ($index = $tokens->count() - 1; 0 <= $index; --$index) {
7676
$token = $tokens[$index];
7777

78-
$previousIndex = $tokens->getPrevMeaningfulToken($index);
79-
if (null !== $previousIndex && $tokens[$previousIndex]->isGivenKind(CT::T_FUNCTION_IMPORT)) {
78+
$nextIndex = $tokens->getNextMeaningfulToken($index);
79+
if (null !== $nextIndex && !$tokens[$nextIndex]->equals('(')) {
8080
continue;
8181
}
8282

tests/Fixer/Basic/BracesFixerTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3142,6 +3142,18 @@ public function provideFixCommentBeforeBraceCases()
31423142
}, false);
31433143
',
31443144
],
3145+
[
3146+
'<?php
3147+
if ($a) { //
3148+
?><?php ++$a;
3149+
} ?>',
3150+
],
3151+
[
3152+
'<?php
3153+
if ($a) { /* */ /* */ /* */ /* */ /* */
3154+
?><?php ++$a;
3155+
} ?>',
3156+
],
31453157
];
31463158
}
31473159

tests/Fixer/Strict/StrictParamFixerTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,16 @@ public function __construct($foo, $bar) {}
155155
array_keys($foo, $bar);
156156
}',
157157
],
158+
[
159+
'<?php
160+
use function \base64_decode;
161+
foo($bar);',
162+
],
163+
[
164+
'<?php
165+
use function Baz\base64_decode;
166+
foo($bar);',
167+
],
158168
];
159169
}
160170

0 commit comments

Comments
 (0)