[php-src] Issue #23543: Fatal error: DateTimeInterface can't be implemented by user classes
| From: | MircoBabin | Date: | Wed, 02 Sep 2026 13:08:38 +0000 |
| Subject: | [php-src] Issue #23543: Fatal error: DateTimeInterface can't be implemented by user classes | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-252695@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/23543
Author: MircoBabin
### Description
The following code:
https://3v4l.org/AVYra#v8.5.9
```php
<?php
// Why is this allowed ?
// This pattern is used by Carbon - https://github.com/briannesbitt/Carbon
class MyDateTimeImmutable extends DateTimeImmutable implements DateTimeInterface
{
public function format(string $format): string
{
return 'Why is this allowed?';
}
}
// And why is this disallowed ?
// Fatal error: DateTimeInterface can't be implemented by user classes
class MyTime implements DateTimeInterface
{
}
```
Resulted in this output:
```
Fatal error: DateTimeInterface can't be implemented by user classes in /in/AVYra on line 14
```
But I expected this output instead:
```
Fatal error: Class MyTime contains ... abstract methods and must therefore be declared abstract or
implement the remaining methods
```
### PHP Version
```plain
PHP 8.5.9
```
### Operating System
https://3v4l.org/