HOT_FUNC_VM int64_t ak_exist_string_obj(ObjectData* obj, StringData* key) { if (obj->isCollection()) { return collectionOffsetContains(obj, key); } CArrRef arr = obj->o_toArray(); int64_t res = ak_exist_string_impl(arr.get(), key); return res; }
HOT_FUNC bool f_array_key_exists(CVarRef key, CVarRef search) { const ArrayData *ad; auto const searchCell = search.asCell(); if (LIKELY(searchCell->m_type == KindOfArray)) { ad = searchCell->m_data.parr; } else if (searchCell->m_type == KindOfObject) { ObjectData* obj = searchCell->m_data.pobj; if (obj->isCollection()) { return collectionOffsetContains(obj, key); } return f_array_key_exists(key, toArray(search)); } else { throw_bad_type_exception("array_key_exists expects an array or an object; " "false returned."); return false; } auto const cell = key.asCell(); switch (cell->m_type) { case KindOfString: case KindOfStaticString: { int64_t n = 0; StringData *sd = cell->m_data.pstr; if (sd->isStrictlyInteger(n)) { return ad->exists(n); } return ad->exists(StrNR(sd)); } case KindOfInt64: return ad->exists(cell->m_data.num); case KindOfUninit: case KindOfNull: return ad->exists(empty_string); default: break; } raise_warning("Array key should be either a string or an integer"); return false; }