fn handle_context()

in src/plugin/plugin_psr3.rs [168:205]


    fn handle_context(context: &mut ZVal) -> crate::Result<Vec<(String, String)>> {
        let Some(context) = context.as_mut_z_arr() else {
            return Ok(vec![]);
        };
        let mut tags = Vec::with_capacity(context.len());
        for (key, value) in context.iter_mut() {
            match key {
                IterKey::Index(_) => continue,
                IterKey::ZStr(key) => {
                    let key = key.to_str()?.to_string();

                    let value = if value.as_null().is_some() {
                        "null".to_string()
                    } else if let Some(value) = value.as_bool() {
                        value.to_string()
                    } else if let Some(value) = value.as_long() {
                        value.to_string()
                    } else if let Some(value) = value.as_double() {
                        value.to_string()
                    } else if let Some(value) = value.as_z_str() {
                        value.to_str()?.to_string()
                    } else if value.as_z_arr().is_some() {
                        "Array".to_string()
                    } else if let Some(value) = value.as_mut_z_obj() {
                        let Some(value) = Self::cast_object_to_string(value)? else {
                            continue;
                        };
                        value
                    } else {
                        continue;
                    };

                    tags.push((key, value));
                }
            }
        }
        Ok(tags)
    }