//void __clone() { throw new NotImplementedException(); } public void __construct(Context ctx, PhpValue @class, string name) { var tinfo = ReflectionUtils.ResolvePhpTypeInfo(ctx, @class); _pinfo = tinfo.GetDeclaredProperty(name); if (_pinfo == null) { throw new ReflectionException(); } }
public void __construct(Context ctx, PhpValue @class, string name) { if (name != null) { _tinfo = ReflectionUtils.ResolvePhpTypeInfo(ctx, @class); _routine = _tinfo.RuntimeMethods[name] ?? throw new ReflectionException(string.Format(Resources.Resources.method_does_not_exist, _tinfo.Name, name)); } else { __construct(ctx, @class.AsString(ctx)); } }
public virtual void __construct(Context ctx, PhpValue /*string|array*/ function, PhpValue /*string|int*/ parameter) { // resolve RoutineInfo: PhpTypeInfo declaringclass = null; RoutineInfo routine = null; var function_str = function.AsString(); if (function_str != null) { routine = ctx.GetDeclaredFunction(function_str); } else { var function_arr = function.AsArray(); if (function_arr != null && function_arr.Count == 2) { declaringclass = ReflectionUtils.ResolvePhpTypeInfo(ctx, function_arr[0]); // cannot be null routine = declaringclass.RuntimeMethods[function_arr[1].ToStringOrThrow(ctx)]; } } if (routine != null) { var func = (declaringclass == null) ? (ReflectionFunctionAbstract) new ReflectionFunction(routine) : new ReflectionMethod(declaringclass, routine); // resolve parameter: var parameters = ReflectionUtils.ResolveReflectionParameters(func, routine.Methods); var pstr = parameter.AsString(); if (pstr != null) { SetParameter(parameters.First(p => p._name == pstr)); return; } else { if (parameter.IsLong(out long index) && index < parameters.Count && index >= 0) { SetParameter(parameters[(int)index]); return; } } } throw new ReflectionException(); }
public void __construct(Context ctx, PhpValue @class, string name) { if (name != null) { _tinfo = ReflectionUtils.ResolvePhpTypeInfo(ctx, @class); _routine = _tinfo.RuntimeMethods[name] ?? throw new ReflectionException(string.Format(Resources.Resources.method_does_not_exist, _tinfo.Name, name)); } else if (@class.IsString(out var class_method)) { __construct(ctx, class_method); } else { throw new ReflectionException(string.Format("Invalid method name '{0}'", @class.ToString(ctx))); } // get the real declaring type from routine: _tinfo = _routine.DeclaringType ?? _tinfo; }
public virtual void __construct(Context ctx, PhpValue @class) { Debug.Assert(_tinfo == null, "Subsequent call not allowed."); _tinfo = ReflectionUtils.ResolvePhpTypeInfo(ctx, @class); }