Skip to content

Commit 8773317

Browse files
alexisbouchezclaude
andcommitted
style: cargo fmt
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 63be1d2 commit 8773317

File tree

4 files changed

+20
-43
lines changed

4 files changed

+20
-43
lines changed

crates/php-rs-vm/src/builtins/file.rs

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,8 +1265,8 @@ pub(crate) fn dispatch(
12651265
let stream_id = args.first().map(|v| v.to_long()).unwrap_or(0);
12661266
let seconds = args.get(1).map(|v| v.to_long()).unwrap_or(0) as u64;
12671267
let microseconds = args.get(2).map(|v| v.to_long()).unwrap_or(0) as u64;
1268-
let duration =
1269-
std::time::Duration::from_secs(seconds) + std::time::Duration::from_micros(microseconds);
1268+
let duration = std::time::Duration::from_secs(seconds)
1269+
+ std::time::Duration::from_micros(microseconds);
12701270
if let Some(handle) = vm.file_handles.get_mut(&stream_id) {
12711271
match handle.set_timeout(duration) {
12721272
Ok(()) => Ok(Some(Value::Bool(true))),
@@ -1303,21 +1303,15 @@ pub(crate) fn dispatch(
13031303
},
13041304
Err(e) => {
13051305
vm.write_back_arg(1, Value::Long(0), ref_args, ref_prop_args);
1306-
vm.write_back_arg(
1307-
2,
1308-
Value::String(e.to_string()),
1309-
ref_args,
1310-
ref_prop_args,
1311-
);
1306+
vm.write_back_arg(2, Value::String(e.to_string()), ref_args, ref_prop_args);
13121307
return Ok(Some(Value::Bool(false)));
13131308
}
13141309
};
13151310
match std::net::TcpStream::connect_timeout(&resolved, timeout) {
13161311
Ok(stream) => {
13171312
let id = vm.next_resource_id;
13181313
vm.next_resource_id += 1;
1319-
let handle =
1320-
php_rs_ext_standard::file::FileHandle::from_tcp_stream(stream);
1314+
let handle = php_rs_ext_standard::file::FileHandle::from_tcp_stream(stream);
13211315
vm.file_handles.insert(id, handle);
13221316
Ok(Some(Value::Resource(id, "stream".to_string())))
13231317
}
@@ -1328,12 +1322,7 @@ pub(crate) fn dispatch(
13281322
ref_args,
13291323
ref_prop_args,
13301324
);
1331-
vm.write_back_arg(
1332-
2,
1333-
Value::String(e.to_string()),
1334-
ref_args,
1335-
ref_prop_args,
1336-
);
1325+
vm.write_back_arg(2, Value::String(e.to_string()), ref_args, ref_prop_args);
13371326
Ok(Some(Value::Bool(false)))
13381327
}
13391328
}
@@ -1346,8 +1335,7 @@ pub(crate) fn dispatch(
13461335
Ok(listener) => {
13471336
let id = vm.next_resource_id;
13481337
vm.next_resource_id += 1;
1349-
let handle =
1350-
php_rs_ext_standard::file::FileHandle::from_tcp_listener(listener);
1338+
let handle = php_rs_ext_standard::file::FileHandle::from_tcp_listener(listener);
13511339
vm.file_handles.insert(id, handle);
13521340
Ok(Some(Value::Resource(id, "stream".to_string())))
13531341
}
@@ -1358,12 +1346,7 @@ pub(crate) fn dispatch(
13581346
ref_args,
13591347
ref_prop_args,
13601348
);
1361-
vm.write_back_arg(
1362-
2,
1363-
Value::String(e.to_string()),
1364-
ref_args,
1365-
ref_prop_args,
1366-
);
1349+
vm.write_back_arg(2, Value::String(e.to_string()), ref_args, ref_prop_args);
13671350
Ok(Some(Value::Bool(false)))
13681351
}
13691352
}
@@ -1374,12 +1357,7 @@ pub(crate) fn dispatch(
13741357
if let Some(server_handle) = vm.file_handles.get(&server_id) {
13751358
match server_handle.accept() {
13761359
Ok((client_handle, peer_name)) => {
1377-
vm.write_back_arg(
1378-
2,
1379-
Value::String(peer_name),
1380-
ref_args,
1381-
ref_prop_args,
1382-
);
1360+
vm.write_back_arg(2, Value::String(peer_name), ref_args, ref_prop_args);
13831361
let id = vm.next_resource_id;
13841362
vm.next_resource_id += 1;
13851363
vm.file_handles.insert(id, client_handle);
@@ -1449,8 +1427,10 @@ pub(crate) fn dispatch(
14491427
None // Block indefinitely
14501428
} else {
14511429
let secs = tv_sec.to_long();
1452-
Some(std::time::Duration::from_secs(secs as u64)
1453-
+ std::time::Duration::from_micros(tv_usec as u64))
1430+
Some(
1431+
std::time::Duration::from_secs(secs as u64)
1432+
+ std::time::Duration::from_micros(tv_usec as u64),
1433+
)
14541434
};
14551435

14561436
// Count ready streams from the read array

crates/php-rs-vm/src/builtins/misc.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3151,26 +3151,23 @@ fn php_proc_open(
31513151
if let Some(stdin) = child.stdin.take() {
31523152
let id = vm.next_resource_id;
31533153
vm.next_resource_id += 1;
3154-
let handle =
3155-
php_rs_ext_standard::file::FileHandle::from_process_stdin(stdin);
3154+
let handle = php_rs_ext_standard::file::FileHandle::from_process_stdin(stdin);
31563155
vm.file_handles.insert(id, handle);
31573156
pipes_arr.set_int(0, Value::Resource(id, "stream".to_string()));
31583157
}
31593158

31603159
if let Some(stdout) = child.stdout.take() {
31613160
let id = vm.next_resource_id;
31623161
vm.next_resource_id += 1;
3163-
let handle =
3164-
php_rs_ext_standard::file::FileHandle::from_process_stdout(stdout);
3162+
let handle = php_rs_ext_standard::file::FileHandle::from_process_stdout(stdout);
31653163
vm.file_handles.insert(id, handle);
31663164
pipes_arr.set_int(1, Value::Resource(id, "stream".to_string()));
31673165
}
31683166

31693167
if let Some(stderr) = child.stderr.take() {
31703168
let id = vm.next_resource_id;
31713169
vm.next_resource_id += 1;
3172-
let handle =
3173-
php_rs_ext_standard::file::FileHandle::from_process_stderr(stderr);
3170+
let handle = php_rs_ext_standard::file::FileHandle::from_process_stderr(stderr);
31743171
vm.file_handles.insert(id, handle);
31753172
pipes_arr.set_int(2, Value::Resource(id, "stream".to_string()));
31763173
}

crates/php-rs-vm/src/builtins/remaining.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,10 @@ pub(crate) fn dispatch(
13851385
// stream_get_transports not yet in file.rs
13861386
"stream_get_transports" => {
13871387
let mut arr = PhpArray::new();
1388-
for t in &["tcp", "udp", "unix", "udg", "ssl", "tls", "tlsv1.0", "tlsv1.1", "tlsv1.2", "tlsv1.3"] {
1388+
for t in &[
1389+
"tcp", "udp", "unix", "udg", "ssl", "tls", "tlsv1.0", "tlsv1.1", "tlsv1.2",
1390+
"tlsv1.3",
1391+
] {
13891392
arr.push(Value::String(t.to_string()));
13901393
}
13911394
Ok(Some(Value::Array(arr)))

crates/php-rs-vm/src/value.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ pub enum Value {
6666
Reference(Rc<RefCell<Value>>),
6767

6868
/// Internal: foreach iterator state (not a PHP-visible type).
69-
_Iterator {
70-
array: PhpArray,
71-
index: usize,
72-
},
69+
_Iterator { array: PhpArray, index: usize },
7370

7471
/// Internal: generator iterator state for foreach over generators.
7572
_GeneratorIterator {

0 commit comments

Comments
 (0)