Skip to content

Commit 5a1695c

Browse files
committed
Naively change the case of method identifiers to comply with PSR-1
1 parent 8b0adf1 commit 5a1695c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

ext-php-rs-derive/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ proc-macro = true
1414
[dependencies]
1515
syn = { version = "1.0.68", features = ["full", "extra-traits"] }
1616
darling = "0.12"
17+
ident_case = "1.0.1"
1718
quote = "1.0.9"
1819
proc-macro2 = "1.0.26"
1920
lazy_static = "1.4.0"

ext-php-rs-derive/src/method.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use anyhow::{anyhow, bail, Result};
2+
use ident_case::RenameRule;
23
use quote::ToTokens;
34
use std::collections::HashMap;
45

@@ -92,8 +93,14 @@ pub fn parser(input: &mut ImplItemMethod) -> Result<(TokenStream, Method)> {
9293
}
9394
};
9495

96+
let name = if ident == "__construct" {
97+
ident.to_string()
98+
} else {
99+
RenameRule::CamelCase.apply_to_field(ident.to_string())
100+
};
101+
95102
let method = Method {
96-
name: ident.to_string(),
103+
name,
97104
ident: internal_ident.to_string(),
98105
args,
99106
optional,

0 commit comments

Comments
 (0)