Skip to content

DateTimeImmutable objects cannot be used as arguments for DateTime faker functions like e.g. dateTimeBetween #947

@AndreasA

Description

@AndreasA

Summary

DateTime generators do not support passing a DateTimeImmutable object.

I know about the issue #512

However, I also noticed that one cannot pass a DateTimeImmutable object to e.g. dateTimeBetween.

This should be quite an easy fix without breaking changes.

It should be enough to change https://github.com/FakerPHP/Faker/blob/v1.24.1/src/Faker/Core/DateTime.php#L39 to check for DateTimeInterface and the rest should work as it is.

Same still applies to the 2.0 branch.

Versions

Version
PHP 8.4
fakerphp/faker 1.24.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions