#55359 closed defect (bug) (wontfix)
get_option return value wrong
Reported by: | malthert | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Options, Meta APIs | Keywords: | |
Focuses: | docs | Cc: |
Description
https://developer.wordpress.org/reference/functions/get_option/
says it can return scalar including integer, which is false.
get_option can only return:
bool|null|string|array|object
Need to fix in phpdoc and documentation.
Change History (4)
#2
@
3 years ago
- Focuses docs added
This function can return a value of any type because of the $default
parameter:
get_option( 'i_dont_exist', 123 );
The @return
documentation could do with improvement here but the return types look correct.
Note: See
TracTickets for help on using
tickets.
EDIT, it's actually:
bool|string|array|object
Only if $default is set to null (or int/float) then it can return those, in case the option isn't found. However this is misleading in the documentation