Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[6.x] Add missing nullable type declaration for the model timestamp fields #34787

Merged
merged 1 commit into from
Oct 11, 2020
Merged

[6.x] Add missing nullable type declaration for the model timestamp fields #34787

merged 1 commit into from
Oct 11, 2020

Conversation

antonkomarev
Copy link
Contributor

This PR replaces #34785 targeted to 8.x because @GrahamCampbell said to target this changes to 6.x

Eloquent Model constants CREATED_AT & UPDATED_AT are nullable. There are checks for null values, but null is not documented in PHPDoc.

public function updateTimestamps()
{
    $time = $this->freshTimestamp();

    $updatedAtColumn = $this->getUpdatedAtColumn();

    if (! is_null($updatedAtColumn) && ! $this->isDirty($updatedAtColumn)) {
        $this->setUpdatedAt($time);
    }

    $createdAtColumn = $this->getCreatedAtColumn();

    if (! $this->exists && ! is_null($createdAtColumn) && ! $this->isDirty($createdAtColumn)) {
        $this->setCreatedAt($time);
    }
}

@antonkomarev antonkomarev changed the base branch from 8.x to 6.x October 10, 2020 23:49
@taylorotwell taylorotwell merged commit 2bf90d2 into laravel:6.x Oct 11, 2020
@antonkomarev antonkomarev deleted the fix-eloquent-model-timestamp-types branch October 11, 2020 15:16
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants