Skip to content

__debugInfo() does nothing on classes extending DateTime #11310

Closed

Description

@terrafrost

Description

The following code:

<?php

class Demo extends DateTime
{
    public function __debugInfo(): array
    {
        return ['value' => 'zzz'];
    }
}

$d = new Demo();
var_dump($d);

Resulted in this output:

object(Demo)#1 (3) {
  ["date"]=>
  string(26) "2023-05-24 15:59:35.014710"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(16) "Europe/Amsterdam"
}

But I expected this output instead:

object(Demo)#1 (1) {
  ["value"]=>
  string(3) "zzz"
}

PHP Version

PHP 8.2.6

Operating System

Windows 11

Activity

  1. derickr commented on Jul 9, 2026

    @derickr
    Member
  2. added a commit that references this issue on Jul 10, 2026
    8b1079a
  3. added a commit that references this issue on Jul 10, 2026
    b2011f2
  4. added a commit that references this issue on Jul 10, 2026
    e4dbda9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions