Skip to content

Regression: DateTime/DateTimeZone/DateInterval methods excess argc silently accepted — Zend ArgumentCountError (ext/date/php_date.c) #30834

Description

@PurHur

Category

Regression · php-src-strict · excess argc · ext/date

Problem

DateTime / DateTimeImmutable methods, DateTimeZone introspection, and DateInterval::format() silently accept excess arguments on VM (or emit wrong ACE wording). Zend throws ArgumentCountError. Sibling of closed ctor fix #30600.

Probed 2026-08-13 — host Zend PHP 8.2.32 vs VM @ fb52e8743e.

Repro Zend 8.2.32 VM
(new DateTime('2020-01-01'))->format('Y', 'x') ArgumentCountError: … exactly 1 …, 2 given 2020 (ACCEPTED)
->modify('+1 day', 'x') … exactly 1 …, 2 given applies modify (ACCEPTED)
->setDate(2021,2,3,'x') … exactly 3 …, 4 given ACCEPTED
->setTime(1,2,3,0,'x') … at most 4 …, 5 given LogicException: … expects two to four arguments
->getTimestamp('x') … exactly 0 …, 1 given returns int (ACCEPTED)
->add($interval,'x') / ->sub(...) … exactly 1 …, 2 given ACCEPTED
->diff($other,false,'x') … at most 2 …, 3 given ACE says at least 1
(new DateTimeZone('UTC'))->getName('x') … exactly 0 …, 1 given UTC
->getOffset($dt,'x') / ->getLocation('x') ACE ACCEPTED
(new DateInterval('P1D'))->format('%d','x') … exactly 1 …, 2 given 1

php-src reference

PHP implementation target

  • lib/VM/Builtin/DateTimeFormat.php, DateTimeModify.php, DateTimeSetDate.php, DateTimeSetTime.php, DateTimeGetTimestamp.php, DateTimeDiff.php, add/sub builtins
  • lib/VM/Builtin/DateTimeZoneGetName.php, DateTimeZoneGetOffset.php, DateTimeZoneGetLocation.php
  • lib/VM/Builtin/DateIntervalFormat.php
  • Matching lib/JIT/Call/DateTime* / DateTimeZone* / DateInterval* call helpers — shared Zend-shaped argc guard (not LogicException)

Repro

./script/docker-exec.sh -- bash -lc 'php -r '\''=new DateTime("2020-01-01"); try { echo ->format("Y","x"),"\n"; } catch (Throwable ) { echo get_class(),": ",->getMessage(),"\n"; }'\'''
./script/docker-exec.sh -- bash -lc 'php bin/vm.php -r '\''=new DateTime("2020-01-01"); try { echo ->format("Y","x"),"\n"; } catch (Throwable ) { echo get_class(),": ",->getMessage(),"\n"; }'\'''

Done when

  • VM (+ JIT when wired): excess argc → Zend-shaped ArgumentCountError for probed DateTime/DateTimeZone/DateInterval methods (and fixed-arity siblings)
  • DateTime::setTime excess uses ACE not LogicException; diff excess says at most not at least
  • Repro under test/repro/ + smallest compliance VM/JIT pair
  • php-src-strict; no php-compiler-strict shortcut

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 machinebugSomething isn't workingimplementation-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