ext-php-rs
ext-php-rs copied to clipboard
#[prop] attribute should rename fields to camelCase by default
Currently, the #[prop]
attribute does not handle case conversion, so we must resort to:
#[php_class]
struct Foo {
#[prop(rename = "isBar")]
pub is_bar: bool,
}
which can quickly become tedious.
The #[php_class]
attribute should accept a rename_fields
argument similiar to rename_methods
for #[php_impl]
, and default to camelCase
.
The #[prop(rename)]
argument should be kept around for corner-cases like:
#[php_class]
struct Request {
#[prop(rename = "isXMLHttpRequest")]
pub is_xml_http_request: bool,
}
Although on might argue that it should be #[prop(name = ..)]
and not #[prop(rename = ..)]
...
For ergonomics, it could even be made into a global, project-wide, configuration option?
Thinking about it, it should look more like :
#[php_class(field_case = "snake", method_case = "camel", constant_case = "upper")]
struct Foo;
This would ease the burden of verbose repeated configuration.
Well I think you could simply rename your function and use #[allow(non_snake_case)]
:)