## Category `stdlib` (ext/date OOP) ## Problem Zend registers **`DateTimeInterface`** as a built-in interface implemented by `DateTime` and `DateTimeImmutable`. This compiler does not register the interface: - `interface_exists('DateTimeInterface')` → **false** - `DateTimeInterface::ATOM` → compile error: *Unknown class for constant fetch* - `(new DateTime()) instanceof DateTimeInterface` → **false** - Parameters typed `DateTimeInterface` reject `DateTime` instances (TypeError / null) `DateTime::ATOM` works because the class exists; interface-level constants and polymorphic typing do not. ## php-src reference - [php/php-src `ext/date/php_date.h`](https://github.com/php/php-src/blob/master/ext/date/php_date.h) — `php_date_get_interface_ce()`, `DateTimeInterface` registration - [php/php-src `ext/date/php_date.c`](https://github.com/php/php-src/blob/master/ext/date/php_date.c) — `register_date_interface()`, format constants (`ATOM`, `RFC3339`, …) - [php/php-src `ext/date/php_datetime.c`](https://github.com/php/php-src/blob/master/ext/date/php_datetime.c) — `DateTime` / `DateTimeImmutable` implement interface ## Repro (failure today) ```php <?php var_dump(interface_exists('DateTimeInterface')); var_dump((new DateTime()) instanceof DateTimeInterface); echo DateTimeInterface::ATOM, "\n"; function accepts(DateTimeInterface $dt): void {} accepts(new DateTime()); ``` ```bash ./script/docker-exec.sh -- bash -lc 'php bin/vm.php repro.php 2>&1 | head -10' ./script/docker-exec.sh -- bash -lc 'php repro.php 2>&1' ``` | Check | Zend PHP 8.2 | This compiler | |-------|--------------|---------------| | `interface_exists('DateTimeInterface')` | true | false | | `(new DateTime()) instanceof DateTimeInterface` | true | false | | `DateTimeInterface::ATOM` | `Y-m-d\TH:i:sP` | compile error | | `accepts(new DateTime())` | ok | TypeError | ## Implementation (PHP-in-PHP) - Register **`DateTimeInterface`** in **`ext/date/`** (or existing date module bootstrap) with format constants mirroring php-src. - Wire `DateTime` / `DateTimeImmutable` (when present, see #3162) to implement the interface in the class registry — no new C runtime logic. - VM type checks / `instanceof` / constant fetch must resolve the interface like other built-ins. ## Done when - [ ] `interface_exists('DateTimeInterface')` true; constants `ATOM`, `RFC3339`, `W3C`, etc. match php-src values. - [ ] `DateTime` and `DateTimeImmutable` instances satisfy `instanceof DateTimeInterface`. - [ ] Parameters/properties typed `DateTimeInterface` accept `DateTime` objects. - [ ] Compliance `.phpt` under `test/compliance/cases/stdlib/`; VM green (JIT/AOT if date types are lowered there). ## Related - #3162 (DateTimeImmutable / DateInterval OOP) - #5936 (`createFromInterface()` factories — depends on interface registration) - #6354 (other Zend built-in interfaces)
Category
stdlib(ext/date OOP)Problem
Zend registers
DateTimeInterfaceas a built-in interface implemented byDateTimeandDateTimeImmutable. This compiler does not register the interface:interface_exists('DateTimeInterface')→ falseDateTimeInterface::ATOM→ compile error: Unknown class for constant fetch(new DateTime()) instanceof DateTimeInterface→ falseDateTimeInterfacerejectDateTimeinstances (TypeError / null)DateTime::ATOMworks because the class exists; interface-level constants and polymorphic typing do not.php-src reference
ext/date/php_date.h—php_date_get_interface_ce(),DateTimeInterfaceregistrationext/date/php_date.c—register_date_interface(), format constants (ATOM,RFC3339, …)ext/date/php_datetime.c—DateTime/DateTimeImmutableimplement interfaceRepro (failure today)
interface_exists('DateTimeInterface')(new DateTime()) instanceof DateTimeInterfaceDateTimeInterface::ATOMY-m-d\TH:i:sPaccepts(new DateTime())Implementation (PHP-in-PHP)
DateTimeInterfaceinext/date/(or existing date module bootstrap) with format constants mirroring php-src.DateTime/DateTimeImmutable(when present, see Stdlib: DateTimeImmutable / DateInterval — ext/date OOP phase 2 (#3072 follow-up) #3162) to implement the interface in the class registry — no new C runtime logic.instanceof/ constant fetch must resolve the interface like other built-ins.Done when
interface_exists('DateTimeInterface')true; constantsATOM,RFC3339,W3C, etc. match php-src values.DateTimeandDateTimeImmutableinstances satisfyinstanceof DateTimeInterface.DateTimeInterfaceacceptDateTimeobjects..phptundertest/compliance/cases/stdlib/; VM green (JIT/AOT if date types are lowered there).Related
createFromInterface()factories — depends on interface registration)