Skip to content

Commit

Permalink
feat: Support mb_str_pad function in mb_str_functions rule (PHP-C…
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-deabreu authored Dec 4, 2023
1 parent e33142d commit be448f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Fixer/Alias/MbStrFunctionsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public function __construct()
{
parent::__construct();

if (\PHP_VERSION_ID >= 8_03_00) {
self::$functionsMap['str_pad'] = ['alternativeName' => 'mb_str_pad', 'argumentCount' => [1, 2, 3, 4]];
}

$this->functions = array_filter(
self::$functionsMap,
static fn (array $mapping): bool => (new \ReflectionFunction($mapping['alternativeName']))->isInternal()
Expand Down
4 changes: 4 additions & 0 deletions tests/Fixer/Alias/MbStrFunctionsFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,9 @@ public function strtolower($a);
'<?php $a = mb_str_split($a);',
'<?php $a = str_split($a);',
];

if (\PHP_VERSION_ID >= 8_03_00) {
yield ['<?php $x = mb_str_pad("bar", 2, "0", STR_PAD_LEFT);', '<?php $x = str_pad("bar", 2, "0", STR_PAD_LEFT);'];
}
}
}

0 comments on commit be448f1

Please sign in to comment.