/// <summary> /// Reports an error when a variable should be PHP object but it is not. /// </summary> /// <param name="reference">Whether a reference modifier (=&) is used.</param> /// <param name="var">The variable which was misused.</param> /// <exception cref="PhpException"><paramref name="var"/> is <see cref="PhpArray"/> (Warning).</exception> /// <exception cref="PhpException"><paramref name="var"/> is scalar type (Warning).</exception> /// <exception cref="PhpException"><paramref name="var"/> is a string (Warning).</exception> public static void VariableMisusedAsObject(object var, bool reference) { Debug.Assert(var != null); if (var is PhpArray) { PhpException.Throw(PhpError.Warning, CoreResources.GetString("array_used_as_object")); } else if (PhpVariable.IsString(var)) { PhpException.Throw(PhpError.Warning, CoreResources.GetString(reference ? "string_item_used_as_reference" : "string_used_as_object")); } else { PhpException.Throw(PhpError.Warning, CoreResources.GetString("scalar_used_as_object", PhpVariable.GetTypeName(var))); } }
/// <summary> /// Reports an error when a variable should be PHP array but it is not. /// </summary> /// <param name="reference">Whether a reference modifier (=&) is used.</param> /// <param name="var">The variable which was misused.</param> /// <exception cref="PhpException"><paramref name="var"/> is <see cref="PhpArray"/> (Warning).</exception> /// <exception cref="PhpException"><paramref name="var"/> is scalar type (Warning).</exception> /// <exception cref="PhpException"><paramref name="var"/> is a string (Warning).</exception> public static void VariableMisusedAsArray(object var, bool reference) { Debug.Assert(var != null); DObject obj; if ((obj = var as DObject) != null) { PhpException.Throw(PhpError.Warning, CoreResources.GetString("object_used_as_array", obj.TypeName)); } else if (PhpVariable.IsString(var)) { PhpException.Throw(PhpError.Warning, CoreResources.GetString(reference ? "string_item_used_as_reference" : "string_used_as_array")); } else { PhpException.Throw(PhpError.Warning, CoreResources.GetString("scalar_used_as_array", PhpVariable.GetTypeName(var))); } }