Skip to content

Commit

Permalink
Simplify implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Sep 18, 2024
1 parent a2da61c commit c53c12b
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/Util/CallableArgumentsExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,9 @@ private function normalizeName(string $name): string
return strtolower(str_replace('_', '', $name));
}

// logic from Symfony\Component\String\AbstractUnicodeString::snake()
private function toSnakeCase(string $str): string
private function toSnakeCase(string $name): string
{
$camel = str_replace(' ', '', preg_replace_callback('/\b.(?!\p{Lu})/u', static function ($m) use (&$i) {
return 1 === ++$i ? ('İ' === $m[0] ? '' : mb_strtolower($m[0], 'UTF-8')) : mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8');
}, preg_replace('/[^\pL0-9]++/u', ' ', $str)));

return mb_strtolower(preg_replace(['/(\p{Lu}+)(\p{Lu}\p{Ll})/u', '/([\p{Ll}0-9])(\p{Lu})/u'], '\1_\2', $camel), 'UTF-8');
return strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z0-9])([A-Z])/'], '\1_\2', $name));
}

private function getCallableParameters(): array
Expand Down

0 comments on commit c53c12b

Please sign in to comment.