diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-13 11:38:20 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-13 17:49:15 +0900 |
| commit | 69c372ba0eca61b05260d6d208445d9e69d14e34 (patch) | |
| tree | ab837346f5729a5a4a67ccd83462033511b41c89 /crates/shirabe-php-shim | |
| parent | efe5bdb1987411a473d4af15451a376d20928245 (diff) | |
| download | php-shirabe-69c372ba0eca61b05260d6d208445d9e69d14e34.tar.gz php-shirabe-69c372ba0eca61b05260d6d208445d9e69d14e34.tar.zst php-shirabe-69c372ba0eca61b05260d6d208445d9e69d14e34.zip | |
fix(console): flatten Application inheritance to restore overrides
Composer\Console\Application embedded Symfony's Application as an
`inner` field and delegated to it, so polymorphic calls inside the
Symfony base (e.g. doRun -> $this->getLongVersion()) resolved to
Symfony's own methods and never reached Composer's overrides. As a
result `--version` bypassed Composer's getLongVersion()/doRun()
entirely.
Flatten the PHP inheritance chain into the single shirabe Application
struct: take in the Symfony base methods (parent-calling overrides kept
under a `base_` prefix) and drop the `inner` delegation. Replace the
Symfony Application struct in shirabe-external-packages with an
`Application` trait that the merged struct implements, so commands and
descriptors can reference it without a reverse crate dependency.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-php-shim')
| -rw-r--r-- | crates/shirabe-php-shim/src/lib.rs | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/crates/shirabe-php-shim/src/lib.rs b/crates/shirabe-php-shim/src/lib.rs index 2142a04..59626ea 100644 --- a/crates/shirabe-php-shim/src/lib.rs +++ b/crates/shirabe-php-shim/src/lib.rs @@ -991,8 +991,20 @@ pub trait JsonSerializable { fn json_serialize(&self) -> PhpMixed; } -pub fn in_array(_needle: PhpMixed, _haystack: &PhpMixed, _strict: bool) -> bool { - todo!() +pub fn in_array(needle: PhpMixed, haystack: &PhpMixed, strict: bool) -> bool { + let values: Vec<&PhpMixed> = match haystack { + PhpMixed::List(items) => items.iter().map(|item| item.as_ref()).collect(), + PhpMixed::Array(map) => map.values().map(|item| item.as_ref()).collect(), + _ => return false, + }; + + if !strict { + // TODO(phase-c): non-strict in_array needs PHP's loose `==` comparison semantics. Only the + // strict path is implemented; loose comparison is deferred rather than approximated. + todo!("non-strict in_array (PHP loose comparison)"); + } + + values.iter().any(|value| **value == needle) } // TODO(phase-c): takes &Path and returns Option<PathBuf> @@ -1963,8 +1975,8 @@ pub fn mb_strlen(_s: &str, _encoding: &str) -> i64 { todo!() } -pub fn stream_isatty(_stream: PhpMixed) -> bool { - todo!() +pub fn stream_isatty(stream: PhpResource) -> bool { + stream_isatty_resource(&stream) } pub fn posix_getuid() -> i64 { @@ -1979,11 +1991,11 @@ pub fn posix_getpwuid(_uid: i64) -> PhpMixed { todo!() } -pub fn posix_isatty(_stream: PhpMixed) -> bool { +pub fn posix_isatty(_stream: PhpResource) -> bool { todo!() } -pub fn fstat(_stream: PhpMixed) -> PhpMixed { +pub fn fstat(_stream: PhpResource) -> PhpMixed { todo!() } @@ -2010,6 +2022,7 @@ pub fn putenv(setting: &str) -> bool { /// PHP superglobal $_SERVER access. In the CLI SAPI $_SERVER is populated from /// the environment, which is the only source modeled here. pub fn server_get(name: &str) -> Option<String> { + // TODO: is var_os() better? std::env::var(name).ok() } @@ -2023,9 +2036,10 @@ pub fn server_contains_key(name: &str) -> bool { std::env::var_os(name).is_some() } -/// PHP superglobal $_ENV access -pub fn env_get(_name: &str) -> Option<String> { - todo!() +/// PHP superglobal $_ENV access. +pub fn env_get(name: &str) -> Option<String> { + // TODO: is var_os() better? + std::env::var(name).ok() } // TODO(php-runtime): modify the real PHP's $_ENV. @@ -2034,8 +2048,8 @@ pub fn env_set(_name: &str, _value: String) {} // TODO(php-runtime): modify the real PHP's $_ENV. pub fn env_unset(_name: &str) {} -pub fn env_contains_key(_name: &str) -> bool { - todo!() +pub fn env_contains_key(name: &str) -> bool { + std::env::var_os(name).is_some() } pub fn trim(_s: &str, _chars: Option<&str>) -> String { @@ -2518,10 +2532,6 @@ pub fn round(_value: f64, _precision: i64) -> f64 { todo!() } -pub fn stdin_handle() -> PhpMixed { - todo!() -} - pub fn composer_dev_warning_time() -> i64 { todo!() } |
