Skip to content
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
12 changes: 4 additions & 8 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub trait PHPProvider<'a>: Sized {
/// Writes the bindings to a file.
fn write_bindings(&self, bindings: String, writer: &mut impl Write) -> Result<()> {
for line in bindings.lines() {
writeln!(writer, "{}", line)?;
writeln!(writer, "{line}")?;
}
Ok(())
}
Expand Down Expand Up @@ -126,7 +126,7 @@ impl PHPInfo {
}

fn get_key(&self, key: &str) -> Option<&str> {
let split = format!("{} => ", key);
let split = format!("{key} => ");
for line in self.0.lines() {
let components: Vec<_> = line.split(&split).collect();
if components.len() > 1 {
Expand Down Expand Up @@ -160,11 +160,7 @@ fn generate_bindings(defines: &[(&str, &str)], includes: &[PathBuf]) -> Result<S
.iter()
.map(|inc| format!("-I{}", inc.to_string_lossy())),
)
.clang_args(
defines
.iter()
.map(|(var, val)| format!("-D{}={}", var, val)),
)
.clang_args(defines.iter().map(|(var, val)| format!("-D{var}={val}")))
.rustfmt_bindings(true)
.no_copy("_zval_struct")
.no_copy("_zend_string")
Expand Down Expand Up @@ -237,7 +233,7 @@ fn main() -> Result<()> {
println!("cargo:rerun-if-changed={}", path.to_string_lossy());
}
for env_var in ["PHP", "PHP_CONFIG", "PATH"] {
println!("cargo:rerun-if-env-changed={}", env_var);
println!("cargo:rerun-if-env-changed={env_var}");
}

println!("cargo:rerun-if-changed=build.rs");
Expand Down
15 changes: 7 additions & 8 deletions crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use dialoguer::{Confirm, Select};

use std::{
fs::OpenOptions,
io::{BufRead, BufReader, Seek, SeekFrom, Write},
io::{BufRead, BufReader, Seek, Write},
path::PathBuf,
process::{Command, Stdio},
};
Expand Down Expand Up @@ -207,7 +207,7 @@ impl Install {
.open(php_ini)
.with_context(|| "Failed to open `php.ini`")?;

let mut ext_line = format!("extension={}", ext_name);
let mut ext_line = format!("extension={ext_name}");

let mut new_lines = vec![];
for line in BufReader::new(&file).lines() {
Expand All @@ -225,7 +225,7 @@ impl Install {
}

new_lines.push(ext_line);
file.seek(SeekFrom::Start(0))?;
file.rewind()?;
file.set_len(0)?;
file.write(new_lines.join("\n").as_bytes())
.with_context(|| "Failed to update `php.ini`")?;
Expand Down Expand Up @@ -255,9 +255,8 @@ fn get_ext_dir() -> AResult<PathBuf> {
ext_dir
);
} else {
std::fs::create_dir(&ext_dir).with_context(|| {
format!("Failed to create extension directory at {:?}", ext_dir)
})?;
std::fs::create_dir(&ext_dir)
.with_context(|| format!("Failed to create extension directory at {ext_dir:?}"))?;
}
}
Ok(ext_dir)
Expand Down Expand Up @@ -341,7 +340,7 @@ impl Remove {
}
}

file.seek(SeekFrom::Start(0))?;
file.rewind()?;
file.set_len(0)?;
file.write(new_lines.join("\n").as_bytes())
.with_context(|| "Failed to update `php.ini`")?;
Expand Down Expand Up @@ -389,7 +388,7 @@ impl Stubs {
.with_context(|| "Failed to generate stubs.")?;

if self.stdout {
print!("{}", stubs);
print!("{stubs}");
} else {
let out_path = if let Some(out_path) = &self.out {
Cow::Borrowed(out_path)
Expand Down
2 changes: 1 addition & 1 deletion crates/macros/src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn parser(args: AttributeArgs, input: ItemFn) -> Result<(TokenStream, Functi
..
} = &sig;

let internal_ident = Ident::new(&format!("_internal_php_{}", ident), Span::call_site());
let internal_ident = Ident::new(&format!("_internal_php_{ident}"), Span::call_site());
let args = build_args(inputs, &attr_args.defaults)?;
let optional = find_optional_parameter(args.iter(), attr_args.optional);
let arg_definitions = build_arg_definitions(&args);
Expand Down
2 changes: 1 addition & 1 deletion crates/macros/src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub fn parser(
} else {
quote! { return; }
};
let internal_ident = Ident::new(&format!("_internal_php_{}", ident), Span::call_site());
let internal_ident = Ident::new(&format!("_internal_php_{ident}"), Span::call_site());
let args = build_args(struct_ty, &mut input.sig.inputs, &defaults)?;
let optional = function::find_optional_parameter(
args.iter().filter_map(|arg| match arg {
Expand Down
2 changes: 1 addition & 1 deletion crates/macros/src/startup_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn build_classes(classes: &HashMap<String, Class>) -> Result<Vec<TokenStream>> {
.map(|(name, class)| {
let Class { class_name, .. } = &class;
let ident = Ident::new(name, Span::call_site());
let meta = Ident::new(&format!("_{}_META", name), Span::call_site());
let meta = Ident::new(&format!("_{name}_META"), Span::call_site());
let methods = class.methods.iter().map(|method| {
let builder = method.get_builder(&ident);
let flags = method.get_flags();
Expand Down
13 changes: 7 additions & 6 deletions src/describe/stub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl ToStub for Module {
.map(|(ns, entries)| {
let mut buf = String::new();
if let Some(ns) = ns {
writeln!(buf, "namespace {} {{", ns)?;
writeln!(buf, "namespace {ns} {{")?;
} else {
writeln!(buf, "namespace {{")?;
}
Expand Down Expand Up @@ -183,7 +183,7 @@ impl ToStub for DocBlock {
if !self.0.is_empty() {
writeln!(buf, "/**")?;
for comment in self.0.iter() {
writeln!(buf, " *{}", comment)?;
writeln!(buf, " *{comment}")?;
}
writeln!(buf, " */")?;
}
Expand All @@ -196,10 +196,10 @@ impl ToStub for Class {
self.docs.fmt_stub(buf)?;

let (_, name) = split_namespace(self.name.as_ref());
write!(buf, "class {} ", name)?;
write!(buf, "class {name} ")?;

if let Option::Some(extends) = &self.extends {
write!(buf, "extends {} ", extends)?;
write!(buf, "extends {extends} ")?;
}

if !self.implements.is_empty() {
Expand Down Expand Up @@ -249,7 +249,7 @@ impl ToStub for Property {
}
write!(buf, "${}", self.name)?;
if let Option::Some(default) = &self.default {
write!(buf, " = {}", default)?;
write!(buf, " = {default}")?;
}
writeln!(buf, ";")
}
Expand Down Expand Up @@ -311,7 +311,7 @@ impl ToStub for Constant {

write!(buf, "const {} = ", self.name)?;
if let Option::Some(value) = &self.value {
write!(buf, "{}", value)?;
write!(buf, "{value}")?;
} else {
write!(buf, "null")?;
}
Expand Down Expand Up @@ -381,6 +381,7 @@ mod test {

#[test]
#[cfg(not(windows))]
#[allow(clippy::uninlined_format_args)]
pub fn test_indent() {
use super::indent;
use crate::describe::stub::NEW_LINE_SEPARATOR;
Expand Down
14 changes: 6 additions & 8 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,15 @@ impl Display for Error {
match self {
Error::IncorrectArguments(n, expected) => write!(
f,
"Expected at least {} arguments, got {} arguments.",
expected, n
"Expected at least {expected} arguments, got {n} arguments."
),
Error::ZvalConversion(ty) => write!(
f,
"Could not convert Zval from type {} into primitive type.",
ty
"Could not convert Zval from type {ty} into primitive type."
),
Error::UnknownDatatype(dt) => write!(f, "Unknown datatype {}.", dt),
Error::UnknownDatatype(dt) => write!(f, "Unknown datatype {dt}."),
Error::InvalidTypeToDatatype(dt) => {
write!(f, "Type flags did not contain a datatype: {:?}", dt)
write!(f, "Type flags did not contain a datatype: {dt:?}")
}
Error::InvalidScope => write!(f, "Invalid scope."),
Error::InvalidPointer => write!(f, "Invalid pointer."),
Expand All @@ -87,12 +85,12 @@ impl Display for Error {
Error::InvalidUtf8 => write!(f, "Invalid Utf8 byte sequence."),
Error::Callable => write!(f, "Could not call given function."),
Error::InvalidException(flags) => {
write!(f, "Invalid exception type was thrown: {:?}", flags)
write!(f, "Invalid exception type was thrown: {flags:?}")
}
Error::IntegerOverflow => {
write!(f, "Converting integer arguments resulted in an overflow.")
}
Error::Exception(e) => write!(f, "Exception was thrown: {:?}", e),
Error::Exception(e) => write!(f, "Exception was thrown: {e:?}"),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl<'a, T: 'a> Property<'a, T> {
let value = get(self_);
value
.set_zval(retval, false)
.map_err(|e| format!("Failed to return property value to PHP: {:?}", e))?;
.map_err(|e| format!("Failed to return property value to PHP: {e:?}"))?;
Ok(())
}) as Box<dyn Fn(&T, &mut Zval) -> PhpResult + Send + Sync + 'a>
});
Expand Down Expand Up @@ -196,7 +196,7 @@ impl<'a, T: 'a> Property<'a, T> {
match self {
Property::Field(field) => field(self_)
.get(retval)
.map_err(|e| format!("Failed to get property value: {:?}", e).into()),
.map_err(|e| format!("Failed to get property value: {e:?}").into()),
Property::Method { get, set: _ } => match get {
Some(get) => get(self_, retval),
None => Err("No getter available for this property.".into()),
Expand Down Expand Up @@ -244,7 +244,7 @@ impl<'a, T: 'a> Property<'a, T> {
match self {
Property::Field(field) => field(self_)
.set(value)
.map_err(|e| format!("Failed to set property value: {:?}", e).into()),
.map_err(|e| format!("Failed to set property value: {e:?}").into()),
Property::Method { get: _, set } => match set {
Some(set) => set(self_, value),
None => Err("No setter available for this property.".into()),
Expand Down
2 changes: 1 addition & 1 deletion src/zend/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl ZendObjectHandlers {
continue;
}
props.insert(name, zv).map_err(|e| {
format!("Failed to insert value into properties hashtable: {:?}", e)
format!("Failed to insert value into properties hashtable: {e:?}")
})?;
}

Expand Down