Skip to content

Fix GH-11310: __debugInfo does nothing on userland classes extending Date classes - #22655

Merged
derickr merged 2 commits into
php:PHP-8.4from
derickr:gh11310-debug-info
Jul 10, 2026
Merged

derickr merged 2 commits into
php:PHP-8.4from
derickr:gh11310-debug-info

Conversation

@derickr

@derickr derickr commented Jul 9, 2026

Copy link
Copy Markdown
Member

The fix for DateTime also works for DateTimeImmutable, but DateTimeZone needed a separate fix.

I have also ran tests with valgrind locally, to make sure there are no memory issues.

Related to: #16317

Bug GH-11310: __debugInfo does nothing on userland classes extending Date classes
--FILE--
<?php
class UDateTime extends DateTime { public function __debugInfo(): array { return ['value' => 'zzz']; } }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also add cases where the parent constructor is not called, to ensure that the parent constructor isn't doing any initialization that is required for the overrides to work?

and at least one case of calling parent::__debugInfo() and confirming that the parent info still shows up

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried adding a test with calling parent::_debugInfo(), but none of the classes have a __debugInfo() method, so that would just be testing calling an undefined method.

I've added tests for when the ctor of the original classes isn't called.

@DanielEScherzer DanielEScherzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me

@derickr
derickr merged commit 8b1079a into php:PHP-8.4 Jul 10, 2026
18 checks passed
derickr added a commit that referenced this pull request Jul 10, 2026
* PHP-8.5:
  Fix GH-11310: __debugInfo does nothing on userland classes extending Date classes (#22655)
@derickr
derickr deleted the gh11310-debug-info branch July 10, 2026 12:40
pull Bot pushed a commit to ppker/php-src that referenced this pull request Jul 10, 2026
* PHP-8.4:
  Fix phpGH-11310: __debugInfo does nothing on userland classes extending Date classes (php#22655)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants