diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-07-02 01:32:03 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-07-02 01:34:49 +0900 |
| commit | eab3a31c5750013c53c0eb02adc976d6757dc9f7 (patch) | |
| tree | c84b4bc6243668eb79c00af98e00800c2951077b /crates/shirabe-php-shim/src/fs.rs | |
| parent | dda045eb663524b40e277047e3cea301738e5c26 (diff) | |
| download | php-shirabe-eab3a31c5750013c53c0eb02adc976d6757dc9f7.tar.gz php-shirabe-eab3a31c5750013c53c0eb02adc976d6757dc9f7.tar.zst php-shirabe-eab3a31c5750013c53c0eb02adc976d6757dc9f7.zip | |
chore(lint): ban std::io::Read/Write, Any, Command use imports
Extends no_banned_use to cover std::any::Any, std::io::Read/Write, and
std::process::Command, and teaches the linter to allow `as _` imports
so trait methods can still be brought into scope without binding the
banned name. Fully qualifies all existing usages across the codebase.
Diffstat (limited to 'crates/shirabe-php-shim/src/fs.rs')
| -rw-r--r-- | crates/shirabe-php-shim/src/fs.rs | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/crates/shirabe-php-shim/src/fs.rs b/crates/shirabe-php-shim/src/fs.rs index ba6eef6..e58623a 100644 --- a/crates/shirabe-php-shim/src/fs.rs +++ b/crates/shirabe-php-shim/src/fs.rs @@ -4,6 +4,7 @@ use crate::StreamBacking; use crate::StreamState; use crate::UnexpectedValueException; use indexmap::IndexMap; +use std::io::{Read as _, Write as _}; pub const PHP_EOL: &str = "\n"; @@ -329,7 +330,6 @@ pub fn fopen(file: &str, mode: &str) -> Result<PhpResource, std::io::Error> { /// PHP `fwrite()`. `length` caps the number of bytes written (`None` = whole string). /// Returns the byte count written, or `None` for PHP's `false`-on-failure. pub fn fwrite(stream: &PhpResource, data: &str, length: Option<i64>) -> Option<i64> { - use std::io::Write; let bytes = data.as_bytes(); let bytes = match length { Some(l) if l >= 0 => &bytes[..(l as usize).min(bytes.len())], @@ -360,7 +360,6 @@ pub fn fwrite(stream: &PhpResource, data: &str, length: Option<i64>) -> Option<i /// TODO(phase-e): byte-string semantics — should return Vec<u8>; from_utf8_lossy can corrupt /// binary reads (filesAreEqual / binary copy). pub fn fread(stream: &PhpResource, length: i64) -> Option<String> { - use std::io::Read; let cap = length.max(0) as usize; match stream { PhpResource::Stdin => { @@ -482,7 +481,6 @@ fn fgets_read_line<R: std::io::Read + ?Sized>( /// PHP `fgetc()`: reads a single byte, or `None` at end-of-stream. /// TODO(phase-e): byte-string semantics — should return Vec<u8>. pub fn fgetc(stream: &PhpResource) -> Option<String> { - use std::io::Read; let mut byte = [0u8; 1]; match stream { PhpResource::Stdin => { @@ -638,7 +636,6 @@ fn build_stat_map(size: u64, file_meta: Option<&std::fs::Metadata>) -> IndexMap< /// PHP `fflush()`. pub fn fflush(stream: &PhpResource) -> bool { - use std::io::Write; match stream { PhpResource::Stdin => true, PhpResource::Stdout => std::io::stdout().flush().is_ok(), @@ -848,7 +845,6 @@ pub fn file_put_contents(_path: &str, _data: &[u8]) -> Option<i64> { } pub fn file_put_contents3(_filename: &str, _data: &str, _flags: i64) -> Option<i64> { - use std::io::Write; // TODO(phase-d): the LOCK_EX and FILE_USE_INCLUDE_PATH flags are ignored; only FILE_APPEND is // honored. let append = _flags & FILE_APPEND != 0; |
