You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extract/hydrate should be symmetrical. Extracting, then hydrating any value should produce the original value. This fails when there are consecutive underscores.
Here is a simplified version of this class that does not have this issue.
$namingStrategy = newclassimplements NamingStrategyInterface
{
/** * Converts camel case to snake case. * * @param string $name The name in camel case. * @param null|object $object The original object for context (unused). * @return string The name converted to snake case. */publicfunctionextract(string$name, ?object$object = null): string
{
returnstrtolower(preg_replace('/[A-Z]/', '_$0', lcfirst($name)));
}
/** * Converts snake case to camel case. * * @param string $name The name in snake case. * @param null|mixed[] $data The original data for context (unused). * @return string The name converted to camel case. */publicfunctionhydrate(string$name, ?array$data = null): string
{
returnlcfirst(preg_replace_callback('/(_[a-z])/', staticfunction ($match) {
returnstrtoupper($match[1][1]);
}, $name));
}
};
$value = 'usb_a__out_usb_a_out';
var_dump($namingStrategy->hydrate($value));
var_dump($namingStrategy->extract($namingStrategy->hydrate($value)));
die(__METHOD__);
Bug Report
Summary
Current behavior
Extract/hydrate should be symmetrical. Extracting, then hydrating any value should produce the original value. This fails when there are consecutive underscores.
How to reproduce
string(15) "usbA_outUsbAOut"
string(19) "usb_a_out_usb_a_out"
Expected behavior
I would expect the second output to equal the original string.
The text was updated successfully, but these errors were encountered: