Beispiel #1
0
        public PhpAlias GetAlias(ref PhpValue value, Context ctx, Type classContext)
        {
            PhpValue tmp;

            if (value.AsObject() is ArrayAccess arrayaccess)
            {
                // special case for ArrayAccess avoids conversion to IntStringKey

                tmp = arrayaccess.offsetGet(Key);

                switch (Next.Operation)
                {
                case RuntimeChainOperation.ArrayItem:
                    tmp = PhpValue.EnsureAlias(ref tmp);
                    break;

                case RuntimeChainOperation.Property:
                    tmp = PhpValue.FromClass(PhpValue.EnsureObject(ref tmp));
                    break;

                case RuntimeChainOperation.End:
                    return(PhpValue.EnsureAlias(ref tmp));

                default:
                    throw new InvalidOperationException();
                }
            }
            else
            {
                var arr = PhpValue.EnsureArray(ref value);

                switch (Next.Operation)
                {
                case RuntimeChainOperation.ArrayItem:
                    tmp = PhpValue.Create(arr.EnsureItemArray(Key));
                    break;

                case RuntimeChainOperation.Property:
                    tmp = PhpValue.FromClass(arr.EnsureItemObject(Key));
                    break;

                case RuntimeChainOperation.End:
                    return(arr.EnsureItemAlias(Key));

                default:
                    throw new InvalidOperationException();
                }
            }

            //
            return(Next.GetAlias(ref tmp, ctx, classContext));
        }
Beispiel #2
0
        public virtual PhpAlias EnsureAlias(Context ctx, object instance)
        {
            var value = GetValue(ctx, instance);

            return(PhpValue.EnsureAlias(ref value));
        }
Beispiel #3
0
        RuntimeChainOperation IRuntimeChain.Operation => RuntimeChainOperation.End; // -1

        public PhpAlias GetAlias(ref PhpValue value, Context ctx, Type classContext) => PhpValue.EnsureAlias(ref value);