diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-17 03:02:18 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-17 04:57:19 +0900 |
| commit | 8d6dbf51af859ad0017ed8d1358824d9386d48c8 (patch) | |
| tree | 129c05d82609a707f12a061104988d463a49b751 /crates/shirabe-php-shim/src/lib.rs | |
| parent | a1c7e6908a26e10f6e1f23a51721664b5e2d838d (diff) | |
| download | php-shirabe-8d6dbf51af859ad0017ed8d1358824d9386d48c8.tar.gz php-shirabe-8d6dbf51af859ad0017ed8d1358824d9386d48c8.tar.zst php-shirabe-8d6dbf51af859ad0017ed8d1358824d9386d48c8.zip | |
fix(php-shim): resolve duplicate definitions and compile errors
- Remove duplicate function/constant definitions that were added during
porting (strpos, str_contains, str_starts_with, is_scalar, strlen,
substr, strtoupper, str_replace, sprintf, array_keys, str_ends_with,
is_int, array_values, is_object, is_numeric, PHP_EOL,
FILTER_VALIDATE_EMAIL, PHP_VERSION_ID)
- Replace old spl_autoload_register/unregister (PhpMixed args) with
typed Box<dyn Fn> versions
- Replace old array_pop/array_shift/array_unshift/array_splice with
generic/correctly-typed versions
- Replace old trim(chars: &str) with trim(chars: Option<&str>)
- Rename array_slice(PhpMixed) to array_slice_mixed to coexist with
the typed array_slice<V>(IndexMap<String, V>) version
- Fix chdir return type Result<()> -> anyhow::Result<()>
- Add anyhow dependency to shirabe-php-shim
Diffstat (limited to 'crates/shirabe-php-shim/src/lib.rs')
| -rw-r--r-- | crates/shirabe-php-shim/src/lib.rs | 101 |
1 files changed, 2 insertions, 99 deletions
diff --git a/crates/shirabe-php-shim/src/lib.rs b/crates/shirabe-php-shim/src/lib.rs index 323d8f8..2c09d7c 100644 --- a/crates/shirabe-php-shim/src/lib.rs +++ b/crates/shirabe-php-shim/src/lib.rs @@ -130,10 +130,6 @@ pub fn is_numeric(value: &PhpMixed) -> bool { todo!() } -pub fn trim(s: &str, chars: &str) -> String { - todo!() -} - pub fn strtotime(time: &str) -> Option<i64> { todo!() } @@ -174,18 +170,6 @@ pub fn spl_autoload_functions() -> Vec<PhpMixed> { todo!() } -pub fn spl_autoload_register(callback: PhpMixed) { - todo!() -} - -pub fn spl_autoload_unregister(callback: PhpMixed) -> bool { - todo!() -} - -pub fn array_pop(array: &mut Vec<String>) -> Option<String> { - todo!() -} - pub fn array_push(array: &mut Vec<String>, value: String) -> i64 { todo!() } @@ -194,15 +178,6 @@ pub fn array_search_in_vec(needle: &str, haystack: &[String]) -> Option<usize> { todo!() } -pub fn array_splice<T: Clone>( - array: &mut Vec<T>, - offset: usize, - length: usize, - replacement: &[T], -) -> Vec<T> { - todo!() -} - pub fn array_map_str_fn<F: Fn(&str) -> String>(callback: F, array: &[String]) -> Vec<String> { todo!() } @@ -255,7 +230,7 @@ pub fn count_mixed(value: &PhpMixed) -> i64 { todo!() } -pub fn array_slice(value: &PhpMixed, offset: i64, length: Option<i64>) -> PhpMixed { +pub fn array_slice_mixed(value: &PhpMixed, offset: i64, length: Option<i64>) -> PhpMixed { todo!() } @@ -263,14 +238,6 @@ pub fn array_slice_strs(value: &[String], offset: i64, length: Option<i64>) -> V todo!() } -pub fn array_shift<T>(array: &mut Vec<T>) -> T { - todo!() -} - -pub fn array_unshift<T>(array: &mut Vec<T>, value: T) -> i64 { - todo!() -} - pub fn empty(value: &PhpMixed) -> bool { todo!() } @@ -912,7 +879,7 @@ pub fn getcwd() -> Option<String> { todo!() } -pub fn chdir(path: &str) -> Result<()> { +pub fn chdir(path: &str) -> anyhow::Result<()> { todo!() } @@ -1156,7 +1123,6 @@ pub fn get_current_user() -> String { } pub const FILE_IGNORE_NEW_LINES: i64 = 2; -pub const FILTER_VALIDATE_EMAIL: i64 = 274; pub fn array_diff(array1: &[String], array2: &[String]) -> Vec<String> { todo!() @@ -1235,7 +1201,6 @@ pub fn reset<T: Clone>(array: &[T]) -> Option<T> { } pub const OPENSSL_ALGO_SHA384: i64 = 9; -pub const PHP_VERSION_ID: i64 = 80100; pub fn array_intersect_key( array1: &IndexMap<String, Box<PhpMixed>>, @@ -1378,10 +1343,6 @@ pub fn is_link(path: &str) -> bool { todo!() } -pub fn strpos(haystack: &str, needle: &str) -> Option<usize> { - todo!() -} - pub fn str_pad(input: &str, length: usize, pad_string: &str, pad_type: i64) -> String { todo!() } @@ -1394,24 +1355,12 @@ pub fn abs(value: i64) -> i64 { todo!() } -pub fn str_contains(haystack: &str, needle: &str) -> bool { - todo!() -} - -pub fn str_starts_with(haystack: &str, needle: &str) -> bool { - todo!() -} - pub const DATE_ATOM: &str = "Y-m-d\\TH:i:sP"; pub fn ucfirst(s: &str) -> String { todo!() } -pub fn is_scalar(value: &PhpMixed) -> bool { - todo!() -} - pub fn strval(value: &PhpMixed) -> String { todo!() } @@ -1424,18 +1373,6 @@ pub fn mb_strlen(s: &str, encoding: &str) -> i64 { todo!() } -pub fn strlen(s: &str) -> i64 { - todo!() -} - -pub fn substr(s: &str, offset: i64, length: Option<i64>) -> String { - todo!() -} - -pub fn strtoupper(s: &str) -> String { - todo!() -} - pub fn stream_isatty(stream: PhpMixed) -> bool { todo!() } @@ -1506,10 +1443,6 @@ pub fn env_contains_key(name: &str) -> bool { todo!() } -pub fn str_replace(search: &str, replace: &str, subject: &str) -> String { - todo!() -} - pub fn trim(s: &str, chars: Option<&str>) -> String { todo!() } @@ -1518,10 +1451,6 @@ pub fn count(value: &PhpMixed) -> i64 { todo!() } -pub fn sprintf(format: &str, args: &[PhpMixed]) -> String { - todo!() -} - pub fn array_shift<T>(array: &mut Vec<T>) -> Option<T> { todo!() } @@ -1570,10 +1499,6 @@ pub fn array_intersect<T: Clone + PartialEq>(array1: &[T], array2: &[T]) -> Vec< todo!() } -pub fn array_keys<V>(array: &IndexMap<String, V>) -> Vec<String> { - todo!() -} - pub fn mkdir(pathname: &str, mode: u32, recursive: bool) -> bool { todo!() } @@ -1674,10 +1599,6 @@ pub fn json_last_error() -> i64 { todo!() } -pub fn str_ends_with(haystack: &str, needle: &str) -> bool { - todo!() -} - pub fn sort<T: Ord>(array: &mut Vec<T>) { todo!() } @@ -1703,10 +1624,6 @@ pub fn ksort<V>(array: &mut IndexMap<String, V>) { todo!() } -pub fn is_int(value: &PhpMixed) -> bool { - todo!() -} - pub fn is_null(value: &PhpMixed) -> bool { todo!() } @@ -1719,10 +1636,6 @@ pub fn array_is_list(array: &PhpMixed) -> bool { todo!() } -pub fn array_values<V: Clone>(array: &IndexMap<String, V>) -> Vec<V> { - todo!() -} - pub fn array_splice<T>( array: &mut Vec<T>, offset: i64, @@ -1751,14 +1664,6 @@ pub fn array_merge_recursive(arrays: Vec<PhpMixed>) -> PhpMixed { todo!() } -pub fn is_object(value: &PhpMixed) -> bool { - todo!() -} - -pub fn is_numeric(value: &PhpMixed) -> bool { - todo!() -} - pub fn levenshtein(string1: &str, string2: &str) -> i64 { todo!() } @@ -1775,8 +1680,6 @@ pub fn asort<V: Ord>(array: &mut IndexMap<String, V>) { todo!() } -pub const PHP_EOL: &str = "\n"; - pub const PHP_INT_MAX: i64 = i64::MAX; pub const PHP_INT_MIN: i64 = i64::MIN; pub const PHP_INT_SIZE: i64 = 8; |
