Closed vrecan closed 5 years ago
The behaviour of the camelize
function is to provide accessor methods which feel more natural to common PHP code conventions.
It will provide the following transformations:
user_name
-> hasUserName
, getUserName
, setUserName
_private_field
-> hasPrivateField
, getPrivateField
, setPrivateField
I don't see how this solves the problem for fields starting with an underscore. Perhaps it would be better to change the camelize
function to the following:
if ($name[0] === '_') return $name;
return preg_replace_callback(
'/_([a-z0-9])/i',
function($m){ return strtoupper($m[1]); },
$name
);
Which will leave unmangled any field starting with an underscore, providing the following transformations:
user_name
-> hasUserName
, getUserName
, setUserName
_private_field
-> has_private_field
, get_private_field
, set_private_field
We have fields that start with underscore that get mangled during code generation.