Skip to content

#[prop] attribute should rename fields to camelCase by default #189

Open
@ju1ius

Description

@ju1ius

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions