Exemplo n.º 1
0
 public static void UndeclaredStaticProperty(string className, string fieldName)
 {
     PhpException.Throw(PhpError.Error, CoreResources.GetString("undeclared_static_property_accessed", className, fieldName));
 }
Exemplo n.º 2
0
 public static void StaticPropertyUnset(string className, string fieldName)
 {
     PhpException.Throw(PhpError.Error, CoreResources.GetString("static_property_unset", className, fieldName));
 }
Exemplo n.º 3
0
 protected override PhpReference /*!*/ GetArrayItemRefOverride(string key)
 {
     PhpException.VariableMisusedAsArray(obj, true);
     return(new PhpReference());
 }
Exemplo n.º 4
0
 public static void ThisUsedOutOfObjectContext()
 {
     PhpException.Throw(PhpError.Error, CoreResources.GetString("this_used_out_of_object"));
 }
Exemplo n.º 5
0
 public static void MethodNotAccessible(string className, string methodName, string context, bool isProtected)
 {
     PhpException.Throw(PhpError.Error, CoreResources.GetString(
                            isProtected ? "protected_method_called" : "private_method_called", className, methodName, context));
 }
Exemplo n.º 6
0
 public static void NoSuitableOverload(string className, string /*!*/ methodName)
 {
     PhpException.Throw(PhpError.Error, CoreResources.GetString(
                            (className != null) ? "no_suitable_method_overload" : "no_suitable_function_overload",
                            className, methodName));
 }
Exemplo n.º 7
0
 protected override DObject EnsureItemIsObjectOverride(object key, ScriptContext /*!*/ context)
 {
     // error (postponed error, which cannot be reported by the previous operator):
     PhpException.VariableMisusedAsObject(obj, false);
     return(null);
 }
Exemplo n.º 8
0
 public static void ConstantNotAccessible(string className, string constName, string context, bool isProtected)
 {
     PhpException.Throw(PhpError.Error, CoreResources.GetString(
                            isProtected ? "protected_constant_accessed" : "private_constant_accessed", className, constName, context));
 }
Exemplo n.º 9
0
 protected override PhpArray EnsureItemIsArrayOverride(object key)
 {
     // error (postponed error, which cannot be reported by the previous operator):
     PhpException.VariableMisusedAsArray(obj, false);
     return(null);
 }
Exemplo n.º 10
0
 protected override PhpArray EnsureItemIsArrayOverride()
 {
     PhpException.VariableMisusedAsArray(obj, false);
     return(null);
 }
Exemplo n.º 11
0
 protected override void SetArrayItemRefOverride(object key, PhpReference value)
 {
     PhpException.VariableMisusedAsArray(obj, true);
 }
Exemplo n.º 12
0
 protected override void SetArrayItemOverride(string key, object value)
 {
     PhpException.VariableMisusedAsArray(obj, true);
 }
Exemplo n.º 13
0
 protected override void SetArrayItemOverride(object value)
 {
     PhpException.VariableMisusedAsArray(obj, false);
 }
Exemplo n.º 14
0
 public static void UndefinedMethodCalled(string className, string methodName)
 {
     PhpException.Throw(PhpError.Error, CoreResources.GetString("undefined_method_called", className, methodName));
 }
Exemplo n.º 15
0
 protected override DObject EnsureItemIsObjectOverride(ScriptContext /*!*/ context)
 {
     PhpException.VariableMisusedAsObject(obj, false);
     return(null);
 }
Exemplo n.º 16
0
 public static void AbstractMethodCalled(string className, string methodName)
 {
     PhpException.Throw(PhpError.Error, CoreResources.GetString("abstract_method_called", className, methodName));
 }
Exemplo n.º 17
0
 /// <summary>
 /// Sets new session name.
 /// </summary>
 /// <param name="request">Valid request context.</param>
 /// <param name="name">New session name.</param>
 /// <returns>Whether session name was changed successfully.</returns>
 public virtual bool SetSessionName(RequestContext /*!*/ request, string name)
 {
     PhpException.FunctionNotSupported(PhpError.Notice);
     return(false);
 }
Exemplo n.º 18
0
 public static void PropertyNotAccessible(string className, string fieldName, string context, bool isProtected)
 {
     PhpException.Throw(PhpError.Error, CoreResources.GetString(
                            isProtected ? "protected_property_accessed" : "private_property_accessed", className, fieldName, context));
 }
Exemplo n.º 19
0
        /// <summary>
        /// Returns names and values of properties whose names have been returned by <c>__sleep</c>.
        /// </summary>
        /// <param name="instance">The instance being serialized.</param>
        /// <param name="sleepResult">The array returned by <c>__sleep</c>.</param>
        /// <param name="context">Current <see cref="ScriptContext"/>.</param>
        /// <returns>Name-value pairs. Names are properly formatted for serialization.</returns>
        /// <exception cref="PhpException">Property of the name returned from <c>__sleep</c> does not exist.</exception>
        /// <remarks>
        /// This method returns exactly <paramref name="sleepResult"/>'s <see cref="PhpHashtable.Count"/> items.
        /// </remarks>
        public static IEnumerable <KeyValuePair <string, object> > EnumerateSerializableProperties(
            DObject /*!*/ instance,
            PhpArray /*!*/ sleepResult,
            ScriptContext /*!*/ context)
        {
            foreach (object item in sleepResult.Values)
            {
                PhpMemberAttributes visibility;
                string name = PHP.Core.Convert.ObjectToString(item);
                string declaring_type_name;
                string property_name = ParsePropertyName(name, out declaring_type_name, out visibility);

                DTypeDesc declarer;
                if (declaring_type_name == null)
                {
                    declarer = instance.TypeDesc;
                }
                else
                {
                    declarer = context.ResolveType(declaring_type_name);
                    if (declarer == null)
                    {
                        // property name refers to an unknown class -> value will be null
                        yield return(new KeyValuePair <string, object>(name, null));

                        continue;
                    }
                }

                // obtain the property desc and decorate the prop name according to its visibility and declaring class
                DPropertyDesc property;
                if (instance.TypeDesc.GetProperty(new VariableName(property_name), declarer, out property) ==
                    GetMemberResult.OK && !property.IsStatic)
                {
                    if ((Enums.VisibilityEquals(visibility, property.MemberAttributes) &&
                         visibility != PhpMemberAttributes.Public)
                        ||
                        (visibility == PhpMemberAttributes.Private &&
                         declarer != property.DeclaringType))
                    {
                        // if certain conditions are met, serialize the property as null
                        // (this is to precisely mimic the PHP behavior)
                        yield return(new KeyValuePair <string, object>(name, null));

                        continue;
                    }
                    name = FormatPropertyName(property, property_name);
                }
                else
                {
                    property = null;
                }

                // obtain the property value
                object val = null;

                if (property != null)
                {
                    val = property.Get(instance);
                }
                else if (instance.RuntimeFields == null || !instance.RuntimeFields.TryGetValue(name, out val))
                {
                    // this is new in PHP 5.1
                    PhpException.Throw(PhpError.Notice, CoreResources.GetString("sleep_returned_bad_field", name));
                }

                yield return(new KeyValuePair <string, object>(name, val));
            }
        }
Exemplo n.º 20
0
 public static void CannotInstantiateType(string typeName, bool isInterface)
 {
     PhpException.Throw(PhpError.Error, CoreResources.GetString(
                            isInterface ? "interface_instantiated" : "abstract_class_instantiated", typeName));
 }
Exemplo n.º 21
0
 public static void UnsupportedOperandTypes()
 {
     PhpException.Throw(PhpError.Error, CoreResources.GetString("unsupported_operand_types"));
 }
Exemplo n.º 22
0
 public static void PropertyTypeMismatch(string /*!*/ className, string /*!*/ propertyName)
 {
     PhpException.Throw(PhpError.Error, CoreResources.GetString("property_type_mismatch",
                                                                className, propertyName));
 }
Exemplo n.º 23
0
 /// <summary>
 /// Throws an error because <B>[]</B> cannot be used in read context.
 /// </summary>
 public override object Get(object var, ScriptContext context, DTypeDesc caller)
 {
     PhpException.Throw(PhpError.Error, CoreResources.operator_array_access_used_for_reading);
     return(null);
 }