-
Notifications
You must be signed in to change notification settings - Fork 76
Add helpers for Zval coercion #341
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
base: master
Are you sure you want to change the base?
Conversation
self.set_string(if val { "1" } else { "0" }, false)?; | ||
return Ok(()); | ||
} else if self.is_array() { | ||
self.set_string("Array", false)?; |
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.
➜ ~ php -r '(string)[];'
PHP Warning: Array to string conversion in Command line code on line 1
So I'd suggest removing this.
self.set_bool(val != "0" && val != ""); | ||
return Ok(()); | ||
} else if let Some(val) = self.array() { | ||
self.set_bool(val.len() != 0); |
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.
.is_empty()
self.set_long(val.parse::<i64>().map_err(|_| Error::ZvalConversion(self.get_type()))?); | ||
return Ok(()); | ||
} else if let Some(val) = self.array() { | ||
self.set_long(if val.len() > 0 { 1 } else { 0 }); |
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.
val.is_empty()
self.set_double(val.parse::<f64>().map_err(|_| Error::ZvalConversion(self.get_type()))?); | ||
return Ok(()); | ||
} else if let Some(val) = self.array() { | ||
self.set_double(if val.len() > 0 { 1.0 } else { 0.0 }); |
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.
val.is_empty()
bd2ffeb
to
cfb15cb
Compare
Pull Request Test Coverage Report for Build 15784055444Details
💛 - Coveralls |
Had a look at this. Don't know if i like that the Would also need some tests. |
Btw, it would be nice to call __to_string() on objects if it's present. |
No description provided.