aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-external-packages/src/symfony/process
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-27 03:52:05 +0900
committernsfisis <nsfisis@gmail.com>2026-06-27 04:21:34 +0900
commit2b51554ff59d1e5cbf8dd2db65d278b0202a9102 (patch)
treef4d9b0abf4df9b5e363e3bd65511d70e3d5ada00 /crates/shirabe-external-packages/src/symfony/process
parentcc07b5abb83a40d678401c335bdc49bb81b72c5f (diff)
downloadphp-shirabe-2b51554ff59d1e5cbf8dd2db65d278b0202a9102.tar.gz
php-shirabe-2b51554ff59d1e5cbf8dd2db65d278b0202a9102.tar.zst
php-shirabe-2b51554ff59d1e5cbf8dd2db65d278b0202a9102.zip
refactor: fix compiler warnings and clippy warnings
Diffstat (limited to 'crates/shirabe-external-packages/src/symfony/process')
-rw-r--r--crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs6
-rw-r--r--crates/shirabe-external-packages/src/symfony/process/process.rs71
2 files changed, 36 insertions, 41 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs b/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs
index bafd146..43a6567 100644
--- a/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs
+++ b/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs
@@ -15,7 +15,7 @@ pub struct AbstractPipes {
impl AbstractPipes {
pub fn new(input: PhpMixed) -> Self {
- let mut input_buffer = String::new();
+ let input_buffer;
let stored_input;
// TODO(plugin): `$input instanceof \Iterator` is not modeled. The PHP `is_resource($input)`
// branch never applies: a PhpMixed is never a resource, so input is never stored as-is here.
@@ -81,9 +81,7 @@ impl AbstractPipes {
let mut w: Vec<PhpResource> = vec![stdin.clone()];
// let's have a look if something changed in streams
- if php::stream_select(&mut r, &mut w, &mut e, 0, Some(0)).is_none() {
- return None;
- }
+ php::stream_select(&mut r, &mut w, &mut e, 0, Some(0))?;
if !self.input_buffer.is_empty() {
let written = php::fwrite(&stdin, &self.input_buffer, None).unwrap_or(0) as usize;
diff --git a/crates/shirabe-external-packages/src/symfony/process/process.rs b/crates/shirabe-external-packages/src/symfony/process/process.rs
index 1b58972..fbf2da7 100644
--- a/crates/shirabe-external-packages/src/symfony/process/process.rs
+++ b/crates/shirabe-external-packages/src/symfony/process/process.rs
@@ -1045,28 +1045,26 @@ impl Process {
return Ok(());
}
- if let Some(timeout) = self.timeout {
- if timeout < php::microtime() - self.starttime.unwrap_or(0.0) {
- self.stop(0.0, None);
+ if let Some(timeout) = self.timeout
+ && timeout < php::microtime() - self.starttime.unwrap_or(0.0)
+ {
+ self.stop(0.0, None);
- return Err(ProcessTimedOutException::new(
- self,
- ProcessTimedOutException::TYPE_GENERAL,
- )
- .into());
- }
+ return Err(ProcessTimedOutException::new(
+ self,
+ ProcessTimedOutException::TYPE_GENERAL,
+ )
+ .into());
}
- if let Some(idle_timeout) = self.idle_timeout {
- if idle_timeout < php::microtime() - self.last_output_time.unwrap_or(0.0) {
- self.stop(0.0, None);
+ if let Some(idle_timeout) = self.idle_timeout
+ && idle_timeout < php::microtime() - self.last_output_time.unwrap_or(0.0)
+ {
+ self.stop(0.0, None);
- return Err(ProcessTimedOutException::new(
- self,
- ProcessTimedOutException::TYPE_IDLE,
- )
- .into());
- }
+ return Err(
+ ProcessTimedOutException::new(self, ProcessTimedOutException::TYPE_IDLE).into(),
+ );
}
Ok(())
@@ -1242,13 +1240,14 @@ impl Process {
self.cached_exit_code = exitcode;
}
- if let Some(cached) = self.cached_exit_code {
- if !running && exitcode == Some(-1) {
- self.process_information
- .as_mut()
- .unwrap()
- .insert("exitcode".to_string(), PhpMixed::Int(cached));
- }
+ if let Some(cached) = self.cached_exit_code
+ && !running
+ && exitcode == Some(-1)
+ {
+ self.process_information
+ .as_mut()
+ .unwrap()
+ .insert("exitcode".to_string(), PhpMixed::Int(cached));
}
}
@@ -1386,11 +1385,11 @@ impl Process {
if signaled && termsig > 0 {
// if process has been signaled, no exitcode but a valid termsig, apply Unix convention
self.exitcode = Some(128 + termsig);
- } else if self.is_sigchild_enabled() {
- if let Some(i) = self.process_information.as_mut() {
- i.insert("signaled".to_string(), PhpMixed::Bool(true));
- i.insert("termsig".to_string(), PhpMixed::Int(-1));
- }
+ } else if self.is_sigchild_enabled()
+ && let Some(i) = self.process_information.as_mut()
+ {
+ i.insert("signaled".to_string(), PhpMixed::Bool(true));
+ i.insert("termsig".to_string(), PhpMixed::Int(-1));
}
}
@@ -1659,13 +1658,11 @@ impl Process {
key, commandline
))
.into()),
- Some(v) if matches!(v, PhpMixed::Bool(false)) => {
- Err(InvalidArgumentException::new(format!(
- "Command line is missing a value for parameter \"{}\": {}",
- key, commandline
- ))
- .into())
- }
+ Some(PhpMixed::Bool(false)) => Err(InvalidArgumentException::new(format!(
+ "Command line is missing a value for parameter \"{}\": {}",
+ key, commandline
+ ))
+ .into()),
Some(v) => Ok(self.escape_argument(Some(&to_php_string(v)))),
}
},