Skip to content

Stdlib: parse_str() — third-argument prefix (ext/standard/basic_functions.c parity) #4219

Description

@PurHur

Category

stdlib

Problem

Zend parse_str($encoded, &$result, $prefix) accepts an optional third argument that prefixes array keys parsed from the query string. This compiler only allows one or two arguments and throws LogicException on three-arg calls.

php-src reference

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php -r "\$a=[]; parse_str(\"k=v\", \$a, \"pre_\"); var_export(\$a); echo PHP_EOL;"
php bin/vm.php -r "\$a=[]; parse_str(\"k=v\", \$a, \"pre_\"); var_export(\$a); echo PHP_EOL;"
'
Runtime Result
Zend array('pre_k' => 'v')
VM LogicException: parse_str() requires one or two arguments in this compiler build

Scope

Area Files
VM ext/standard/parse_str.php, VmParseStr.php
JIT __compiler_parse_str / JitParseStr if present
Tests test/compliance/cases/stdlib/parse_str_prefix.phpt

Complements #4050 (reject deprecated one-arg form).

Done when

  • Three-arg form populates prefixed keys like Zend
  • Empty prefix string behavior matches Zend
  • ./script/ci-fast.sh --filter parse_str_prefix green

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:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions