#58612 closed enhancement (invalid)
Invalid return type "void" for get_post_custom_keys
Reported by: | kesselb | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 6.3 |
Component: | General | Keywords: | has-patch |
Focuses: | Cc: |
Description
Source
<?php function test() { return; } var_dump(test());
Output
NULL
Change History (4)
This ticket was mentioned in PR #4683 on WordPress/wordpress-develop by kesselb.
19 months ago
#1
- Keywords has-patch added
#2
@
19 months ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
Thanks for the report @kesselb. In PHP, void is a special return type which indicates that the function returns nothing. It's not a real type, therefore it gets coerced to null
as in your example, but void
is the correct type here.
Cheers!
@johnbillion commented on PR #4683:
19 months ago
#3
Closing as per the ticket.
19 months ago
#4
Would you accept the change if I change return; to return null; as you suggest in https://github.com/szepeviktor/phpstan-wordpress/issues/176#issuecomment-1507376826?
Note: See
TracTickets for help on using
tickets.
Trac ticket: https://core.trac.wordpress.org/ticket/58612