Skip to content

Stdlib: DatePeriod::createFromISO8601() — PHP 8.4 ISO8601 period factory missing (ext/date/php_date.c) #7296

@PurHur

Description

@PurHur

Category

stdlib | php-src-strict | PHP 8.4

Problem

PHP 8.4 adds DatePeriod::createFromISO8601(string $spec): DatePeriod — a static factory parsing ISO8601 recurring intervals (e.g. 2024-01-01T00:00:00/2024-01-03T00:00:00/P1D).

This compiler has no DatePeriod class (#3633) and therefore no factory. Scheduling utilities and Symfony-style date code expect the method once base OOP lands.

php-src reference

Dependency graph

Prerequisite Issue
DatePeriod OOP + iteration #3633 (or fold into this issue if unclaimed)
DateInterval parsing #3162
Invalid spec exceptions #7129 (DateMalformedPeriodException)

Claim strategy: If #3633 is open, implement DatePeriod + factory together; otherwise implement factory stub that fatals until class exists.

Repro (failure today)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "var_export(method_exists(DatePeriod::class, \"createFromISO8601\")); echo PHP_EOL;"
'
# bool(false) — class missing

Minimal script once DatePeriod exists:

<?php
$p = DatePeriod::createFromISO8601('2024-01-01T00:00:00/2024-01-03T00:00:00/P1D');
foreach ($p as $d) { echo $d->format('Y-m-d'), "\n"; break; }

Expected: prints 2024-01-01

Invalid spec (pairs #7129):

DatePeriod::createFromISO8601('not-an-interval');
// DateMalformedPeriodException

Scope (PHP-in-PHP)

Done when

  • Valid repro prints first period date 2024-01-01
  • Malformed spec throws DateMalformedPeriodException (not generic Exception)
  • Compliance .phpt under test/compliance/cases/stdlib/date_period_create_from_iso8601.phpt
  • Capability matrix regenerated (script/capability-matrix.php)

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php vendor/bin/phpunit --filter date_period_create_from_iso8601
'

Labels

stdlib · implementation-ready · blocks web/calendar examples using ISO8601 periods

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