ext-php-rs icon indicating copy to clipboard operation
ext-php-rs copied to clipboard

Move zval value coercing into `FromZval`

Open davidcole1340 opened this issue 4 years ago • 0 comments

At the moment, calling zval.string() will attempt to convert a f64 into a string, so zval.string() != zval.str() all the time. This should be removed, and a new function added to FromZval, coerce_from_zval():

pub trait FromZval<'a> {
    fn from_zval(zval: &'a Zval) -> Option<Self>;
    // by default, most types won't need coercing
    fn coerce_from_zval(zval: &'a Zval) -> Option<Self> {
        Self::from_zval(zval)
    }
}

davidcole1340 avatar Oct 01 '21 02:10 davidcole1340