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] Fixed isEmpty implementation #32300

Merged
merged 1 commit into from
Apr 9, 2020
Merged

[7.x] Fixed isEmpty implementation #32300

merged 1 commit into from
Apr 9, 2020

Conversation

GrahamCampbell
Copy link
Member

Do we really want '0' to be treated as an empty html string?

I don't even understand why isEmpty was added. Why not just compare its value with the empty string. In particular, this method is not present on the htmlable contract, so cannot usually be safely called anyway...

I'd actually vote for just entirely removing this method.

@GrahamCampbell
Copy link
Member Author

Should we actually remove this method?

$v->toHtml() === '' is clearer than $v->isEmpty() IMO.

@taylorotwell taylorotwell merged commit 5dfba14 into 7.x Apr 9, 2020
@driesvints driesvints deleted the is-empty-fix branch April 9, 2020 14:31
@vlakoff
Copy link
Contributor

vlakoff commented Apr 19, 2020

Note it broke consistency with Stringable::isEmpty, which still has the "wrong behaviour".

'0' definitely shouldn't be considered to be an empty string.

But doing the change in Stringable::isEmpty would be a BC break. Though, as it's a recent class (and the "correct behaviour" is probably what the users would expect), maybe it's still time for just doing the change. I don't think it's a change of behaviour, but really a bugfix.

@mvdnbrk
Copy link
Contributor

mvdnbrk commented Apr 19, 2020

@vlakoff submitted #32447 to fix the behaviour of the isEmpty method in the Stringable class.

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.

5 participants