Skip to content

Fix the argument named by the TypeError of an invalid stream context notification callback - #25556

Open
lacatoire wants to merge 1 commit into
php:PHP-8.5from
lacatoire:fix/standard-stream-context-notification-argument-PHP-8.5
Open

lacatoire wants to merge 1 commit into
php:PHP-8.5from
lacatoire:fix/standard-stream-context-notification-argument-PHP-8.5

Conversation

@lacatoire

Copy link
Copy Markdown
Member

The TypeError for a notification parameter that is not callable names argument #1 in both stream_context_create() and stream_context_set_params(), although the value comes from $params, which is argument #2 of both. It also describes the value as an array of callbacks, while it is a single callable.

To reproduce:

try {
    stream_context_create(null, ['notification' => 'nope']);
} catch (Throwable $e) {
    echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
    stream_context_set_params(stream_context_create(), ['notification' => 'nope']);
} catch (Throwable $e) {
    echo $e::class, ': ', $e->getMessage(), "\n";
}

Before (8.5.12):

TypeError: stream_context_create(): Argument #1 ($options) must be an array with valid callbacks as values, function "nope" not found or invalid function name
TypeError: stream_context_set_params(): Argument #1 ($context) must be an array with valid callbacks as values, function "nope" not found or invalid function name

After:

TypeError: stream_context_create(): Argument #2 ($params) must have a valid callback for key "notification", function "nope" not found or invalid function name
TypeError: stream_context_set_params(): Argument #2 ($params) must have a valid callback for key "notification", function "nope" not found or invalid function name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant