Exemple #1
0
        internal static object GetUserArrayItem(DObject /*!*/ arrayAccess, object index, Operators.GetItemKinds kind)
        {
            PhpStack stack = ScriptContext.CurrentContext.Stack;

            switch (kind)
            {
            case Operators.GetItemKinds.Isset:
                // pass isset() ""/null to say true/false depending on the value returned from "offsetExists":
                stack.AddFrame(index);
                return(Core.Convert.ObjectToBoolean(arrayAccess.InvokeMethod(offsetExists, null, stack.Context)) ? "" : null);

            case Operators.GetItemKinds.Empty:
                // if "offsetExists" returns false, the empty()/isset() returns false (pass null to say true/false):
                // otherwise, "offsetGet" is called to retrieve the value, which is passed to isset():
                stack.AddFrame(index);
                if (!Core.Convert.ObjectToBoolean(arrayAccess.InvokeMethod(offsetExists, null, stack.Context)))
                {
                    return(null);
                }
                else
                {
                    goto default;
                }

            default:
                // regular getter:
                stack.AddFrame(index);
                return(PhpVariable.Dereference(arrayAccess.InvokeMethod(offsetGet, null, stack.Context)));
            }
        }
Exemple #2
0
        protected override void SetArrayItemRefOverride(object key, PhpReference value)
        {
            PhpStack stack = ScriptContext.CurrentContext.Stack;

            stack.AddFrame(key, value);
            arrayAccess.InvokeMethod(offsetSet, null, stack.Context);
        }
Exemple #3
0
        protected override object GetArrayItemOverride(object key, bool quiet)
        {
            PhpStack stack = ScriptContext.CurrentContext.Stack;

            stack.AddFrame(key);
            return(PhpVariable.Dereference(arrayAccess.InvokeMethod(offsetGet, null, stack.Context)));
        }