Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/macros/src/impl_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl<'a> ParsedImpl<'a> {
{
// `self_: &[mut] ZendClassObject<Self>`
// Need to remove arg from argument list
func.args.typed.pop();
func.args.typed.remove(0);
MethodReceiver::ZendClassObject
} else {
modifiers.insert(MethodModifier::Static);
Expand Down
2 changes: 2 additions & 0 deletions tests/src/integration/class/class.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
assert($class->getString() === 'lorem ipsum');
$class->setString('dolor et');
assert($class->getString() === 'dolor et');
$class->selfRef("foo");
assert($class->getString() === 'Changed to foo');

assert($class->getNumber() === 2022);
$class->setNumber(2023);
Expand Down
15 changes: 14 additions & 1 deletion tests/src/integration/class/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#![allow(clippy::unused_self)]
use ext_php_rs::{convert::IntoZval, prelude::*, types::Zval, zend::ce};
use ext_php_rs::{
convert::IntoZval,
prelude::*,
types::{ZendClassObject, Zval},
zend::ce,
};

/// Doc comment
/// Goes here
Expand Down Expand Up @@ -36,6 +41,14 @@ impl TestClass {
pub fn static_call(name: String) -> String {
format!("Hello {name}")
}

pub fn self_ref(
self_: &mut ZendClassObject<TestClass>,
val: String,
) -> &mut ZendClassObject<TestClass> {
self_.string = format!("Changed to {val}");
self_
}
}

#[php_function]
Expand Down
Loading