Skip to content

Commit 59128c9

Browse files
committed
PHPStan fixes
1 parent a538162 commit 59128c9

File tree

4 files changed

+29
-8
lines changed

4 files changed

+29
-8
lines changed

src/Comment_Command.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function __construct() {
6464
* $ wp comment create --comment_post_ID=15 --comment_content="hello blog" --comment_author="wp-cli"
6565
* Success: Created comment 932.
6666
*/
67-
public function create( $args, $assoc_args ) {
67+
public function create( $args, array $assoc_args ) {
6868
$assoc_args = wp_slash( $assoc_args );
6969
parent::_create(
7070
$args,
@@ -111,7 +111,7 @@ function ( $params ) {
111111
* $ wp comment update 123 --comment_author='That Guy'
112112
* Success: Updated comment 123.
113113
*/
114-
public function update( $args, $assoc_args ) {
114+
public function update( $args, array $assoc_args ) {
115115
$assoc_args = wp_slash( $assoc_args );
116116
parent::_update(
117117
$args,

src/Term_Command.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,14 @@ public function list_( $args, $assoc_args ) {
142142
/**
143143
* @var \WP_Term[] $terms
144144
*/
145-
// phpcs:ignore WordPress.WP.DeprecatedParameters.Get_termsParam2Found -- Required for backward compatibility.
146-
$terms = get_terms( $args, $assoc_args );
145+
$terms = get_terms(
146+
array_merge(
147+
$assoc_args,
148+
[
149+
'taxonomy' => $args,
150+
]
151+
)
152+
);
147153
}
148154

149155
$terms = array_map(
@@ -211,7 +217,11 @@ public function create( $args, $assoc_args ) {
211217

212218
$assoc_args = wp_slash( $assoc_args );
213219
$term = wp_slash( $term );
214-
$result = wp_insert_term( $term, $taxonomy, $assoc_args );
220+
221+
/**
222+
* @var string $term
223+
*/
224+
$result = wp_insert_term( $term, $taxonomy, $assoc_args );
215225

216226
if ( is_wp_error( $result ) ) {
217227
WP_CLI::error( $result->get_error_message() );
@@ -643,8 +653,13 @@ public function recount( $args ) {
643653
* @var \WP_Term[] $terms
644654
*/
645655

646-
// phpcs:ignore WordPress.WP.DeprecatedParameters.Get_termsParam2Found -- Required for backward compatibility.
647-
$terms = get_terms( $taxonomy, [ 'hide_empty' => false ] );
656+
$terms = get_terms(
657+
[
658+
'taxonomy' => $taxonomy,
659+
'hide_empty' => false,
660+
]
661+
);
662+
648663
$term_taxonomy_ids = wp_list_pluck( $terms, 'term_taxonomy_id' );
649664

650665
wp_update_term_count( $term_taxonomy_ids, $taxonomy );

src/User_Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ public function create( $args, $assoc_args ) {
554554
* $ wp user update 123 --display_name=Mary --user_pass=marypass
555555
* Success: Updated user 123.
556556
*/
557-
public function update( $args, $assoc_args ) {
557+
public function update( $args, array $assoc_args ) {
558558
if ( isset( $assoc_args['user_login'] ) ) {
559559
WP_CLI::warning( "User logins can't be changed." );
560560
unset( $assoc_args['user_login'] );

src/WP_CLI/CommandWithMeta.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ public function update( $args, $assoc_args ) {
314314

315315
$object_id = $this->check_object_id( $object_id );
316316

317+
/**
318+
* @var array|string $meta_value
319+
*/
317320
$meta_value = sanitize_meta( $meta_key, $meta_value, $this->meta_type );
318321
$old_value = sanitize_meta( $meta_key, $this->get_metadata( $object_id, $meta_key, true ), $this->meta_type );
319322

@@ -454,6 +457,9 @@ function ( $key ) {
454457
WP_CLI::error( $exception->getMessage() );
455458
}
456459

460+
/**
461+
* @var array|string $patched_meta_value
462+
*/
457463
$patched_meta_value = sanitize_meta( $meta_key, $traverser->value(), $this->meta_type );
458464

459465
if ( $patched_meta_value === $old_meta_value ) {

0 commit comments

Comments
 (0)