public static PhpArray GetClassVars(DTypeDesc caller, string className, bool parentsFirst, bool includeStatic) { ScriptContext script_context = ScriptContext.CurrentContext; DTypeDesc type = script_context.ResolveType(className); if (type == null) { return(null); } // determine the calling type //DTypeDesc caller = PhpStackTrace.GetClassContext(); if (caller != null && caller.IsUnknown) { caller = PhpStackTrace.GetClassContext(); } PhpArray result = new PhpArray(); // add instance properties bool have_instance_props = false; if (!type.IsAbstract) { // the class has to be instantiated in order to discover default instance property values // (the constructor will initialize default properties, user defined constructor will not be called) DObject obj = type.New(script_context) as DObject; if (obj == null) { return(null); } // populate the resulting array taking into account current caller IDictionaryEnumerator enumerator = obj.GetEnumerator(caller); while (enumerator.MoveNext()) { result.Add(enumerator.Key, enumerator.Value); } have_instance_props = true; } // add static fields (static and instance fields if the type is abstract) if (includeStatic) { foreach (KeyValuePair <VariableName, DPropertyDesc> pair in type.EnumerateProperties(caller)) { if (pair.Value.IsStatic) { result.Add(pair.Key.ToString(), pair.Value.Get(null)); } else if (!have_instance_props) { result.Add(pair.Key.ToString(), null); } } } result.InplaceCopyOnReturn = true; return(result); }