Skip to content

Commit eca070b

Browse files
committed
bug #4533 Revert PHP7.4 - Add "str_split" => "mb_str_split" mapping (keradus)
This PR was squashed before being merged into the 2.12 branch (closes #4533). Discussion ---------- Revert PHP7.4 - Add "str_split" => "mb_str_split" mapping Reverts #4380 Closes #4529 Commits ------- d35c431 Revert PHP7.4 - Add \"str_split\" => \"mb_str_split\" mapping
2 parents 3b917bc + d35c431 commit eca070b

File tree

2 files changed

+2
-33
lines changed

2 files changed

+2
-33
lines changed

src/Fixer/Alias/MbStrFunctionsFixer.php

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ final class MbStrFunctionsFixer extends AbstractFunctionReferenceFixer
2828
* @var array the list of the string-related function names and their mb_ equivalent
2929
*/
3030
private static $functionsMap = [
31-
'str_split' => ['alternativeName' => 'mb_str_split', 'argumentCount' => [1, 2, 3]],
3231
'stripos' => ['alternativeName' => 'mb_stripos', 'argumentCount' => [2, 3]],
3332
'stristr' => ['alternativeName' => 'mb_stristr', 'argumentCount' => [2, 3]],
3433
'strlen' => ['alternativeName' => 'mb_strlen', 'argumentCount' => [1]],
@@ -43,23 +42,6 @@ final class MbStrFunctionsFixer extends AbstractFunctionReferenceFixer
4342
'substr_count' => ['alternativeName' => 'mb_substr_count', 'argumentCount' => [2, 3, 4]],
4443
];
4544

46-
/**
47-
* @var array<string, array>
48-
*/
49-
private $functions;
50-
51-
public function __construct()
52-
{
53-
parent::__construct();
54-
55-
$this->functions = array_filter(
56-
self::$functionsMap,
57-
static function (array $mapping) {
58-
return \function_exists($mapping['alternativeName']);
59-
}
60-
);
61-
}
62-
6345
/**
6446
* {@inheritdoc}
6547
*/
@@ -104,7 +86,7 @@ public function isCandidate(Tokens $tokens)
10486
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
10587
{
10688
$argumentsAnalyzer = new ArgumentsAnalyzer();
107-
foreach ($this->functions as $functionIdentity => $functionReplacement) {
89+
foreach (self::$functionsMap as $functionIdentity => $functionReplacement) {
10890
$currIndex = 0;
10991
while (null !== $currIndex) {
11092
// try getting function reference and translate boundaries for humans

tests/Fixer/Alias/MbStrFunctionsFixerTest.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testFix($expected, $input = null)
3737

3838
public function provideFixCases()
3939
{
40-
$cases = [
40+
return [
4141
['<?php $x = "strlen";'],
4242
['<?php $x = Foo::strlen("bar");'],
4343
['<?php $x = new strlen("bar");'],
@@ -62,18 +62,5 @@ public function strtolower($a);
6262
}',
6363
],
6464
];
65-
66-
if (\function_exists('mb_str_split')) {
67-
$cases[] = [
68-
'<?php $a = mb_str_split($a);',
69-
'<?php $a = str_split($a);',
70-
];
71-
} else {
72-
$cases[] = [
73-
'<?php $a = str_split($a);',
74-
];
75-
}
76-
77-
return $cases;
7865
}
7966
}

0 commit comments

Comments
 (0)