diff --git a/runtime-common/core/core-types/definition/mixed.cpp b/runtime-common/core/core-types/definition/mixed.cpp index 52c1a7579..e4d3af26b 100644 --- a/runtime-common/core/core-types/definition/mixed.cpp +++ b/runtime-common/core/core-types/definition/mixed.cpp @@ -1428,6 +1428,11 @@ const mixed mixed::push_back_return(const mixed &v) { bool mixed::isset(int64_t int_key) const { if (unlikely (get_type() != type::ARRAY)) { + if (get_type() == type::OBJECT) { + // TODO think about numeric-like string + auto xxx = from_mixed>(*this, string()); + return f$ArrayAccess$$offsetExists(xxx, int_key); + } if (get_type() == type::STRING) { int_key = as_string().get_correct_index(int_key); return as_string().isset(int_key); @@ -1472,6 +1477,13 @@ bool mixed::isset(double double_key) const { void mixed::unset(int64_t int_key) { if (unlikely (get_type() != type::ARRAY)) { + // TODO f$is_a + if (get_type() == type::OBJECT) { + auto xxx = from_mixed>(*this, string()); + f$ArrayAccess$$offsetUnset(xxx, int_key); + return; + } + if (get_type() != type::NUL && (get_type() != type::BOOLEAN || as_bool())) { php_warning("Cannot use variable of type %s as array in unset", get_type_or_class_name()); } @@ -1484,6 +1496,12 @@ void mixed::unset(int64_t int_key) { void mixed::unset(const mixed &v) { if (unlikely (get_type() != type::ARRAY)) { + if (get_type() == type::OBJECT) { + auto xxx = from_mixed>(*this, string()); + f$ArrayAccess$$offsetUnset(xxx, v); + return; + } + if (get_type() != type::NUL && (get_type() != type::BOOLEAN || as_bool())) { php_warning("Cannot use variable of type %s as array in unset", get_type_or_class_name()); } diff --git a/runtime-common/core/core-types/definition/mixed.inl b/runtime-common/core/core-types/definition/mixed.inl index 98adcac74..642de8a3d 100644 --- a/runtime-common/core/core-types/definition/mixed.inl +++ b/runtime-common/core/core-types/definition/mixed.inl @@ -93,6 +93,12 @@ int64_t spaceship(const T1 &lhs, const T2 &rhs); template bool mixed::isset(const string &string_key, MaybeHash ...maybe_hash) const { if (unlikely (get_type() != type::ARRAY)) { + if (get_type() == type::OBJECT) { + // TODO think about numeric-like string + auto xxx = from_mixed>(*this, string()); + return f$ArrayAccess$$offsetExists(xxx, string_key); + } + int64_t int_key{std::numeric_limits::max()}; if (get_type() == type::STRING) { if (!string_key.try_to_int(&int_key)) { @@ -110,6 +116,12 @@ bool mixed::isset(const string &string_key, MaybeHash ...maybe_hash) const { template void mixed::unset(const string &string_key, MaybeHash ...maybe_hash) { if (unlikely (get_type() != type::ARRAY)) { + if (get_type() == type::OBJECT) { + auto xxx = from_mixed>(*this, string()); + f$ArrayAccess$$offsetUnset(xxx, string_key); + return; + } + if (get_type() != type::NUL && (get_type() != type::BOOLEAN || as_bool())) { php_warning("Cannot use variable of type %s as array in unset", get_type_or_class_name()); }