Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[7.x] Add default value to HtmlString constructor #32290

Merged
merged 1 commit into from
Apr 8, 2020

Conversation

mvdnbrk
Copy link
Contributor

@mvdnbrk mvdnbrk commented Apr 8, 2020

This PR adds a default value to the Illuminate\Support\HtmlString constructor.

new HtmlString;

// vs

new HtmlString('');

Example use case:

public function getContent(): HtmlString
{
    if (empty($this->attribute) {
        return new HtmlString;
        // vs
        return new HtmlString('');
    }

    return new HtmlString($this->attribute);
}

@taylorotwell taylorotwell merged commit 3e07f46 into laravel:7.x Apr 8, 2020
@mvdnbrk
Copy link
Contributor Author

mvdnbrk commented Apr 8, 2020

@taylorotwell Thank you!

@mvdnbrk mvdnbrk deleted the htmlstring-default-value branch April 8, 2020 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants