-
Notifications
You must be signed in to change notification settings - Fork 24
Update PHPDoc for patch commands
#107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Remove extra spaces in `cache patch` PHPDoc annotation - Specify default value for `expiration` argument in `transient patch` PHPDoc annotation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
src/Transient_Command.php
Outdated
| public function patch( $args, $assoc_args ) { | ||
| list( $action, $key ) = $args; | ||
| $expiration = (int) Utils\get_flag_value( $assoc_args, 'expiration', 0 ); | ||
| $expiration = (int) Utils\get_flag_value( $assoc_args, 'expiration' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you remove the 0 here for consistency with the other commands, but I think this is the only one that is actually correct. For all of the expiration flags, we should:
- be explicit with the default value (as it will otherwise default to
null) - cast to the expected type
(int)to ensure we don't see unexpected changes later in the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1/
Yes it was for consistency, I removed the default value here and set it in the PHPDoc like what was done in the cache command.
During my testing, I saw that the default value from the PHPDoc was automatically used without having to set it in get_flag_value. I thought it was cleaner, and I apply the change here.
I can add the 0 back here and in the cache command if you think it's more explicit ?
2/
I've done that in 4bf6850
cache patchPHPDoc annotationexpirationargument intransient patchPHPDoc annotation