bool objOffsetIsset(TypedValue& tvRef, ObjectData* base, const Variant& offset, bool validate /* = true */) { auto exists = objOffsetExists(base, offset); // Unless we called ArrayObject::offsetExists, there's nothing more to do if (exists != OffsetExistsResult::IssetIfNonNull) { return (int)exists; } // For ArrayObject::offsetExists, we need to check the value at `offset`. // If it's null, then we return false. TypedValue tvResult; tvWriteUninit(&tvResult); // We can't call the offsetGet method on `base` because users aren't // expecting offsetGet to be called for `isset(...)` expressions, so call // the method on the base ArrayObject class. auto const method = SystemLib::s_ArrayObjectClass->lookupMethod(s_offsetGet.get()); assert(method != nullptr); g_context->invokeFuncFew(&tvResult, method, base, nullptr, 1, offset.asCell()); auto const result = !IS_NULL_TYPE(tvResult.m_type); tvRefcountedDecRef(&tvResult); return result; }
bool objOffsetEmpty(TypedValue& tvRef, ObjectData* base, const Variant& offset, bool validate /* = true */) { if (objOffsetExists(base, offset) == OffsetExistsResult::DoesNotExist) { return true; } TypedValue* result = objOffsetGet(tvRef, base, offset, false); assert(result); return !cellToBool(*tvToCell(result)); }
bool objOffsetEmpty(TypedValue& tvRef, ObjectData* base, CVarRef offset, bool validate /* = true */) { if (!objOffsetExists(base, offset)) { return true; } TypedValue* result = objOffsetGet(tvRef, base, offset, false); assert(result); return empty(tvAsCVarRef(result)); }
bool objOffsetEmpty( ObjectData* base, TypedValue offset, bool validate /* = true */ ) { if (objOffsetExists(base, offset) == OffsetExistsResult::DoesNotExist) { return true; } auto value = objOffsetGet(base, offset, false); auto result = !cellToBool(*tvToCell(&value)); tvRefcountedDecRef(value); return result; }
bool objOffsetIsset( ObjectData* base, TypedValue offset, bool validate /* = true */ ) { auto exists = objOffsetExists(base, offset); // Unless we called ArrayObject::offsetExists, there's nothing more to do. if (exists != OffsetExistsResult::IssetIfNonNull) { return (int)exists; } // For ArrayObject::offsetExists, we need to check the value at `offset`. If // it's null, then we return false. We can't call the offsetGet method on // `base` because users aren't expecting offsetGet to be called for // `isset(...)` expressions, so call the method on the base ArrayObject class. auto const cls = SystemLib::s_ArrayObjectClass; auto const method = cls->lookupMethod(s_offsetGet.get()); assert(method != nullptr); auto result = g_context->invokeMethodV(base, method, InvokeArgs(&offset, 1)); return !result.isNull(); }
bool objOffsetIsset(TypedValue& tvRef, ObjectData* base, CVarRef offset, bool validate /* = true */) { return objOffsetExists(base, offset); }