Skip to content

Commit 6617538

Browse files
authored
Merge pull request #553 from wp-cli/fix/phpstan
2 parents 5a05e4c + a8548f3 commit 6617538

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

src/Comment_Command.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ public function __construct() {
6363
* # Create comment.
6464
* $ wp comment create --comment_post_ID=15 --comment_content="hello blog" --comment_author="wp-cli"
6565
* Success: Created comment 932.
66+
*
67+
* @param string[] $args Positional arguments. Unused.
68+
* @param array<string, mixed> $assoc_args Associative arguments.
6669
*/
6770
public function create( $args, $assoc_args ) {
6871
$assoc_args = wp_slash( $assoc_args );
@@ -110,6 +113,9 @@ function ( $params ) {
110113
* # Update comment.
111114
* $ wp comment update 123 --comment_author='That Guy'
112115
* Success: Updated comment 123.
116+
*
117+
* @param string[] $args Positional arguments. Comment IDs to update.
118+
* @param array<string, mixed> $assoc_args Associative arguments.
113119
*/
114120
public function update( $args, $assoc_args ) {
115121
$assoc_args = wp_slash( $assoc_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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,9 @@ public function create( $args, $assoc_args ) {
553553
* # Update user
554554
* $ wp user update 123 --display_name=Mary --user_pass=marypass
555555
* Success: Updated user 123.
556+
*
557+
* @param string[] $args Positional arguments. Users to update.
558+
* @param array $assoc_args Associative arguments.
556559
*/
557560
public function update( $args, $assoc_args ) {
558561
if ( isset( $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)