Skip to content

Stdlib: null operand coercion parity batch (#18369–#18378)#18385

Merged
PurHur merged 2 commits into
masterfrom
agent/advanced-stdlib-null-coerce-batch-18369-18378
Jul 12, 2026
Merged

Stdlib: null operand coercion parity batch (#18369–#18378)#18385
PurHur merged 2 commits into
masterfrom
agent/advanced-stdlib-null-coerce-batch-18369-18378

Conversation

@PurHur

@PurHur PurHur commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add InternalStrictArg::resolveCoercibleStringArg() for php-src Z_PARAM_STR parity: null coerces to '' outside declare(strict_types=1), still TypeError under strict call sites.
  • Fix 7 null-coercion gaps across datetime, PCRE, array sort, mktime, touch/unserialize, and scandir/exec/popen paths on VM + JIT lowering.
  • Add compliance .phpt guards + maintainer repro scripts for each issue.

php-src reference

  • ext/standard/datetime.cphp_date, php_gmdate, php_strtotime, php_mktime
  • ext/pcre/php_pcre.c — subject string coercion
  • ext/standard/array.c — sort flags default
  • ext/standard/filestat.c, ext/standard/var.c — touch/unserialize empty input
  • ext/standard/dir.c, ext/standard/exec.c, ext/standard/proc_open.c — empty path/command

PHP implementation

  • lib/VM/InternalStrictArg.php — shared resolveCoercibleStringArg()
  • ext/standard/{strtotime,date,gmdate,preg_match,sort_,rsort_,mktime,gmmktime,touch_,unserialize,scandir,exec,popen}.php + matching JIT helpers

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_strtotime_null.php'
# false

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_mktime_null_coerce.php'
# mktime=int:yes
# gmmktime=int:yes

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_touch_unserialize_null.php'
# touch=false
# unserialize=false

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter "strtotime_null_datetime|preg_match_null_subject|sort_null_flags|mktime_null_coerce|touch_unserialize_null|scandir_exec_null|date_gmdate_arg_parity"'
# 16/17 pass (VM+JIT); AOT date_gmdate_arg_parity pre-existing red on master (compile error exit 2 → segfault exit 139 on this branch — tracked separately)

Closes #18378
Closes #18377
Closes #18376
Closes #18375
Closes #18370
Closes #18369
Closes #18371

Made with Cursor

PurHur and others added 2 commits July 12, 2026 22:16
Add InternalStrictArg::resolveCoercibleStringArg for Z_PARAM_STR parity outside
declare(strict_types=1), fixing strtotime/date/gmdate/preg_match/sort/rsort/mktime/
touch/unserialize/scandir/exec/popen null handling on VM and JIT paths.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur PurHur merged commit 10ac48a into master Jul 12, 2026
1 check failed
@PurHur PurHur deleted the agent/advanced-stdlib-null-coerce-batch-18369-18378 branch July 12, 2026 22:17
PurHur added a commit that referenced this pull request Jul 13, 2026
…rt (#18482) (#18485)

Regression from #18385: flags operand used Variable::TYPE_INTEGER without
importing PHPCompiler\VM\Variable. Restores Zend parity for offset capture.

php-src: ext/pcre/php_pcre.c — PHP_FUNCTION(preg_match)

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment