Skip to content

Commit 5684cbc

Browse files
committed
Add full docblocks to methods
1 parent 182b183 commit 5684cbc

File tree

5 files changed

+260
-108
lines changed

5 files changed

+260
-108
lines changed

src/Comment_Meta_Command.php

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,47 +25,79 @@ class Comment_Meta_Command extends \WP_CLI\CommandWithMeta {
2525
protected $meta_type = 'comment';
2626

2727
/**
28-
* @param $object_id
29-
* @param $meta_key
30-
* @param $meta_value
31-
* @param bool $unique
28+
* Wrapper method for add_metadata that can be overridden in sub classes.
3229
*
33-
* @return mixed
30+
* @param int $object_id ID of the object the metadata is for.
31+
* @param string $meta_key Metadata key to use.
32+
* @param mixed $meta_value Metadata value. Must be serializable if
33+
* non-scalar.
34+
* @param bool $unique Optional, default is false. Whether the
35+
* specified metadata key should be unique for the
36+
* object. If true, and the object already has a
37+
* value for the specified metadata key, no change
38+
* will be made.
39+
*
40+
* @return int|false The meta ID on success, false on failure.
3441
*/
3542
protected function add_metadata( $object_id, $meta_key, $meta_value, $unique = false ) {
3643
return add_comment_meta( $object_id, $meta_key, $meta_value, $unique );
3744
}
3845

3946
/**
40-
* @param $object_id
41-
* @param $meta_key
42-
* @param $meta_value
43-
* @param string $prev_value
47+
* Wrapper method for update_metadata that can be overridden in sub classes.
48+
*
49+
* @param int $object_id ID of the object the metadata is for.
50+
* @param string $meta_key Metadata key to use.
51+
* @param mixed $meta_value Metadata value. Must be serializable if
52+
* non-scalar.
53+
* @param mixed $prev_value Optional. If specified, only update existing
54+
* metadata entries with the specified value.
55+
* Otherwise, update all entries.
4456
*
45-
* @return mixed
57+
* @return int|bool Meta ID if the key didn't exist, true on successful
58+
* update, false on failure.
4659
*/
4760
protected function update_metadata( $object_id, $meta_key, $meta_value, $prev_value = '' ) {
4861
return update_comment_meta( $object_id, $meta_key, $meta_value, $prev_value );
4962
}
5063

5164
/**
52-
* @param $object_id
53-
* @param string $meta_key
54-
* @param bool $single
65+
* Wrapper method for get_metadata that can be overridden in sub classes.
5566
*
56-
* @return mixed
67+
* @param int $object_id ID of the object the metadata is for.
68+
* @param string $meta_key Optional. Metadata key. If not specified,
69+
* retrieve all metadata for the specified object.
70+
* @param bool $single Optional, default is false. If true, return only
71+
* the first value of the specified meta_key. This
72+
* parameter has no effect if meta_key is not
73+
* specified.
74+
*
75+
* @return mixed Single metadata value, or array of values.
5776
*/
5877
protected function get_metadata( $object_id, $meta_key = '', $single = false ) {
5978
return get_comment_meta( $object_id, $meta_key, $single );
6079
}
6180

6281
/**
63-
* @param $object_id
64-
* @param $meta_key
65-
* @param string $meta_value
66-
* @param bool $delete_all
82+
* Wrapper method for delete_metadata that can be overridden in sub classes.
83+
*
84+
* @param int $object_id ID of the object metadata is for
85+
* @param string $meta_key Metadata key
86+
* @param mixed $meta_value Optional. Metadata value. Must be serializable
87+
* if non-scalar. If specified, only delete
88+
* metadata entries with this value. Otherwise,
89+
* delete all entries with the specified meta_key.
90+
* Pass `null, `false`, or an empty string to skip
91+
* this check. For backward compatibility, it is
92+
* not possible to pass an empty string to delete
93+
* those entries with an empty string for a value.
94+
* @param bool $delete_all Optional, default is false. If true, delete
95+
* matching metadata entries for all objects,
96+
* ignoring the specified object_id. Otherwise,
97+
* only delete matching metadata entries for the
98+
* specified object_id.
6799
*
68-
* @return mixed
100+
* @return bool True on successful delete, false on failure.
69101
*/
70102
protected function delete_metadata( $object_id, $meta_key, $meta_value = '', $delete_all = false ) {
71103
return delete_comment_meta( $object_id, $meta_key, $meta_value, $delete_all );

src/Post_Meta_Command.php

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,47 +36,79 @@ protected function check_object_id( $object_id ) {
3636
}
3737

3838
/**
39-
* @param $object_id
40-
* @param $meta_key
41-
* @param $meta_value
42-
* @param bool $unique
39+
* Wrapper method for add_metadata that can be overridden in sub classes.
4340
*
44-
* @return mixed
41+
* @param int $object_id ID of the object the metadata is for.
42+
* @param string $meta_key Metadata key to use.
43+
* @param mixed $meta_value Metadata value. Must be serializable if
44+
* non-scalar.
45+
* @param bool $unique Optional, default is false. Whether the
46+
* specified metadata key should be unique for the
47+
* object. If true, and the object already has a
48+
* value for the specified metadata key, no change
49+
* will be made.
50+
*
51+
* @return int|false The meta ID on success, false on failure.
4552
*/
4653
protected function add_metadata( $object_id, $meta_key, $meta_value, $unique = false ) {
4754
return add_post_meta( $object_id, $meta_key, $meta_value, $unique );
4855
}
4956

5057
/**
51-
* @param $object_id
52-
* @param $meta_key
53-
* @param $meta_value
54-
* @param string $prev_value
58+
* Wrapper method for update_metadata that can be overridden in sub classes.
59+
*
60+
* @param int $object_id ID of the object the metadata is for.
61+
* @param string $meta_key Metadata key to use.
62+
* @param mixed $meta_value Metadata value. Must be serializable if
63+
* non-scalar.
64+
* @param mixed $prev_value Optional. If specified, only update existing
65+
* metadata entries with the specified value.
66+
* Otherwise, update all entries.
5567
*
56-
* @return mixed
68+
* @return int|bool Meta ID if the key didn't exist, true on successful
69+
* update, false on failure.
5770
*/
5871
protected function update_metadata( $object_id, $meta_key, $meta_value, $prev_value = '' ) {
5972
return update_post_meta( $object_id, $meta_key, $meta_value, $prev_value );
6073
}
6174

6275
/**
63-
* @param $object_id
64-
* @param string $meta_key
65-
* @param bool $single
76+
* Wrapper method for get_metadata that can be overridden in sub classes.
6677
*
67-
* @return mixed
78+
* @param int $object_id ID of the object the metadata is for.
79+
* @param string $meta_key Optional. Metadata key. If not specified,
80+
* retrieve all metadata for the specified object.
81+
* @param bool $single Optional, default is false. If true, return only
82+
* the first value of the specified meta_key. This
83+
* parameter has no effect if meta_key is not
84+
* specified.
85+
*
86+
* @return mixed Single metadata value, or array of values.
6887
*/
6988
protected function get_metadata( $object_id, $meta_key = '', $single = false ) {
7089
return get_post_meta( $object_id, $meta_key, $single );
7190
}
7291

7392
/**
74-
* @param $object_id
75-
* @param $meta_key
76-
* @param string $meta_value
77-
* @param bool $delete_all
93+
* Wrapper method for delete_metadata that can be overridden in sub classes.
94+
*
95+
* @param int $object_id ID of the object metadata is for
96+
* @param string $meta_key Metadata key
97+
* @param mixed $meta_value Optional. Metadata value. Must be serializable
98+
* if non-scalar. If specified, only delete
99+
* metadata entries with this value. Otherwise,
100+
* delete all entries with the specified meta_key.
101+
* Pass `null, `false`, or an empty string to skip
102+
* this check. For backward compatibility, it is
103+
* not possible to pass an empty string to delete
104+
* those entries with an empty string for a value.
105+
* @param bool $delete_all Optional, default is false. If true, delete
106+
* matching metadata entries for all objects,
107+
* ignoring the specified object_id. Otherwise,
108+
* only delete matching metadata entries for the
109+
* specified object_id.
78110
*
79-
* @return mixed
111+
* @return bool True on successful delete, false on failure.
80112
*/
81113
protected function delete_metadata( $object_id, $meta_key, $meta_value = '', $delete_all = false ) {
82114
return delete_post_meta( $object_id, $meta_key, $meta_value, $delete_all );

src/Term_Meta_Command.php

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,47 +38,79 @@ protected function check_object_id( $object_id ) {
3838
}
3939

4040
/**
41-
* @param $object_id
42-
* @param $meta_key
43-
* @param $meta_value
44-
* @param bool $unique
41+
* Wrapper method for add_metadata that can be overridden in sub classes.
4542
*
46-
* @return mixed
43+
* @param int $object_id ID of the object the metadata is for.
44+
* @param string $meta_key Metadata key to use.
45+
* @param mixed $meta_value Metadata value. Must be serializable if
46+
* non-scalar.
47+
* @param bool $unique Optional, default is false. Whether the
48+
* specified metadata key should be unique for the
49+
* object. If true, and the object already has a
50+
* value for the specified metadata key, no change
51+
* will be made.
52+
*
53+
* @return int|false The meta ID on success, false on failure.
4754
*/
4855
protected function add_metadata( $object_id, $meta_key, $meta_value, $unique = false ) {
4956
return add_term_meta( $object_id, $meta_key, $meta_value, $unique );
5057
}
5158

5259
/**
53-
* @param $object_id
54-
* @param $meta_key
55-
* @param $meta_value
56-
* @param string $prev_value
60+
* Wrapper method for update_metadata that can be overridden in sub classes.
61+
*
62+
* @param int $object_id ID of the object the metadata is for.
63+
* @param string $meta_key Metadata key to use.
64+
* @param mixed $meta_value Metadata value. Must be serializable if
65+
* non-scalar.
66+
* @param mixed $prev_value Optional. If specified, only update existing
67+
* metadata entries with the specified value.
68+
* Otherwise, update all entries.
5769
*
58-
* @return mixed
70+
* @return int|bool Meta ID if the key didn't exist, true on successful
71+
* update, false on failure.
5972
*/
6073
protected function update_metadata( $object_id, $meta_key, $meta_value, $prev_value = '' ) {
6174
return update_term_meta( $object_id, $meta_key, $meta_value, $prev_value );
6275
}
6376

6477
/**
65-
* @param $object_id
66-
* @param string $meta_key
67-
* @param bool $single
78+
* Wrapper method for get_metadata that can be overridden in sub classes.
6879
*
69-
* @return mixed
80+
* @param int $object_id ID of the object the metadata is for.
81+
* @param string $meta_key Optional. Metadata key. If not specified,
82+
* retrieve all metadata for the specified object.
83+
* @param bool $single Optional, default is false. If true, return only
84+
* the first value of the specified meta_key. This
85+
* parameter has no effect if meta_key is not
86+
* specified.
87+
*
88+
* @return mixed Single metadata value, or array of values.
7089
*/
7190
protected function get_metadata( $object_id, $meta_key = '', $single = false ) {
7291
return get_term_meta( $object_id, $meta_key, $single );
7392
}
7493

7594
/**
76-
* @param $object_id
77-
* @param $meta_key
78-
* @param string $meta_value
79-
* @param bool $delete_all
95+
* Wrapper method for delete_metadata that can be overridden in sub classes.
96+
*
97+
* @param int $object_id ID of the object metadata is for
98+
* @param string $meta_key Metadata key
99+
* @param mixed $meta_value Optional. Metadata value. Must be serializable
100+
* if non-scalar. If specified, only delete
101+
* metadata entries with this value. Otherwise,
102+
* delete all entries with the specified meta_key.
103+
* Pass `null, `false`, or an empty string to skip
104+
* this check. For backward compatibility, it is
105+
* not possible to pass an empty string to delete
106+
* those entries with an empty string for a value.
107+
* @param bool $delete_all Optional, default is false. If true, delete
108+
* matching metadata entries for all objects,
109+
* ignoring the specified object_id. Otherwise,
110+
* only delete matching metadata entries for the
111+
* specified object_id.
80112
*
81-
* @return mixed
113+
* @return bool True on successful delete, false on failure.
82114
*/
83115
protected function delete_metadata( $object_id, $meta_key, $meta_value = '', $delete_all = false ) {
84116
return delete_term_meta( $object_id, $meta_key, $meta_value, $delete_all );

src/User_Meta_Command.php

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -227,47 +227,79 @@ public function update( $args, $assoc_args ) {
227227
}
228228

229229
/**
230-
* @param $object_id
231-
* @param $meta_key
232-
* @param $meta_value
233-
* @param bool $unique
234-
*
235-
* @return mixed
230+
* Wrapper method for add_metadata that can be overridden in sub classes.
231+
*
232+
* @param int $object_id ID of the object the metadata is for.
233+
* @param string $meta_key Metadata key to use.
234+
* @param mixed $meta_value Metadata value. Must be serializable if
235+
* non-scalar.
236+
* @param bool $unique Optional, default is false. Whether the
237+
* specified metadata key should be unique for the
238+
* object. If true, and the object already has a
239+
* value for the specified metadata key, no change
240+
* will be made.
241+
*
242+
* @return int|false The meta ID on success, false on failure.
236243
*/
237244
protected function add_metadata( $object_id, $meta_key, $meta_value, $unique = false ) {
238245
return add_user_meta( $object_id, $meta_key, $meta_value, $unique );
239246
}
240247

241248
/**
242-
* @param $object_id
243-
* @param $meta_key
244-
* @param $meta_value
245-
* @param string $prev_value
246-
*
247-
* @return mixed
249+
* Wrapper method for update_metadata that can be overridden in sub classes.
250+
*
251+
* @param int $object_id ID of the object the metadata is for.
252+
* @param string $meta_key Metadata key to use.
253+
* @param mixed $meta_value Metadata value. Must be serializable if
254+
* non-scalar.
255+
* @param mixed $prev_value Optional. If specified, only update existing
256+
* metadata entries with the specified value.
257+
* Otherwise, update all entries.
258+
*
259+
* @return int|bool Meta ID if the key didn't exist, true on successful
260+
* update, false on failure.
248261
*/
249262
protected function update_metadata( $object_id, $meta_key, $meta_value, $prev_value = '' ) {
250263
return update_user_meta( $object_id, $meta_key, $meta_value, $prev_value );
251264
}
252265

253266
/**
254-
* @param $object_id
255-
* @param string $meta_key
256-
* @param bool $single
267+
* Wrapper method for get_metadata that can be overridden in sub classes.
257268
*
258-
* @return mixed
269+
* @param int $object_id ID of the object the metadata is for.
270+
* @param string $meta_key Optional. Metadata key. If not specified,
271+
* retrieve all metadata for the specified object.
272+
* @param bool $single Optional, default is false. If true, return only
273+
* the first value of the specified meta_key. This
274+
* parameter has no effect if meta_key is not
275+
* specified.
276+
*
277+
* @return mixed Single metadata value, or array of values.
259278
*/
260279
protected function get_metadata( $object_id, $meta_key = '', $single = false ) {
261280
return get_user_meta( $object_id, $meta_key, $single );
262281
}
263282

264283
/**
265-
* @param $object_id
266-
* @param $meta_key
267-
* @param string $meta_value
268-
* @param bool $delete_all
269-
*
270-
* @return mixed
284+
* Wrapper method for delete_metadata that can be overridden in sub classes.
285+
*
286+
* @param int $object_id ID of the object metadata is for
287+
* @param string $meta_key Metadata key
288+
* @param mixed $meta_value Optional. Metadata value. Must be serializable
289+
* if non-scalar. If specified, only delete
290+
* metadata entries with this value. Otherwise,
291+
* delete all entries with the specified meta_key.
292+
* Pass `null, `false`, or an empty string to skip
293+
* this check. For backward compatibility, it is
294+
* not possible to pass an empty string to delete
295+
* those entries with an empty string for a value.
296+
* @param bool $delete_all Optional, default is false. If true, delete
297+
* matching metadata entries for all objects,
298+
* ignoring the specified object_id. Otherwise,
299+
* only delete matching metadata entries for the
300+
* specified object_id.
301+
*
302+
* @return bool True on successful delete, false on failure.
271303
*/
272304
protected function delete_metadata( $object_id, $meta_key, $meta_value = '', $delete_all = false ) {
273305
return delete_user_meta( $object_id, $meta_key, $meta_value, $delete_all );

0 commit comments

Comments
 (0)