Skip to content
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

Remove type coercion #298

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repository = "https://github.com/davidcole1340/ext-php-rs"
homepage = "https://github.com/davidcole1340/ext-php-rs"
license = "MIT OR Apache-2.0"
keywords = ["php", "ffi", "zend"]
version = "0.11.2"
version = "0.12.0"
authors = ["David Cole <[email protected]>"]
edition = "2018"
categories = ["api-bindings"]
Expand Down
9 changes: 1 addition & 8 deletions src/types/zval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl Zval {
if self.is_double() {
Some(unsafe { self.value.dval })
} else {
self.long().map(|x| x as f64)
None
}
}

Expand All @@ -114,17 +114,10 @@ impl Zval {

/// Returns the value of the zval if it is a string.
///
/// If the zval does not contain a string, the function will check if it
/// contains a double or a long, and if so it will convert the value to
/// a [`String`] and return it. Don't rely on this logic, as there is
/// potential for this to change to match the output of the [`str()`]
/// function.
///
/// [`str()`]: #method.str
pub fn string(&self) -> Option<String> {
self.str()
.map(|s| s.to_string())
.or_else(|| self.double().map(|x| x.to_string()))
}

/// Returns the value of the zval if it is a string.
Expand Down
Loading