[wp-trac] [WordPress Trac] #35346: WP_Term breaks type-hints for stdClass
WordPress Trac
noreply at wordpress.org
Thu Jan 7 10:01:52 UTC 2016
#35346: WP_Term breaks type-hints for stdClass
--------------------------+-----------------------------
Reporter: exz | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: 4.4.1
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Since 4.4.0 instances of `WP_Term` is returned from various function calls
in WordPress core. Before the return value(s) were instances of
`stdClass`. #14162
This makes code that type-hints `stdClass` not work with 4.4.0+, if you
for instance have a callback for `array_map()` that expects a `stdClass`
you will get:
`Argument 1 passed to {closure}() must be an instance of stdClass,
instance of WP_Term given`
This would be easily fixed by just making `WP_Term` extend `stdClass` like
this:
`final class WP_Term extends stdClass { }`
I haven't tested if this breaks something else, but would you consider
this change, or is it up to the plugin/theme developer to change all code
that expects a `stdClass` to be able to support 4.4.0+?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35346>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list