/// <summary> /// Performs bitwise negation. /// </summary> internal static PhpValue BitNot(ref PhpValue x) { switch (x.TypeCode) { case PhpTypeCode.Long: return PhpValue.Create(~x.Long); case PhpTypeCode.Int32: return PhpValue.Create(~x.ToLong()); case PhpTypeCode.Alias: return BitNot(ref x.Alias.Value); case PhpTypeCode.String: case PhpTypeCode.WritableString: throw new NotImplementedException(); // bitwise negation of each character in string case PhpTypeCode.Object: if (x.Object == null) { return PhpValue.Null; } goto default; default: // TODO: Err UnsupportedOperandTypes return PhpValue.Null; } }
/// <summary> /// Constructs the object with single runtime field <c>scalar</c>. /// </summary> /// <param name="scalar">Value of <c>scalar</c> field.</param> internal stdClass(PhpValue scalar) { __peach__runtimeFields = new PhpArray(1) { { new IntStringKey("scalar"), scalar } }; }
/// <summary> /// Creates an aliased value. /// </summary> public PhpAlias(PhpValue value, int refcount = 1) { Debug.Assert(refcount >= 1); Debug.Assert(value.TypeCode != PhpTypeCode.Alias); Value = value; _refcount = refcount; }
/// <summary> /// Performs bitwise or operation. /// </summary> internal static PhpValue BitOr(ref PhpValue x, ref PhpValue y) { var xtype = x.TypeCode; if (xtype == PhpTypeCode.String || xtype == PhpTypeCode.WritableString) { var ytype = y.TypeCode; if (ytype == PhpTypeCode.String || ytype == PhpTypeCode.WritableString) { throw new NotImplementedException(); } } // return PhpValue.Create(x.ToLong() | y.ToLong()); }
/// <summary> /// Calls a function or a method defined by callback with arguments stored in an array. /// </summary> /// <param name="ctx">Current runtime context.</param> /// <param name="function">Target callback.</param> /// <param name="args">Arguments. Can be null.</param> /// <returns>The returned value.</returns> public static PhpValue call_user_func_array(Context ctx, IPhpCallable function, PhpArray args) { PhpValue[] args_array; if (args != null && args.Count != 0) { args_array = new PhpValue[args.Count]; args.CopyValuesTo(args_array, 0); } else { args_array = Core.Utilities.ArrayUtils.EmptyValues; } return call_user_func(ctx, function, args_array); }
public static TextElement FromValue(Context ctx, PhpValue value) { switch (value.TypeCode) { case PhpTypeCode.Object: if (value.Object is byte[]) { return new TextElement((byte[])value.Object); } goto default; case PhpTypeCode.WritableString: return new TextElement(value.WritableString, ctx.StringEncoding); default: return new TextElement(value.ToStringOrThrow(ctx)); } }
public static int Compare(string sx, PhpValue y) { switch (y.TypeCode) { case PhpTypeCode.Double: return Compare(sx, y.Double); case PhpTypeCode.Long: return Compare(sx, y.Long); case PhpTypeCode.Boolean: return Compare(Convert.ToBoolean(sx), y.Boolean); case PhpTypeCode.String: return Compare(sx, y.String); case PhpTypeCode.WritableString: return Compare(sx, y.WritableString.ToString()); case PhpTypeCode.Alias: return Compare(sx, y.Alias.Value); case PhpTypeCode.Undefined: return (sx.Length == 0) ? 0 : 1; case PhpTypeCode.Object: if (y.Object == null) return (sx.Length == 0) ? 0 : 1; break; } throw new NotImplementedException($"compare(String, {y.TypeCode})"); }
public static int Compare(double dx, PhpValue y) { switch (y.TypeCode) { case PhpTypeCode.Double: return Compare(dx, y.Double); case PhpTypeCode.Long: return Compare(dx, (double)y.Long); case PhpTypeCode.Boolean: return Compare(dx != 0.0, y.Boolean); case PhpTypeCode.String: return -Compare(y.String, dx); case PhpTypeCode.WritableString: return -Compare(y.WritableString.ToString(), dx); case PhpTypeCode.Alias: return Compare(dx, y.Alias.Value); case PhpTypeCode.Undefined: return (dx == 0.0) ? 0 : 1; case PhpTypeCode.Object: if (y.Object == null) return (dx == 0.0) ? 0 : 1; break; } throw new NotImplementedException($"compare(Double, {y.TypeCode})"); }
int ProcessStatus(Context ctx, ref PhpValue status) { switch (status.TypeCode) { case PhpTypeCode.Alias: return ProcessStatus(ctx, ref status.Alias.Value); case PhpTypeCode.Long: case PhpTypeCode.Int32: return (int)status.ToLong(); default: if (ctx != null) { ctx.Echo(status); } return 0; } }
/// <summary> /// Tries to get a global constant from current context. /// </summary> internal bool TryGetConstant(string name, out PhpValue value, ref int idx) { value = _constants.GetConstant(name, ref idx); return(value.IsSet); }
/// <summary> /// Debug textual representation of the value. /// </summary> public abstract string DisplayString(ref PhpValue me);
/// <summary> /// Gets value as a callable object that can be invoked dynamically. /// </summary> public static IPhpCallable AsCallable(PhpValue value, RuntimeTypeHandle callerCtx, object callerObj) => value.AsCallable(callerCtx, callerObj);
static PhpValue preg_replace(Context ctx, string pattern, string replacement, PhpCallable callback, PhpValue subject, int limit, ref long count) { var regex = new PerlRegex.Regex(pattern); // TODO: count // TODO: callback var subject_array = subject.AsArray(); if (subject_array == null) { return PhpValue.Create(regex.Replace(subject.ToStringOrThrow(ctx), replacement, limit)); } else { var arr = new PhpArray(subject_array, false); var enumerator = arr.GetFastEnumerator(); while (enumerator.MoveNext()) { var newvalue = regex.Replace(enumerator.CurrentValue.ToStringOrThrow(ctx), replacement, limit); enumerator.CurrentValue = PhpValue.Create(newvalue); } return PhpValue.Create(arr); } }
//class HtmlDumpFormatter : DumpFormatter //{ //} #endregion /// <summary> /// Outputs or returns human-readable information about a variable. /// </summary> /// <param name="ctx">Current runtime context.</param> /// <param name="value">The variable.</param> /// <param name="returnString">Whether to return a string representation.</param> /// <returns>A string representation or <c>true</c> if <paramref name="returnString"/> is <c>false</c>.</returns> public static PhpValue print_r(Context ctx, PhpValue value, bool returnString = false) { var output = (new PrintFormatter(ctx, "\n")).Serialize(value); if (returnString) { // output to a string: return PhpValue.Create(output); } else { // output to script context: ctx.Echo(output); return PhpValue.True; } }
/// <summary> /// Checks whether a dereferenced variable is numeric. /// </summary> /// <param name="variable">The variable.</param> /// <returns>Whether <paramref name="variable"/> is integer, double or numeric string. /// <seealso cref="PHP.Core.Convert.StringToNumber"/></returns> public static bool is_numeric(PhpValue variable) { switch (variable.TypeCode) { case PhpTypeCode.Int32: case PhpTypeCode.Long: case PhpTypeCode.Double: return true; case PhpTypeCode.String: case PhpTypeCode.WritableString: PhpNumber tmp; return (variable.ToNumber(out tmp) & Core.Convert.NumberInfo.IsNumber) != 0; default: return false; } }
/// <summary> /// Converts given value to a class object. /// </summary> public static object ToClass(PhpValue value) => value.ToClass();
/// <summary> /// Casts value to <see cref="PhpArray"/> or <c>null</c>. /// </summary> public static PhpArray AsArray(PhpValue value) => value.AsArray();
/// <summary> /// Converts value to an array. /// </summary> public static PhpArray ToArray(PhpValue value) => value.ToArray();
/// <summary> /// Gets underlaying class instance or <c>null</c>. /// </summary> public static object AsObject(PhpValue value) => value.AsObject();
/// <summary> /// Creates an instance of a type dynamically with constructor overload resolution. /// </summary> /// <param name="classname">Full name of the class to instantiate. The name uses PHP syntax of name separators (<c>\</c>) and is case insensitive.</param> /// <param name="arguments">Arguments to be passed to the constructor.</param> /// <returns>Object instance or <c>null</c> if class is not declared.</returns> public object Create(string classname, params object[] arguments) => Create(classname, PhpValue.FromClr(arguments));
/// <summary> /// Call a function by its name dynamically. /// </summary> /// <param name="function">Function name valid within current runtime context.</param> /// <param name="arguments">Arguments to be passed to the function call.</param> /// <returns>Returns value given from the function call.</returns> public PhpValue Call(string function, params object[] arguments) => PhpCallback.Create(function, default(RuntimeTypeHandle)).Invoke(this, PhpValue.FromClr(arguments));
/// <summary> /// Gets value as a callable object that can be invoked dynamically. /// </summary> public static IPhpCallable AsCallable(PhpValue value, RuntimeTypeHandle callerCtx) => value.AsCallable(callerCtx);
/// <summary> /// Checks whether a dereferenced variable is a <B>null</B> reference. /// </summary> /// <param name="variable">The variable.</param> /// <returns>Whether <paramref name="variable"/> is a <B>null</B> reference.</returns> public static bool is_null(PhpValue variable) => variable.IsNull;
/// <summary> /// Tries conversion to an array key. /// </summary> public static bool TryToIntStringKey(PhpValue value, out IntStringKey key) => value.TryToIntStringKey(out key);
/// <summary> /// Verifies that the contents of a variable can be called as a function. /// </summary> /// <param name="ctx">Current runtime context.</param> /// <param name="variable">The variable.</param> /// <param name="syntaxOnly">If <B>true</B>, it is only checked that has <pararef name="variable"/> /// a valid structure to be used as a callback. if <B>false</B>, the existence of the function (or /// method) is also verified.</param> /// <param name="callableName">Receives the name of the function or method (for example /// <c>SomeClass::SomeMethod</c>).</param> /// <returns><B>true</B> if <paramref name="variable"/> denotes a function, <B>false</B> /// otherwise.</returns> public static bool is_callable(Context ctx /*, caller*/, PhpValue variable, bool syntaxOnly, out string callableName) { var callback = variable.AsCallable(); if (PhpVariable.IsValidCallback(callback)) { callableName = callback.ToString(); return true; } callableName = variable.ToString(ctx); return false; }
static void AddScriptReference(Assembly assembly) { if (assembly == null) { throw new ArgumentNullException(nameof(assembly)); } // remember the assembly for class map: s_assClassMap.AddPhpAssemblyNoLock(assembly); // reflect the module for imported symbols: var module = assembly.ManifestModule; // PhpPackageReferenceAttribute foreach (var r in module.GetCustomAttributes <PhpPackageReferenceAttribute>()) { Context.AddScriptReference(r.ScriptType); } // ImportPhpTypeAttribute foreach (var t in module.GetCustomAttributes <ImportPhpTypeAttribute>()) { TypesTable.DeclareAppType(PhpTypeInfoExtension.GetPhpTypeInfo(t.ImportedType)); } // ImportPhpFunctionsAttribute foreach (var t in module.GetCustomAttributes <ImportPhpFunctionsAttribute>()) { // TODO: remember the container, do not reflect repetitiously foreach (var m in t.ContainerType.GetMethods()) { if (m.IsPublic && m.IsStatic && !m.IsPhpHidden()) { RoutinesTable.DeclareAppRoutine(m.Name, m); } } } // ImportPhpConstantsAttribute foreach (var t in module.GetCustomAttributes <ImportPhpConstantsAttribute>()) { // TODO: remember the container, do not reflect repetitiously foreach (var m in t.ContainerType.GetMembers(BindingFlags.Static | BindingFlags.Public)) { if (m is FieldInfo fi && !fi.IsPhpHidden()) { Debug.Assert(fi.IsStatic && fi.IsPublic); if (fi.IsInitOnly || fi.IsLiteral) { ConstsMap.DefineAppConstant(fi.Name, PhpValue.FromClr(fi.GetValue(null))); } else { ConstsMap.DefineAppConstant(fi.Name, new Func <PhpValue>(() => PhpValue.FromClr(fi.GetValue(null)))); } }
public static PhpValue preg_replace(Context ctx, PhpValue pattern, PhpValue replacement, PhpValue subject, int limit = -1) { long count; return preg_replace(ctx, pattern, replacement, subject, limit, out count); }
/// <summary> /// Defines a runtime constant. /// </summary> public bool DefineConstant(string name, PhpValue value, bool ignorecase = false) => _constants.DefineConstant(name, value, ignorecase);
/// <summary> /// Add a value to the end of array. /// Value can be an alias. /// </summary> void IPhpArray.AddValue(PhpValue value) { throw new NotSupportedException(); }
void IConstantsComposition.Define(string name, PhpValue value) => DefineConstant(name, value, ignorecase: false);
/// <summary> /// Outputs current value to the <see cref="Context.Output"/> or <see cref="Context.OutputStream"/>. /// </summary> public abstract void Output(ref PhpValue me, Context ctx);
/// <summary> /// Checks whether a dereferenced variable is double. /// Alias for is_float(). /// </summary> /// <param name="variable">The variable.</param> /// <returns>Whether <paramref name="variable"/> is double.</returns> public static bool is_double(PhpValue variable) => variable.TypeCode == PhpTypeCode.Double;
/// <summary> /// Defines a runtime constant. /// </summary> internal bool DefineConstant(string name, PhpValue value, ref int idx, bool ignorecase = false) => _constants.DefineConstant(name, value, ref idx, ignorecase);
/// <summary> /// Checks whether a dereferenced variable is string. /// </summary> /// <param name="variable">The variable.</param> /// <returns>Whether <paramref name="variable"/> is string.</returns> public static bool is_string(PhpValue variable) => variable.TypeCode == PhpTypeCode.String || variable.TypeCode == PhpTypeCode.WritableString;
// TODO: static AddScript(string path, MainDelegate @delegate) #endregion #region Constants /// <summary> /// Tries to get a global constant from current context. /// </summary> public bool TryGetConstant(string name, out PhpValue value) { int idx = 0; return(TryGetConstant(name, out value, ref idx)); }
/// <summary> /// Checks whether a dereferenced variable is <see cref="Core.Reflection.DObject"/>. /// </summary> /// <param name="variable">The variable.</param> /// <returns>Whether <paramref name="variable"/> is <see cref="Core.Reflection.DObject"/>.</returns> public static bool is_object(PhpValue variable) => variable.IsObject && variable.Object != null && !(variable.Object is __PHP_Incomplete_Class);
/// <summary> /// Flushes data on current level of buffering to the sinks or to the previous level. /// The current level clean up MUST follow this method's call. /// </summary> internal void InternalFlush() { Debug.Assert(_level != null); if (_level.filter == null) { if (_level.Index == 0) { // TODO: PhpString buffers // NOTE: avoid calling non-async on ASP.NET Core 3.0; consider changing to async // writes top-level data to sinks: for (int i = 0; i < _level.buffers.Count; i++) { var element = _level.buffers[i]; if (element.data is char[] chars) { _charSink.Write(chars, 0, element.size); } else { _byteSink .WriteAsync((byte[])element.data, 0, element.size) .GetAwaiter() .GetResult(); } } } else { // joins levels (data are not copied => the current level MUST be cleaned up after the return from this method): if (_level.size > 0) { var lower_level = _levels[_level.Index - 1]; lower_level.buffers.AddRange(_level.buffers); lower_level.size += _level.size; lower_level.freeSpace = _level.freeSpace; // free space in the last buffer of the level lower_level.containsByteData |= _level.containsByteData; lower_level.containsCharData |= _level.containsCharData; } } } else { // gets data from user's callback: var data = _level.filter.Invoke(_ctx, GetContent(), PhpValue.Create((int)(ChunkPosition.First | ChunkPosition.Middle | ChunkPosition.Last))); if (!data.IsEmpty) { var bytes = data.AsBytesOrNull(_ctx); // writes data to the current level of buffering or to sinks depending on the level count: if (_level.Index == 0) { // checks whether the filtered data are binary at first; if not so, converts them to a string: if (bytes != null) { _byteSink.Write(bytes); } else { // TODO: PhpString containing both string and byte[] _charSink.Write(data.ToString(_ctx)); } } else { // temporarily decreases the level of buffering toredirect writes to the lower level: var old_level = _level; _level = _levels[_level.Index - 1]; // checks whether the filtered data are binary at first; if not so, converts them to a string: if (bytes != null) { Stream.Write(bytes); } else { // TODO: PhpString containing both string and byte[] this.Write(data.ToString(_ctx)); } // restore the level of buffering: _level = old_level; } } } }
void IConstantsComposition.Define(string name, PhpValue value, bool ignoreCase) => DefineConstant(name, value, ignoreCase);
/// <summary> /// Checks whether a dereferenced variable is double. /// </summary> /// <param name="variable">The variable.</param> /// <returns>Whether <paramref name="variable"/> is double.</returns> public static bool is_float(PhpValue variable) => is_double(variable);
public PhpHashEntryDebugView(IntStringKey key, PhpValue value) { _key = key; _value = value; }
/// <summary> /// Checks whether a dereferenced variable is double. /// Alias for is_float(). /// </summary> /// <param name="variable">The variable.</param> /// <returns>Whether <paramref name="variable"/> is double.</returns> public static bool is_real(PhpValue variable) => is_double(variable);
/// <summary> /// Gets <see cref="IPhpArray"/> instance providing access to the value with array operators. /// Returns <c>null</c> if underlaying value does provide array access. /// </summary> public virtual IPhpArray GetArrayAccess(ref PhpValue me) => null;
/// <summary> /// Checks whether a dereferenced variable is an <see cref="PhpArray"/>. /// </summary> /// <param name="variable">The variable.</param> /// <returns>Whether <paramref name="variable"/> is <see cref="PhpArray"/>.</returns> public static bool is_array(PhpValue variable) => variable.IsArray;
/// <summary> /// Accesses the value as an array and gets item at given index. /// Gets <c>void</c> value in case the key is not found. /// </summary> public virtual PhpValue GetArrayItem(ref PhpValue me, PhpValue index, bool quiet) => PhpValue.Null;
/// <summary> /// Checks whether a dereferenced variable is a valid <see cref="PhpResource"/>. /// </summary> /// <param name="variable">The variable.</param> /// <returns>Whether <paramref name="variable"/> is a valid <see cref="PhpResource"/>.</returns> public static bool is_resource(PhpValue variable) { //PhpResource res = variable as PhpResource; //return res != null && res.IsValid; throw new NotImplementedException(); }
/// <summary> /// Accesses the value as an array and gets item at given index. /// Gets empty value in case the key is not found. /// </summary> public virtual PhpAlias EnsureItemAlias(ref PhpValue me, PhpValue index, bool quiet) => new PhpAlias(PhpValue.Null);
/// <summary> /// Checks whether a dereferenced variable is a scalar. /// </summary> /// <param name="variable">The variable.</param> /// <returns>Whether <paramref name="variable"/> is an integer, a double, a bool or a string after dereferencing.</returns> public static bool is_scalar(PhpValue variable) => PhpVariable.IsScalar(variable);
/// <summary> /// Converts value to an array. /// </summary> public abstract PhpArray ToArray(ref PhpValue me);
/// <summary> /// Verifies that the contents of a variable can be called as a function. /// </summary> /// <param name="variable">The variable.</param> /// <param name="syntaxOnly">If <B>true</B>, it is only checked that has <pararef name="variable"/> /// a valid structure to be used as a callback. if <B>false</B>, the existence of the function (or /// method) is also verified.</param> /// <returns><B>true</B> if <paramref name="variable"/> denotes a function, <B>false</B> /// otherwise.</returns> public static bool is_callable(PhpValue variable, bool syntaxOnly = false) { return PhpVariable.IsValidCallback(variable.AsCallable()); // TODO: check syntaxOnly || can be bound }
/// <summary> /// Gets <see cref="PhpArray"/> or throws an exception. /// </summary> public virtual PhpArray GetArray(ref PhpValue me) => throw new InvalidCastException();
public PhpString Serialize(PhpValue value) { _output = new PhpString(); _indent = 0; // Accept(value); _output.Append(_nl); return _output; }
/// <summary> /// Gets underlaying class instance or <c>null</c>. /// </summary> public virtual object AsObject(ref PhpValue me) => null;
/// <summary> /// Outputs or returns a pars-able string representation of a variable. /// </summary> /// <param name="ctx">Current runtime context.</param> /// <param name="variable">The variable.</param> /// <param name="returnString">Whether to return a string representation.</param> /// <returns>A string representation or a <c>null</c> reference if <paramref name="returnString"/> is <c>false</c>.</returns> public static string var_export(Context ctx, PhpValue variable, bool returnString = false) { var output = (new ExportFormatter(ctx, "\n")).Serialize(variable); if (returnString) { // output to a string: return output.ToString(ctx); } else { // output to script context: ctx.Echo(output); return null; } }
/// <summary> /// Gets callable wrapper for dynamic object invocation. /// </summary> /// <param name="me"></param> /// <param name="callerCtx">Current caller type.</param> /// <returns>Instance of a callable object, cannot be <c>null</c>, can be invalid.</returns> public virtual IPhpCallable AsCallable(ref PhpValue me, RuntimeTypeHandle callerCtx) => PhpCallback.CreateInvalid();
/// <summary> /// Perform a regular expression search and replace. /// </summary> /// <param name="ctx">A reference to current context. Cannot be <c>null</c>.</param> /// <param name="pattern">The pattern to search for. It can be either a string or an array with strings.</param> /// <param name="replacement">The string or an array with strings to replace. /// If this parameter is a string and the pattern parameter is an array, all patterns will be /// replaced by that string. If both pattern and replacement parameters are arrays, each pattern will be /// replaced by the replacement counterpart. If there are fewer elements in the replacement array than /// in the pattern array, any extra patterns will be replaced by an empty string.</param> /// <param name="subject">The string or an array with strings to search and replace. /// If subject is an array, then the search and replace is performed on every entry of subject, and the return value is an array as well.</param> /// <param name="limit">The maximum possible replacements for each pattern in each subject string. Defaults to <c>-1</c> (no limit).</param> /// <param name="count">This variable will be filled with the number of replacements done.</param> /// <returns></returns> public static PhpValue preg_replace(Context ctx, PhpValue pattern, PhpValue replacement, PhpValue subject, int limit, out long count) { count = 0; // PHP's behaviour for undocumented limit range if (limit < -1) { limit = 0; } // var replacement_array = replacement.AsArray(); var pattern_array = pattern.AsArray(); if (pattern_array == null) { if (replacement_array == null) { // string pattern // string replacement return preg_replace(ctx, pattern.ToStringOrThrow(ctx), replacement.ToStringOrThrow(ctx), null, subject, limit, ref count); } else { // string pattern and array replacement not allowed: throw new ArgumentException("replacement_array_pattern_not", nameof(replacement)); // return PhpValue.Null; } } else if (replacement_array == null) { // array pattern // string replacement } else { // array pattern // array replacement } throw new NotImplementedException(); }
/// <summary> /// Creates a deep copy of PHP variable. /// </summary> /// <returns>A deep copy of the value.</returns> public virtual PhpValue DeepCopy(ref PhpValue me) => me;
/// <summary> /// Sets value at specific index. Value must not be an alias. /// </summary> void IPhpArray.SetItemValue(IntStringKey key, PhpValue value) { int index = key.IsInteger ? key.Integer : (int)Convert.StringToLongInteger(key.String); char ch; switch (value.TypeCode) { case PhpTypeCode.Long: ch = (char)value.Long; break; case PhpTypeCode.String: ch = (value.String.Length != 0) ? value.String[0] : '\0'; break; case PhpTypeCode.WritableString: ch = value.WritableString[0]; break; // TODO: other types default: throw new NotSupportedException(value.TypeCode.ToString()); } this[key.Integer] = ch; }
/// <summary> /// Performs dereferencing and deep copying of the value inplace. /// </summary> public virtual void PassValue(ref PhpValue me) { }
public virtual bool SetParameter(StreamParameterOptions option, PhpValue value) { // Do not display error messages here, the caller will. // EX: will have to distinguish between failed and unsupported. // (use additional message when fails) // Descendants may call this default implementation for unhandled options switch (option) { case StreamParameterOptions.BlockingMode: // Unimplemented in Win32 PHP. return false; case StreamParameterOptions.ReadBufferSize: // Unused option (only turns buffering off) return false; case StreamParameterOptions.WriteBufferSize: if (value.IsInteger()) { // Let the write buffer reset on next write operation. FlushWriteBuffer(); writeBuffer = null; // Set the new size (0 to disable write buffering). writeBufferSize = (int)value.ToLong(); if (writeBufferSize < 0) writeBufferSize = 0; return true; } return false; case StreamParameterOptions.ReadTimeout: // Set the read timeout for network-based streams (overrides DefaultTimeout). this.readTimeout = (double)value; return false; case StreamParameterOptions.SetChunkSize: if (value.IsInteger()) { // This setting will affect reading after the buffers are emptied. readChunkSize = (int)value.ToLong(); if (readChunkSize < 1) readChunkSize = 1; return true; } return false; case StreamParameterOptions.Locking: return false; case StreamParameterOptions.MemoryMap: return false; case StreamParameterOptions.Truncate: // EX: [Truncate] Override SetParameter in NativeStream to truncate a local file. return false; default: Debug.Assert(false); // invalid option return false; } }
public static stdClass ToObject(PhpString value) => new stdClass(PhpValue.Create(value.DeepCopy()));