Skip to content

Stdlib: DateTime / DateTimeImmutable OOP (ext/date parity) #3072

Description

@PurHur

Category

stdlib

Status (2026-06-07 audit)

Partial landing. DateTime / DateTimeZone classes exist on the VM (class_exists('DateTime') → true), but OOP method dispatch is broken or stubbed for common paths. Procedural date() / gmdate() remain in ext/standard/date.php.

Do not re-implement the whole ext/date module in one PR — claim a child slice below.

Gap Issue
->format() / method dispatch (Method call on non-object) #5120
JIT/AOT method lowering (phase 2) #4043
DateTimeInterface + ATOM constant #7141
__construct() malformed string / exception parity #7113, #7162 (enum operand TypeError)
modify() enum modifier TypeError #6132
Static factories (createFromFormat, createFromTimestamp, …) #4659, #5973, #5936, #6518, #6197
getLastErrors() #4660
PHP 8.4 getMicrosecond() / setMicrosecond() #7082
Procedural date_add / date_diff / … #4604
Delete host \DateTime delegation #6164 (php-in-php)
Exception hierarchy #7276–#7279, #7129

Problem

Zend apps use DateTime / DateTimeImmutable / DateTimeZone for parsing, formatting, and time zones. This compiler registers class names but instance methods fail on typical scripts — blocking sessions, logging, and future self-host vendor code.

php-src reference

Repro (failure today — probed 2026-06-07)

<?php
$dt = new DateTime('2026-05-29', new DateTimeZone('UTC'));
echo $dt->format('Y-m-d');
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php -r "\$dt = new DateTime(\"2026-05-29\", new DateTimeZone(\"UTC\")); echo \$dt->format(\"Y-m-d\");"
php bin/vm.php -r "\$dt = new DateTime(\"2026-05-29\", new DateTimeZone(\"UTC\")); echo \$dt->format(\"Y-m-d\");"
'
Runtime Result
Zend PHP 8.2 2026-05-29
bin/vm.php Method call on non-object (or similar fatal on ->format())

Scope (this repo — PHP-in-PHP first)

Area Path
VM builtins ext/date/ or ext/standard/VmDate*.php — real handlers, not host new \DateTime long-term (#6164)
Class registry lib/VM/BuiltinClasses.php, lib/VM.php
Compiler new DateTime as builtin/user class
JIT/AOT #4043 — phase 1 VM-only methods acceptable for v1
Matrix script/capability-matrix.php — syntax row already notes VM-only (capabilities-syntax.md)

Done when (umbrella — close when children green)

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && ./script/ci-fast.sh --filter DateTime'

Links

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:compilerCompiler / CFG / JITarea: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