diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-08 04:22:49 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-08 04:23:11 +0900 |
| commit | 632c9793927a30c4bca3c91888e66b369d732dfe (patch) | |
| tree | 5bafb9d7fa2523d5a2f8d70ff59c3173e962e389 /crates/shirabe-php-shim/src | |
| parent | 243450fee9853c2fea66ae0642dabb8db5227d6f (diff) | |
| download | php-shirabe-632c9793927a30c4bca3c91888e66b369d732dfe.tar.gz php-shirabe-632c9793927a30c4bca3c91888e66b369d732dfe.tar.zst php-shirabe-632c9793927a30c4bca3c91888e66b369d732dfe.zip | |
feat(phase-c): resolve PhpMixed-conversion phase-b TODOs
Implement the foundational PhpMixed conversion infrastructure
(From<bool|i64|f64|String>, order-sensitive PartialEq matching PHP ===)
and resolve the category-G phase-b TODOs that depend on it:
- Fix VCS driver cache paths that discarded parsed JSON or diverged on
null caches (svn/forgejo/gitlab/git-bitbucket/github).
- Wire up real conversions previously stubbed or dropped: suggests
platform config, audit ignore-severities, composer_repository search
and ProviderInfo, class_loader prefix/classmap merges, locker lock
diff comparison, advisory JSON serialization, SPDX license fields.
- Make GenericRule take a typed ReasonData; populate RULE_ROOT_REQUIRE
with the constraint and convert PhpMixed at the call sites.
Diffstat (limited to 'crates/shirabe-php-shim/src')
| -rw-r--r-- | crates/shirabe-php-shim/src/lib.rs | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/crates/shirabe-php-shim/src/lib.rs b/crates/shirabe-php-shim/src/lib.rs index 6acdd0e..ad2736b 100644 --- a/crates/shirabe-php-shim/src/lib.rs +++ b/crates/shirabe-php-shim/src/lib.rs @@ -44,6 +44,39 @@ impl serde::Serialize for PhpMixed { } } +/// PHP `===` semantics: type-strict and, for arrays, order-sensitive. +impl PartialEq for PhpMixed { + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (PhpMixed::Null, PhpMixed::Null) => true, + (PhpMixed::Bool(a), PhpMixed::Bool(b)) => a == b, + (PhpMixed::Int(a), PhpMixed::Int(b)) => a == b, + (PhpMixed::Float(a), PhpMixed::Float(b)) => a == b, + (PhpMixed::String(a), PhpMixed::String(b)) => a == b, + (PhpMixed::List(a), PhpMixed::List(b)) => a == b, + (PhpMixed::Array(a), PhpMixed::Array(b)) => { + a.len() == b.len() + && a.iter() + .zip(b.iter()) + .all(|((ka, va), (kb, vb))| ka == kb && va == vb) + } + (PhpMixed::Object(a), PhpMixed::Object(b)) => a == b, + _ => false, + } + } +} + +impl PartialEq for ArrayObject { + fn eq(&self, other: &Self) -> bool { + self.data.len() == other.data.len() + && self + .data + .iter() + .zip(other.data.iter()) + .all(|((ka, va), (kb, vb))| ka == kb && va == vb) + } +} + impl serde::Serialize for ArrayObject { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where @@ -175,26 +208,26 @@ impl PhpMixed { } impl From<bool> for PhpMixed { - fn from(_value: bool) -> Self { - todo!() + fn from(value: bool) -> Self { + PhpMixed::Bool(value) } } impl From<i64> for PhpMixed { - fn from(_value: i64) -> Self { - todo!() + fn from(value: i64) -> Self { + PhpMixed::Int(value) } } impl From<f64> for PhpMixed { - fn from(_value: f64) -> Self { - todo!() + fn from(value: f64) -> Self { + PhpMixed::Float(value) } } impl From<String> for PhpMixed { - fn from(_value: String) -> Self { - todo!() + fn from(value: String) -> Self { + PhpMixed::String(value) } } |
