Skip to content

[7.x] Fixed isEmpty implementation - #32300

Merged
taylorotwell merged 1 commit into
7.xfrom
is-empty-fix
Apr 9, 2020
Merged

[7.x] Fixed isEmpty implementation#32300
taylorotwell merged 1 commit into
7.xfrom
is-empty-fix

Conversation

@GrahamCampbell

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Collaborator 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

vlakoff commented Apr 19, 2020

Copy link
Copy Markdown
Contributor

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

mvdnbrk commented Apr 19, 2020

Copy link
Copy Markdown
Contributor

@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