Pchp.Library.Arrays.array_pop C# (CSharp) Method

array_pop() public static method

Removes the last item from an array and returns it.
Resets intrinsic enumerator.
public static array_pop ( PhpArray array ) : PhpValue
array Pchp.Core.PhpArray The array whcih item to pop.
return Pchp.Core.PhpValue
        public static PhpValue array_pop(PhpArray array)
        {
            if (array == null)
            {
                //PhpException.ReferenceNull("array");
                //return null;
                throw new ArgumentNullException();
            }

            if (array.Count == 0) return PhpValue.Null;

            // dereferences result since the array doesn't do so:
            var result = (array.RemoveLast().Value);    // TODO: PhpVariable.Dereference

            array.RefreshMaxIntegerKey();
            array.RestartIntrinsicEnumerator();

            return result;
        }