aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-class-map-generator/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe-class-map-generator/src')
-rw-r--r--crates/shirabe-class-map-generator/src/class_map_generator.rs2
-rw-r--r--crates/shirabe-class-map-generator/src/php_file_parser.rs23
2 files changed, 15 insertions, 10 deletions
diff --git a/crates/shirabe-class-map-generator/src/class_map_generator.rs b/crates/shirabe-class-map-generator/src/class_map_generator.rs
index f33c93c..391bee9 100644
--- a/crates/shirabe-class-map-generator/src/class_map_generator.rs
+++ b/crates/shirabe-class-map-generator/src/class_map_generator.rs
@@ -29,7 +29,7 @@ impl ClassMapGenerator {
.map(|w| preg_quote(w, None))
.collect();
let stream_wrappers_regex =
- sprintf("{^(?:%s)://}", &[PhpMixed::String(implode("|", &wrappers))]);
+ format!("{{^(?:{})://}}", PhpMixed::String(implode("|", &wrappers)));
ClassMapGenerator {
extensions,
diff --git a/crates/shirabe-class-map-generator/src/php_file_parser.rs b/crates/shirabe-class-map-generator/src/php_file_parser.rs
index d196f8b..84fb418 100644
--- a/crates/shirabe-class-map-generator/src/php_file_parser.rs
+++ b/crates/shirabe-class-map-generator/src/php_file_parser.rs
@@ -27,24 +27,29 @@ impl PhpFileParser {
// Use @ here instead of Silencer to actively suppress 'unhelpful' output
let contents = php_strip_whitespace(path);
if contents.is_empty() {
- let message: &str;
+ let message: String;
if !file_exists(path) {
- message = "File at \"%s\" does not exist, check your classmap definitions";
+ message = format!(
+ "File at \"{}\" does not exist, check your classmap definitions",
+ path
+ );
} else if !Self::is_readable(path) {
- message = "File at \"%s\" is not readable, check its permissions";
+ message = format!(
+ "File at \"{}\" is not readable, check its permissions",
+ path
+ );
} else if trim(file_get_contents(path).unwrap_or_default().as_str(), None).is_empty() {
// The input file was really empty and thus contains no classes
return Ok(vec![]);
} else {
- message =
- "File at \"%s\" could not be parsed as PHP, it may be binary or corrupted";
+ message = format!(
+ "File at \"{}\" could not be parsed as PHP, it may be binary or corrupted",
+ path
+ );
}
let error = error_get_last();
- let mut message = sprintf(
- message,
- &[shirabe_php_shim::PhpMixed::String(path.to_string())],
- );
+ let mut message = message;
if let Some(error) = error
&& let Some(err_msg) = error.get("message")
{