diff --git a/crates/macros/src/function.rs b/crates/macros/src/function.rs index 477d6fb493..4600e34409 100644 --- a/crates/macros/src/function.rs +++ b/crates/macros/src/function.rs @@ -343,18 +343,12 @@ impl Arg { } Type::Reference(ref_) => { // Returning references is invalid, so let's just create our arg - - // Change any `&mut T` into `&T` and set the `as_ref` attribute on the Arg - // to marked it as a "passed by ref" PHP argument. - let mut ref_ = ref_.clone(); - let is_mutable_ref = ref_.mutability.is_some(); - ref_.mutability = None; Some(Arg::new( name, ref_.to_token_stream().to_string(), false, default, - is_mutable_ref, + ref_.mutability.is_some(), )) } _ => None, diff --git a/guide/src/types/bool.md b/guide/src/types/bool.md index 1974ff305a..498b40ec39 100644 --- a/guide/src/types/bool.md +++ b/guide/src/types/bool.md @@ -45,3 +45,17 @@ pub fn test_bool(input: bool) -> String { var_dump(test_bool(true)); // string(4) "Yes!" var_dump(test_bool(false)); // string(3) "No!" ``` + +## Rust example, taking by reference + +```rust,no_run +# #![cfg_attr(windows, feature(abi_vectorcall))] +# extern crate ext_php_rs; +# use ext_php_rs::prelude::*; +# use ext_php_rs::types; +#[php_function] +pub fn test_bool(input: &mut types::Zval) { + input.reference_mut().unwrap().set_bool(false); +} +# fn main() {} +```