Skip to content

Commit

Permalink
correct named arguments for stream_context_create()
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubmisek committed Aug 5, 2024
1 parent 134e374 commit 9d5431a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions src/Peachpie.Library/Streams/StreamContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ public StreamContext()
/// <summary>
/// Create a new context resource from an array of wrapper options.
/// </summary>
/// <param name="data">A 2-dimensional array of wrapper options</param>
public StreamContext(PhpArray data)
: this(data, true) { }
/// <param name="options">A 2-dimensional array of wrapper options</param>
public StreamContext(PhpArray options)
: this(options, true) { }

/// <summary>
/// Create a new context resource from an array of wrapper options.
/// </summary>
/// <param name="data">A 2-dimensional array of wrapper options</param>
/// <param name="options">A 2-dimensional array of wrapper options</param>
/// <param name="registerInCtx">Whether to register this instance in current <see cref="Context"/>. Should be <c>false</c> for static resources.</param>
private StreamContext(PhpArray data, bool registerInCtx)
private StreamContext(PhpArray options, bool registerInCtx)
: base(StreamContextTypeName/*, registerInCtx*/)
{
this.Data = data;
this.Data = options;
}

#endregion
Expand Down
16 changes: 8 additions & 8 deletions src/Peachpie.Library/Streams/Streams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ public static class PhpContexts
#region stream_context_create

/// <summary>Create a new stream context.</summary>
/// <param name="data">The 2-dimensional array in format "options[wrapper][option]".</param>
public static PhpResource stream_context_create(PhpArray data = null)
/// <param name="options">The 2-dimensional array in format "options[wrapper][option]".</param>
public static PhpResource stream_context_create(PhpArray options = null)
{
if (data == null)
if (options == null)
{
return StreamContext.Default;
}

// OK, data lead to a valid stream-context.
if (CheckContextData(data))
if (CheckContextData(options))
{
return new StreamContext(data);
return new StreamContext(options);
}

// Otherwise..
Expand All @@ -62,12 +62,12 @@ public static PhpResource stream_context_create(PhpArray data = null)
/// <summary>
/// Check whether the provided argument is a valid stream-context data array.
/// </summary>
/// <param name="data">The data to be stored into context.</param>
/// <param name="options">The data to be stored into context.</param>
/// <returns></returns>
static bool CheckContextData(PhpArray data)
static bool CheckContextData(PhpArray options)
{
// Check if the supplied data are correctly formed.
var enumerator = data.GetFastEnumerator();
var enumerator = options.GetFastEnumerator();
while (enumerator.MoveNext())
{
if (enumerator.CurrentValue.AsArray() == null)
Expand Down

0 comments on commit 9d5431a

Please sign in to comment.