Opened 9 years ago
Closed 8 years ago
#30989 closed task (blessed) (fixed)
Additional audit for recent documentation changes
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.6 | Priority: | normal |
Severity: | normal | Version: | 4.1 |
Component: | General | Keywords: | dev-feedback |
Focuses: | docs | Cc: |
Description (last modified by )
Some of the documentation changes in #30224 need an additional audit for consistency:
- [30673] added
null
as a possible@return
value forset_user_setting()
anddelete_user_setting()
, but it's not explained in the comment when it can be returned. - [30674] removed
int
as a possible@return
value forget_the_time()
,get_post_time()
, andget_post_modified_time()
, but they all depend onmysql2date()
and can return an integer if'U'
or'G'
is passed. [30682] addedint
back, but only forget_post_time()
. - [30678] added
string
as a possible@return
value forWP_Filesystem_SSH2::chown()
, but it's not explained in the comment when it can be returned. - There are probably more, these are just the ones that stood out to me.
Attachments (1)
Change History (19)
This ticket was mentioned in Slack in #core by drew. View the logs.
9 years ago
#5
@
8 years ago
- Milestone changed from Future Release to 4.4
- Owner set to DrewAPicture
- Status changed from new to accepted
- Type changed from defect (bug) to task (blessed)
I'm working on this.
#6
in reply to:
↑ 1
@
8 years ago
Replying to SergeyBiryukov:
If a function returns a string on success and false on failure, does it make a difference if
string
comes first in the@return
value? I thoughtstring|bool
is preferred, but was confused by some of the changes in [30674].
The first type in the list should always be the expected type, followed by any outliers. Beyond a certain number (usually 3 or 4) we just mixed
then explain all possibles in the description.
So a common pattern in core is something like * @return int|WP_Error Description.
. int
is the expected type, WP_Error
is the outlier.
Looks like some of the recent changes attempted to clarify
bool
and changed it tofalse
.
Should we standardize on
string|false
in that case?
I think so, yes, because I assume string
is the expected type.
#14
follow-up:
↓ 16
@
8 years ago
Have asked @dd32 if he could please give feedback on 30989.diff which attempts return descriptions for WP_Filesystem_SSH2::chown()
and WP_Filesystem_SSH2::run_command()
.
#16
in reply to:
↑ 14
;
follow-up:
↓ 17
@
8 years ago
Replying to DrewAPicture:
Have asked @dd32 if he could please give feedback on 30989.diff which attempts return descriptions for
WP_Filesystem_SSH2::chown()
andWP_Filesystem_SSH2::run_command()
.
Seems sane. I'm not sure when chown()
returns a a string though, I doubt it'd return anything on a success, it'd more likely be a failure.. but I can't test it.
#17
in reply to:
↑ 16
@
8 years ago
Replying to dd32:
Replying to DrewAPicture:
Have asked @dd32 if he could please give feedback on 30989.diff which attempts return descriptions for
WP_Filesystem_SSH2::chown()
andWP_Filesystem_SSH2::run_command()
.
Seems sane. I'm not sure when
chown()
returns a a string though, I doubt it'd return anything on a success, it'd more likely be a failure.. but I can't test it.
You're correct. In re-reading the source for ->chown()
, the second parameter, $returnbool
is always specified as true. Thus, ->run_command()
can only return a boolean. On the other hand, ->run_command()
could return a string in the case where $returnbool
was false
and the stream_get_contents()
call returned something (was successful).
I'll fix it on commit.
If a function returns a string on success and false on failure, does it make a difference if
string
comes first in the@return
value? I thoughtstring|bool
is preferred, but was confused by some of the changes in [30674].Looks like some of the recent changes attempted to clarify
bool
and changed it tofalse
.Should we standardize on
string|false
in that case?