Skip to content

Commit

Permalink
Revert PHP7.4 - Add \"str_split\" => \"mb_str_split\" mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Aug 31, 2019
1 parent 3b917bc commit d35c431
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 33 deletions.
20 changes: 1 addition & 19 deletions src/Fixer/Alias/MbStrFunctionsFixer.php
Expand Up @@ -28,7 +28,6 @@ final class MbStrFunctionsFixer extends AbstractFunctionReferenceFixer
* @var array the list of the string-related function names and their mb_ equivalent
*/
private static $functionsMap = [
'str_split' => ['alternativeName' => 'mb_str_split', 'argumentCount' => [1, 2, 3]],
'stripos' => ['alternativeName' => 'mb_stripos', 'argumentCount' => [2, 3]],
'stristr' => ['alternativeName' => 'mb_stristr', 'argumentCount' => [2, 3]],
'strlen' => ['alternativeName' => 'mb_strlen', 'argumentCount' => [1]],
Expand All @@ -43,23 +42,6 @@ final class MbStrFunctionsFixer extends AbstractFunctionReferenceFixer
'substr_count' => ['alternativeName' => 'mb_substr_count', 'argumentCount' => [2, 3, 4]],
];

/**
* @var array<string, array>
*/
private $functions;

public function __construct()
{
parent::__construct();

$this->functions = array_filter(
self::$functionsMap,
static function (array $mapping) {
return \function_exists($mapping['alternativeName']);
}
);
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -104,7 +86,7 @@ public function isCandidate(Tokens $tokens)
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
{
$argumentsAnalyzer = new ArgumentsAnalyzer();
foreach ($this->functions as $functionIdentity => $functionReplacement) {
foreach (self::$functionsMap as $functionIdentity => $functionReplacement) {
$currIndex = 0;
while (null !== $currIndex) {
// try getting function reference and translate boundaries for humans
Expand Down
15 changes: 1 addition & 14 deletions tests/Fixer/Alias/MbStrFunctionsFixerTest.php
Expand Up @@ -37,7 +37,7 @@ public function testFix($expected, $input = null)

public function provideFixCases()
{
$cases = [
return [
['<?php $x = "strlen";'],
['<?php $x = Foo::strlen("bar");'],
['<?php $x = new strlen("bar");'],
Expand All @@ -62,18 +62,5 @@ public function strtolower($a);
}',
],
];

if (\function_exists('mb_str_split')) {
$cases[] = [
'<?php $a = mb_str_split($a);',
'<?php $a = str_split($a);',
];
} else {
$cases[] = [
'<?php $a = str_split($a);',
];
}

return $cases;
}
}

0 comments on commit d35c431

Please sign in to comment.