Update TaskLists::add_task() to reflect changes in TaskList::add_task() (#36104)

* Update TaskLists::add_task() to reflect changes in TaskList::add_task()

In
8ff08ea0c9 (diff-061f664bd417ad78d47c53ad5e6cc7e2eb1243af4e55b6fbf68750225acb06a3R173)
`TaskList::add_task()` was refactored to receive an instance of `Task`
instead of an `array` as its first parameter.

This commit updates `TaskLists::add_task()` (easy to miss that it is a
different method as the only difference is the plural in the class
name) to reflect the changes from the commit mentioned above. It
updates the type of the second parameter from `array` to `Task` and
renames the parameter from `$args` to `$task`.

I found this while using `TaskLists::add_task()` to add a MailPoet task
as our PHPStan checks complained that I was passing the wrong parameter
to this WooCommerce method.

* Add missing changelog file
This commit is contained in:
Rodrigo Primo 2023-01-10 13:13:49 -03:00 committed by GitHub
parent 4927a2e412
commit 1d234b5ac0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Update TaskLists::add_task() to reflect changes in TaskList::add_task()

View File

@ -288,10 +288,11 @@ class TaskLists {
* Add task to a given task list.
*
* @param string $list_id List ID to add the task to.
* @param array $args Task properties.
* @param Task $task Task object.
*
* @return \WP_Error|Task
*/
public static function add_task( $list_id, $args ) {
public static function add_task( $list_id, $task ) {
if ( ! isset( self::$lists[ $list_id ] ) ) {
return new \WP_Error(
'woocommerce_task_list_invalid_list',
@ -299,7 +300,7 @@ class TaskLists {
);
}
self::$lists[ $list_id ]->add_task( $args );
self::$lists[ $list_id ]->add_task( $task );
}
/**