Skip to content

Commit 8dee338

Browse files
committed
bug #4219 NativeFunctionCasingFixer - handle T_RETURN_REF (kubawerlos)
This PR was squashed before being merged into the 2.12 branch (closes #4219). Discussion ---------- NativeFunctionCasingFixer - handle T_RETURN_REF Fixes #4218 Ping @umulmrum (as reporter) and @SpacePossum (as original author) for review. Commits ------- 6bf3515 NativeFunctionCasingFixer - handle T_RETURN_REF
2 parents 30b30c4 + 6bf3515 commit 8dee338

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/Fixer/Casing/NativeFunctionCasingFixer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use PhpCsFixer\AbstractFixer;
1616
use PhpCsFixer\FixerDefinition\CodeSample;
1717
use PhpCsFixer\FixerDefinition\FixerDefinition;
18+
use PhpCsFixer\Tokenizer\CT;
1819
use PhpCsFixer\Tokenizer\Token;
1920
use PhpCsFixer\Tokenizer\Tokens;
2021

@@ -67,7 +68,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
6768
}
6869

6970
$functionNamePrefix = $tokens->getPrevMeaningfulToken($index);
70-
if ($tokens[$functionNamePrefix]->isGivenKind([T_DOUBLE_COLON, T_NEW, T_OBJECT_OPERATOR, T_FUNCTION])) {
71+
if ($tokens[$functionNamePrefix]->isGivenKind([T_DOUBLE_COLON, T_NEW, T_OBJECT_OPERATOR, T_FUNCTION, CT::T_RETURN_REF])) {
7172
continue;
7273
}
7374

tests/Fixer/Casing/NativeFunctionCasingFixerTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ public function gettypE()
102102
function sqrT($a)
103103
{
104104
}
105+
106+
function &END($a)
107+
{
108+
}
105109
}
106110
',
107111
],
@@ -130,6 +134,24 @@ function sqrT($a)
130134
$a->STRTOLOWER();
131135
',
132136
],
137+
[
138+
'<?php
139+
namespace Foo {
140+
function &Next() {
141+
return prev(-1);
142+
}
143+
}',
144+
],
145+
[
146+
'<?php
147+
$next1 = & next($array1);
148+
$next2 = & \next($array2);
149+
',
150+
'<?php
151+
$next1 = & Next($array1);
152+
$next2 = & \Next($array2);
153+
',
154+
],
133155
];
134156
}
135157

0 commit comments

Comments
 (0)