public static void SetItemRef(PhpReference value, string key, ref object var) { Debug.Assert(!(var is PhpReference)); Debug.Assert(!(var is PhpArrayString), "ensures and end-of-chain operators only"); PhpArray array; // PhpArray: if ((array = var as PhpArray) != null) { // a reference in "value" is directly assigned to the array's item: array.SetArrayItemRef(key, value); return; } // null, empty string or empty string of bytes if (IsEmptyForEnsure(var)) { // a reference in "value" is directly assigned to the array's item: PhpArray var_array = new PhpArray(); var_array.SetArrayItemRef(key, value); var = var_array; return; } SetItemRefEpilogue(value, key, ref var); }
public static PhpReference/*!*/ GetItemRef(string key, ref object var) { Debug.Assert(!(var is PhpReference)); Debug.Assert(!(var is PhpArrayString), "ensures and end-of-chain operators only"); // PhpArray: if (var != null && var.GetType() == typeof(PhpArray)) // fast check for PhpArray, not derived types return ((PhpArray)var).GetArrayItemRef(key); // creates a new reference and adds it to an a new array: if (IsEmptyForEnsure(var)) { PhpArray array; var = array = new PhpArray(0, 1); PhpReference result = new PhpReference(); array.SetArrayItemRef(key, result); return result; } return GetItemRefEpilogue(key, ref var); }