Skip to content

Commit 0b0368a

Browse files
committed
fix(macro): allow multiple refs with self_
Refs: #506
1 parent 6db8ef2 commit 0b0368a

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

crates/macros/src/function.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ impl<'a> Function<'a> {
196196
}
197197

198198
fn build_returns(&self) -> Option<TokenStream> {
199-
self.output.as_ref().map(|output| {
199+
self.output.cloned().map(|mut output| {
200+
output.drop_lifetimes();
200201
quote! {
201202
.returns(
202203
<#output as ::ext_php_rs::convert::IntoZval>::TYPE,

tests/src/integration/class/class.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
assert($class->getString() === 'dolor et');
1313
$class->selfRef("foo");
1414
assert($class->getString() === 'Changed to foo');
15+
$class->selfMultiRef("bar");
16+
assert($class->getString() === 'Changed to bar');
1517

1618
assert($class->getNumber() === 2022);
1719
$class->setNumber(2023);

tests/src/integration/class/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ impl TestClass {
4949
self_.string = format!("Changed to {val}");
5050
self_
5151
}
52+
53+
pub fn self_multi_ref<'a>(
54+
self_: &'a mut ZendClassObject<TestClass>,
55+
val: &str,
56+
) -> &'a mut ZendClassObject<TestClass> {
57+
self_.string = format!("Changed to {val}");
58+
self_
59+
}
5260
}
5361

5462
#[php_function]

0 commit comments

Comments
 (0)