Skip to content

Reject parse_str() one-argument form in all scopes (#4050) - #7873

Merged
PurHur merged 1 commit into
masterfrom
agent/runtime-php-parse-str-4050
Jun 10, 2026
Merged

Reject parse_str() one-argument form in all scopes (#4050)#7873
PurHur merged 1 commit into
masterfrom
agent/runtime-php-parse-str-4050

Conversation

@PurHur

@PurHur PurHur commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • parse_str() now requires exactly two arguments on VM and JIT, matching PHP 8+ / php-src ext/standard/basic_functions.c
  • Removed the {main} one-arg import path (VmScope::requireMainScriptForParseStrOneArg, JitParseStr::parseIntoScope call site)
  • Updated compliance PHPTs; dropped AOT one-arg fixture (native emitArgumentCountError still segfaults — VM/JIT compliance covers arity)

Closes #4050

php-src reference

ext/standard/basic_functions.cPHP_FUNCTION(parse_str) arity check (PHP 8+)

PHP implementation

  • ext/standard/parse_str.php — VM + JIT lowering
  • ext/standard/VmScope.php — deleted main-script one-arg exception

C runtime shrink

No new C; removed VM scope helper for legacy one-arg import (52 lines net deleted across PHP paths).

Verification

# Issue repro
./script/docker-exec.sh -- bash -lc 'php bin/vm.php -r "try { parse_str(\"x=1\"); } catch (ArgumentCountError \$e) { echo \$e->getMessage(); }"'
# parse_str() expects exactly 2 arguments, 1 given

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro-maintainer/parse_str_function_scope.php'
# parse_str() expects exactly 2 arguments, 1 given

# Targeted tests (15/15 OK)
./script/docker-exec.sh -- bash -lc 'cd /compiler && vendor/bin/phpunit --filter parse_str'
# OK (15 tests, 23 assertions)

Made with Cursor

PHP 8+ requires two arguments; remove the {main}-only import path and VmScope main-script exception so VM and JIT match Zend ArgumentCountError messages.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 8a4e676 into master Jun 10, 2026
@PurHur
PurHur deleted the agent/runtime-php-parse-str-4050 branch June 10, 2026 11:56
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.

Stdlib: parse_str() — reject one-argument form in all scopes (PHP 8+ ext/standard/basic_functions.c)

1 participant