From 632c9793927a30c4bca3c91888e66b369d732dfe Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 8 Jun 2026 04:22:49 +0900 Subject: feat(phase-c): resolve PhpMixed-conversion phase-b TODOs Implement the foundational PhpMixed conversion infrastructure (From, 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. --- crates/shirabe-php-shim/src/lib.rs | 49 +++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 8 deletions(-) (limited to 'crates/shirabe-php-shim/src') 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(&self, serializer: S) -> Result where @@ -175,26 +208,26 @@ impl PhpMixed { } impl From for PhpMixed { - fn from(_value: bool) -> Self { - todo!() + fn from(value: bool) -> Self { + PhpMixed::Bool(value) } } impl From for PhpMixed { - fn from(_value: i64) -> Self { - todo!() + fn from(value: i64) -> Self { + PhpMixed::Int(value) } } impl From for PhpMixed { - fn from(_value: f64) -> Self { - todo!() + fn from(value: f64) -> Self { + PhpMixed::Float(value) } } impl From for PhpMixed { - fn from(_value: String) -> Self { - todo!() + fn from(value: String) -> Self { + PhpMixed::String(value) } } -- cgit v1.3.1