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

array_shift() public static method

Removes the first item of an array and reindex integer keys starting from zero.
Resets intrinsic enumerator.
public static array_shift ( PhpArray array ) : PhpValue
array Pchp.Core.PhpArray The array to be shifted.
return Pchp.Core.PhpValue
        public static PhpValue array_shift(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.RemoveFirst().Value;  // TODO: PhpVariable.Dereference

            // reindexes integer keys starting from zero:
            array.ReindexIntegers(0);
            array.RestartIntrinsicEnumerator();

            return result;
        }