-
Notifications
You must be signed in to change notification settings - Fork 79
fix(macro): allow multiple refs with self_
#507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Xenira
merged 1 commit into
master
from
506-missing-lifetime-specifier-when-taking-self_-and-zval-and-returning-self_
Jul 13, 2025
Merged
fix(macro): allow multiple refs with self_
#507
Xenira
merged 1 commit into
master
from
506-missing-lifetime-specifier-when-taking-self_-and-zval-and-returning-self_
Jul 13, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pull Request Test Coverage Report for Build 16248137065Details
💛 - Coveralls |
fe24877
to
f815a13
Compare
@ptondereau do you see any reason why we sholdn't do this. Seems to be working and I see no unsafe code that could cause trouble here. |
Relevant generated code: ::ext_php_rs::builders::FunctionBuilder::new(
"selfMultiRef",
{
extern "C" fn handler(
ex: &mut ::ext_php_rs::zend::ExecuteData,
retval: &mut ::ext_php_rs::types::Zval,
) {
use ::ext_php_rs::convert::IntoZval;
let mut val = ::ext_php_rs::args::Arg::new(
"val",
<&str as ::ext_php_rs::convert::FromZvalMut>::TYPE,
);
let result = {
let (parse, this) = ex.parser_method::<TestClass>();
let this = match this {
Some(this) => this,
None => {
::ext_php_rs::exception::PhpException::default(
"Failed to retrieve reference to `$this`".into(),
)
.throw()
.unwrap();
return;
}
};
let parse_result = parse
.arg(&mut val)
.not_required()
.parse();
if parse_result.is_err() {
return;
}
TestClass::self_multi_ref(
this,
{
match val.val() {
Some(val) => val,
None => {
::ext_php_rs::exception::PhpException::default(
"Invalid value given for argument `val`.".into(),
)
.throw()
.expect("Failed to throw PHP exception.");
return;
}
}
},
)
};
if let Err(e) = result.set_zval(retval, false) {
let e: ::ext_php_rs::exception::PhpException = e.into();
e.throw().expect("Failed to throw PHP exception.");
}
}
handler
},
)
.arg(
::ext_php_rs::args::Arg::new(
"val",
<&str as ::ext_php_rs::convert::FromZvalMut>::TYPE,
),
)
.not_required()
.returns(
<&mut ZendClassObject< // <-- Lifetime dropped here
TestClass,
> as ::ext_php_rs::convert::IntoZval>::TYPE,
false,
<&mut ZendClassObject< // <-- And here
TestClass,
> as ::ext_php_rs::convert::IntoZval>::NULLABLE,
), |
ptondereau
approved these changes
Jul 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem! To me, this is great!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refs: #506
Description
Allow multiple refs with lifetime. e.g:
Need to think this through though.
Checklist
Check the boxes that apply (put an
x
in the brackets, like[x]
). You can also check boxes after the PR is created.❤️ Thank you for your contribution!