Skip to content

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

petitphp
Copy link
Contributor

  • Remove extra spaces in cache patch PHPDoc annotation
  • Specify default value for expiration argument in transient patch PHPDoc annotation

- Remove extra spaces in `cache patch` PHPDoc annotation
- Specify default value for `expiration` argument in `transient patch` PHPDoc annotation
@petitphp petitphp requested a review from a team as a code owner May 14, 2025 21:13
Copy link

codecov bot commented May 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@@ -505,7 +508,7 @@ function ( $key ) {
*/
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' );
Copy link
Member

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:

  1. be explicit with the default value (as it will otherwise default to null)
  2. cast to the expected type (int) to ensure we don't see unexpected changes later in the code

Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants