Skip to content

__debugInfo() does nothing on classes extending DateTime #11310

Open
@terrafrost

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions