@@ -58,11 +58,14 @@ class Cache_Command extends WP_CLI_Command {
5858 * # Add cache.
5959 * $ wp cache add my_key my_group my_value 300
6060 * Success: Added object 'my_key' in group 'my_value'.
61+ *
62+ * @param array{string, string, string, string} $args Positional arguments.
63+ * @param array<mixed> $assoc_args Associative arguments.
6164 */
6265 public function add ( $ args , $ assoc_args ) {
6366 list ( $ key , $ value , $ group , $ expiration ) = $ args ;
6467
65- if ( ! wp_cache_add ( $ key , $ value , $ group , $ expiration ) ) {
68+ if ( ! wp_cache_add ( $ key , $ value , $ group , ( int ) $ expiration ) ) {
6669 WP_CLI ::error ( "Could not add object ' $ key' in group ' $ group'. Does it already exist? " );
6770 }
6871
@@ -96,10 +99,13 @@ public function add( $args, $assoc_args ) {
9699 * # Decrease cache value.
97100 * $ wp cache decr my_key 2 my_group
98101 * 48
102+ *
103+ * @param array{string, string, string} $args Positional arguments.
104+ * @param array<mixed> $assoc_args Associative arguments.
99105 */
100106 public function decr ( $ args , $ assoc_args ) {
101107 list ( $ key , $ offset , $ group ) = $ args ;
102- $ value = wp_cache_decr ( $ key , $ offset , $ group );
108+ $ value = wp_cache_decr ( $ key , ( int ) $ offset , $ group );
103109
104110 if ( false === $ value ) {
105111 WP_CLI ::error ( 'The value was not decremented. ' );
@@ -129,6 +135,9 @@ public function decr( $args, $assoc_args ) {
129135 * # Delete cache.
130136 * $ wp cache delete my_key my_group
131137 * Success: Object deleted.
138+ *
139+ * @param array{string, string} $args Positional arguments.
140+ * @param array<mixed> $assoc_args Associative arguments.
132141 */
133142 public function delete ( $ args , $ assoc_args ) {
134143 list ( $ key , $ group ) = $ args ;
@@ -157,7 +166,7 @@ public function delete( $args, $assoc_args ) {
157166 * $ wp cache flush
158167 * Success: The cache was flushed.
159168 */
160- public function flush ( $ args , $ assoc_args ) {
169+ public function flush () {
161170 // TODO: Needs fixing in wp-cli/wp-cli
162171 // @phpstan-ignore offsetAccess.nonOffsetAccessible
163172 if ( WP_CLI ::has_config ( 'url ' ) && ! empty ( WP_CLI ::get_config ()['url ' ] ) && is_multisite () ) {
@@ -193,6 +202,9 @@ public function flush( $args, $assoc_args ) {
193202 * # Get cache.
194203 * $ wp cache get my_key my_group
195204 * my_value
205+ *
206+ * @param array{string, string} $args Positional arguments.
207+ * @param array<mixed> $assoc_args Associative arguments.
196208 */
197209 public function get ( $ args , $ assoc_args ) {
198210 list ( $ key , $ group ) = $ args ;
@@ -232,10 +244,13 @@ public function get( $args, $assoc_args ) {
232244 * # Increase cache value.
233245 * $ wp cache incr my_key 2 my_group
234246 * 50
247+ *
248+ * @param array{string, string, string} $args Positional arguments.
249+ * @param array<mixed> $assoc_args Associative arguments.
235250 */
236251 public function incr ( $ args , $ assoc_args ) {
237252 list ( $ key , $ offset , $ group ) = $ args ;
238- $ value = wp_cache_incr ( $ key , $ offset , $ group );
253+ $ value = wp_cache_incr ( $ key , ( int ) $ offset , $ group );
239254
240255 if ( false === $ value ) {
241256 WP_CLI ::error ( 'The value was not incremented. ' );
@@ -274,10 +289,13 @@ public function incr( $args, $assoc_args ) {
274289 * # Replace cache.
275290 * $ wp cache replace my_key new_value my_group
276291 * Success: Replaced object 'my_key' in group 'my_group'.
292+ *
293+ * @param array{string, string, string, string} $args Positional arguments.
294+ * @param array<mixed> $assoc_args Associative arguments.
277295 */
278296 public function replace ( $ args , $ assoc_args ) {
279297 list ( $ key , $ value , $ group , $ expiration ) = $ args ;
280- $ result = wp_cache_replace ( $ key , $ value , $ group , $ expiration );
298+ $ result = wp_cache_replace ( $ key , $ value , $ group , ( int ) $ expiration );
281299
282300 if ( false === $ result ) {
283301 WP_CLI ::error ( "Could not replace object ' $ key' in group ' $ group'. Does it not exist? " );
@@ -316,10 +334,13 @@ public function replace( $args, $assoc_args ) {
316334 * # Set cache.
317335 * $ wp cache set my_key my_value my_group 300
318336 * Success: Set object 'my_key' in group 'my_group'.
337+ *
338+ * @param array{string, string, string, string} $args Positional arguments.
339+ * @param array<mixed> $assoc_args Associative arguments.
319340 */
320341 public function set ( $ args , $ assoc_args ) {
321342 list ( $ key , $ value , $ group , $ expiration ) = $ args ;
322- $ result = wp_cache_set ( $ key , $ value , $ group , $ expiration );
343+ $ result = wp_cache_set ( $ key , $ value , $ group , ( int ) $ expiration );
323344
324345 if ( false === $ result ) {
325346 WP_CLI ::error ( "Could not add object ' $ key' in group ' $ group'. " );
@@ -342,7 +363,7 @@ public function set( $args, $assoc_args ) {
342363 * $ wp cache type
343364 * Default
344365 */
345- public function type ( $ args , $ assoc_args ) {
366+ public function type () {
346367 $ message = WP_CLI \Utils \wp_get_cache_type ();
347368 WP_CLI ::line ( $ message );
348369 }
@@ -366,8 +387,10 @@ public function type( $args, $assoc_args ) {
366387 * if ! wp cache supports non_existing; then
367388 * echo 'non_existing is not supported'
368389 * fi
390+ *
391+ * @param array{string} $args Positional arguments.
369392 */
370- public function supports ( $ args, $ assoc_args ) {
393+ public function supports ( $ args ) {
371394 list ( $ feature ) = $ args ;
372395
373396 if ( ! function_exists ( 'wp_cache_supports ' ) ) {
@@ -397,8 +420,10 @@ public function supports( $args, $assoc_args ) {
397420 * Success: Cache group 'my_group' was flushed.
398421 *
399422 * @subcommand flush-group
423+ *
424+ * @param array{string} $args Positional arguments.
400425 */
401- public function flush_group ( $ args, $ assoc_args ) {
426+ public function flush_group ( $ args ) {
402427 list ( $ group ) = $ args ;
403428
404429 if ( ! function_exists ( 'wp_cache_supports ' ) || ! wp_cache_supports ( 'flush_group ' ) ) {
@@ -437,6 +462,9 @@ public function flush_group( $args, $assoc_args ) {
437462 * - json
438463 * - yaml
439464 * ---
465+ *
466+ * @param array{string, string} $args Positional arguments.
467+ * @param array{group: string, format: string} $assoc_args Associative arguments.
440468 */
441469 public function pluck ( $ args , $ assoc_args ) {
442470 list ( $ key ) = $ args ;
@@ -518,7 +546,8 @@ function ( $key ) {
518546 * - json
519547 * ---
520548 *
521- * @param string[] $args
549+ * @param string[] $args Positional arguments.
550+ * @param array{group: string, expiration: string, format: string} $assoc_args Associative arguments.
522551 */
523552 public function patch ( $ args , $ assoc_args ) {
524553 list ( $ action , $ key ) = $ args ;
0 commit comments