Skip to content

[4.x] Remove the unused default context merge from the stream transport - #96

Open
Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-stream-remove-unused-context-merge
Open

Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-stream-remove-unused-context-merge

Conversation

@Hackwar

@Hackwar Hackwar commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary of Changes

Stream::request() built $contextOptions by merging the http options of PHP's default stream context (stream_context_get_default()) with the request options, and then never used it: the context for fopen() is created from $options alone, and a context passed to fopen() replaces the default context rather than being merged with it.

This keeps the current behaviour (the default context is not used) and removes the dead code. The alternative, actually merging the default context's http options, would change behaviour in 4.x (a proxy or headers set globally with stream_context_set_default() would suddenly apply), so it was not done; transport.stream already offers a way to pass such options.

Testing Instructions

No behaviour change, so no new test. The existing stream transport tests pass unchanged. To confirm that PHP does not merge the default context:

stream_context_set_default(['http' => ['header' => 'X-Default: 1']]);
$context = stream_context_create(['http' => ['header' => 'X-Own: 1']]);
// Request any URL that echoes the request headers: only X-Own arrives.
file_get_contents($urlThatEchoesHeaders, false, $context);

Documentation Changes Required

docs/classes/TransportInterface.md, "Options": the stream transport does not use PHP's default stream context; use transport.stream instead.

🤖 Generated with Claude Code

The stream transport merged the http options of PHP's default stream
context with its own options into $contextOptions and then never used the
result: the context is created from its own options only, and a context
passed to fopen() replaces the default one. Remove the dead code and
document that the default context is not used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant