Implements GetResult expiryTime must be compatible with ?DateTimeImmutable

hi, i have little bit misunderstanding

In docs Documentation
return DateTimeInterface

In source php-couchbase/result.c at master · couchbase/php-couchbase · GitHub
return DateTimeImmutable

when create implements GetResult

e.g. based on phpstorm-stubs/couchbase.php at master · JetBrains/phpstorm-stubs · GitHub

$result = (new class implements GetResult {
    public function content(): ?array {
        return null;

    public function expiryTime(): ?DateTimeInterface {
        return null;

    public function cas(): ?string
        return null;

catch the error "must be compatible with Couchbase\GetResult::expiryTime(): ?DateTimeImmutable"

and if replace with ?DateTimeImmutable

public function expiryTime(): ?DateTimeImmutable {
    return null;

all done

i create fix request to phpstorm-stubs fix: must be compatible with GetResult::expiryTime(): ?DateTimeImmutable by real420og · Pull Request #1085 · JetBrains/phpstorm-stubs · GitHub
but maybe i’m missing some details

please give some kind of feedback

But isn’t DateTimeImmutable implements DateTimeInterface?

nevermind, I’ve got it. release 3.1.2 will get it fixed.

1 Like