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
Category
Regression· php-src-strict · excess argc · ext/dateProblem
DateTime/DateTimeImmutablemethods,DateTimeZoneintrospection, andDateInterval::format()silently accept excess arguments on VM (or emit wrong ACE wording). Zend throwsArgumentCountError. Sibling of closed ctor fix #30600.Probed 2026-08-13 — host Zend PHP 8.2.32 vs VM @
fb52e8743e.(new DateTime('2020-01-01'))->format('Y', 'x')ArgumentCountError: … exactly 1 …, 2 given2020(ACCEPTED)->modify('+1 day', 'x')… exactly 1 …, 2 given->setDate(2021,2,3,'x')… exactly 3 …, 4 given->setTime(1,2,3,0,'x')… at most 4 …, 5 givenLogicException: … expects two to four arguments->getTimestamp('x')… exactly 0 …, 1 given->add($interval,'x')/->sub(...)… exactly 1 …, 2 given->diff($other,false,'x')… at most 2 …, 3 given(new DateTimeZone('UTC'))->getName('x')… exactly 0 …, 1 givenUTC->getOffset($dt,'x')/->getLocation('x')(new DateInterval('P1D'))->format('%d','x')… exactly 1 …, 2 given1php-src reference
ext/date/php_date.cext/date/php_date.stub.phpPHP implementation target
lib/VM/Builtin/DateTimeFormat.php,DateTimeModify.php,DateTimeSetDate.php,DateTimeSetTime.php,DateTimeGetTimestamp.php,DateTimeDiff.php, add/sub builtinslib/VM/Builtin/DateTimeZoneGetName.php,DateTimeZoneGetOffset.php,DateTimeZoneGetLocation.phplib/VM/Builtin/DateIntervalFormat.phplib/JIT/Call/DateTime*/DateTimeZone*/DateInterval*call helpers — shared Zend-shaped argc guard (notLogicException)Repro
Done when
ArgumentCountErrorfor probed DateTime/DateTimeZone/DateInterval methods (and fixed-arity siblings)DateTime::setTimeexcess uses ACE notLogicException;diffexcess says at most not at leasttest/repro/+ smallest compliance VM/JIT pair