Skip to content

Stdlib: DateTimeInterface built-in interface missing — ATOM constant fetch + instanceof broken (ext/date/php_date.h) #7141

Description

@PurHur

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

Repro (failure today)

<?php
var_dump(interface_exists('DateTimeInterface'));
var_dump((new DateTime()) instanceof DateTimeInterface);
echo DateTimeInterface::ATOM, "\n";

function accepts(DateTimeInterface $dt): void {}
accepts(new DateTime());
./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)

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

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 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