Skip to content

Stdlib: stream_context_set_options() inline array literal — $options arrives null (ext/standard/streams.c) #10056

Description

@PurHur

Category

stdlib · php-src-strict · compile/lowering

Problem

stream_context_set_options($ctx, ['http' => ['timeout' => 1]]) fatals: Argument #2 ($options) must be of type array, null given.

Passing the same array via a variable works. Inline array literals are not lowered to the second argument.

Related umbrella: #3448 — this is the concrete inline-literal repro.

php-src reference

Repro

test/repro-maintainer/parity_stream_context_set_options_inline.php

<?php
declare(strict_types=1);
$ctx = stream_context_create();
stream_context_set_options($ctx, ['http' => ['timeout' => 1]]);
$got = stream_context_get_options($ctx);
echo 'timeout=', ($got['http']['timeout'] ?? 'missing'), PHP_EOL;
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro-maintainer/parity_stream_context_set_options_inline.php'
Form Zend (8.4+) VM today
Inline array literal 2nd arg OK TypeError: … null given ❌
Variable holding array OK OK ✅

Implementation hints (PHP-in-PHP)

  • Likely named-arg / call lowering bug for internal builtins — check compile path for stream_context_set_options in lib/Compiler.php and ext/standard/stream_context_set_options.php.
  • Runtime merge logic already in ext/standard/VmStreamContext.php — fix argument materialization, not C.

Done when

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions