// SAFETY: PHP objects are single-threaded; method calls are safe within a request.
let result = unsafe { (*self.inner).try_call_method("{{ method_name }}", {{ args_expr }}) };
{% if is_result_type %}
match result {
{% if is_unit_return %}
    Ok(_) => Ok(()),
{% elif is_primitive_return %}
    Ok(val) => {
        // For primitives, extract directly from Zval without JSON parsing
{% if return_type == "bool" %}
        let int_val = val.long().unwrap_or_default() != 0;
{% else %}
        let int_val = val.long().unwrap_or_default() as {{ return_type }};
{% endif %}
        Ok(int_val)
    }
{% else %}
    Ok(val) => {
{%- if native_return_binding %}
        // Native-object return: extract the host's native `#[php_class]` object and convert via
        // `From<{{ native_return_binding }}>` for core, falling back to the array/JSON path.
        if let Some(native) = <&{{ native_return_binding }} as ext_php_rs::convert::FromZval>::from_zval(&val) {
            Ok(native.clone().into())
        } else {
            let json_str = val.string().unwrap_or_default();
            serde_json::from_str(&json_str).map_err(|e| {{ deserialize_error_expr }})
        }
{%- else %}
        let json_str = val.string().unwrap_or_default();
        serde_json::from_str(&json_str).map_err(|e| {{ deserialize_error_expr }})
{%- endif %}
    }
{% endif %}
    Err(e) => Err({{ call_error_expr }}),
}
{% else %}
match result {
{% if is_unit_return %}
    Ok(_) => (),
{% elif is_primitive_return %}
{% if return_type == "bool" %}
    Ok(val) => val.long().unwrap_or_default() != 0,
{% else %}
    Ok(val) => val.long().unwrap_or_default() as {{ return_type }},
{% endif %}
{% else %}
    Ok(val) => {
{%- if native_return_binding %}
        if let Some(native) = <&{{ native_return_binding }} as ext_php_rs::convert::FromZval>::from_zval(&val) {
            native.clone().into()
        } else {
            let json_str = val.string().unwrap_or_default();
            serde_json::from_str(&json_str).unwrap_or_default()
        }
{%- else %}
        let json_str = val.string().unwrap_or_default();
        serde_json::from_str(&json_str).unwrap_or_default()
{%- endif %}
    }
{% endif %}
    Err(_) => Default::default(),
}
{% endif %}
