Skip to content

Commit f91d5c4

Browse files
committed
bug #4586 BracesFixer - handle dynamic static method call (SpacePossum)
This PR was merged into the 2.15 branch. Discussion ---------- BracesFixer - handle dynamic static method call closes #4451 Commits ------- 239938d BracesFixer - handle dynamic static method call
2 parents 9dbf585 + 239938d commit f91d5c4

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Fixer/Basic/BracesFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ static function ($item) {
424424
// and it is not a `Foo::{bar}()` situation
425425
!($nestToken->equals('}') && $nextNonWhitespaceNestToken->equals('(')) &&
426426
// and it is not a `${"a"}->...` and `${"b{$foo}"}->...` situation
427-
!($nestToken->equals('}') && $tokens[$nestIndex - 1]->equalsAny(['"', "'", [T_CONSTANT_ENCAPSED_STRING]])) &&
427+
!($nestToken->equals('}') && $tokens[$nestIndex - 1]->equalsAny(['"', "'", [T_CONSTANT_ENCAPSED_STRING], [T_VARIABLE]])) &&
428428
// and next token is not a closing tag that would break heredoc/nowdoc syntax
429429
!($tokens[$nestIndex - 1]->isGivenKind(T_END_HEREDOC) && $nextNonWhitespaceNestToken->isGivenKind(T_CLOSE_TAG))
430430
) {

tests/Fixer/Basic/BracesFixerTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5248,4 +5248,19 @@ function foo()
52485248
],
52495249
];
52505250
}
5251+
5252+
public function testDynamicStaticMethodCallNotTouched()
5253+
{
5254+
$this->doTest(
5255+
'<?php
5256+
SomeClass::{$method}(new \stdClass());
5257+
SomeClass::{\'test\'}(new \stdClass());
5258+
5259+
function example()
5260+
{
5261+
SomeClass::{$method}(new \stdClass());
5262+
SomeClass::{\'test\'}(new \stdClass());
5263+
}'
5264+
);
5265+
}
52515266
}

0 commit comments

Comments
 (0)