Skip to content

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
@codecov
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!

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

@petitphp petitphp requested a review from schlessera June 5, 2025 14:30
@swissspidy swissspidy merged commit 283ccb2 into wp-cli:main Nov 2, 2025
43 checks passed
@swissspidy swissspidy added this to the 2.2.1 milestone Nov 2, 2025
@petitphp petitphp deleted the fix/expiration-arg branch November 2, 2025 20:45
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.

3 participants