[wp-trac] [WordPress Trac] #48565: The `site_url` function doesn't work with objects implemented `__toString`
WordPress Trac
noreply at wordpress.org
Wed Nov 13 20:26:54 UTC 2019
#48565: The `site_url` function doesn't work with objects implemented `__toString`
-------------------------------+------------------------------
Reporter: azeemhassni | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 5.2.4
Severity: trivial | Resolution:
Keywords: needs-patch close | Focuses:
-------------------------------+------------------------------
Changes (by johnbillion):
* keywords: needs-patch dev-feedback 2nd-opinion => needs-patch close
Comment:
This is an interesting one. An object of a class with a `__toString()`
method is not a string, however it will get cast to a string when
necessary (for example if it gets passed to a parameter with a type hint
of `string`, or gets explicitly casted with `(string)`).
Personally I think this is enough of an edge case that this ticket should
be closed off. The additional overhead to handle this case is not worth
it. Just cast it to a string before passing into functions that expect a
string.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48565#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list