Pass a Variable to joinWith Dynamic Function?

The code below is trying to limit the join table results to a particular product. It works if I hard-code a number into the condition. I want to pass $taskProductId into the dynamic function, but that is a PHP error (undefined variable). Is there another way to pass in that value?

		$tasks = Task::find()



		                     'taskProducts' => function ($query, $taskProductId) {

			                     $query->where('taskProduct.taskProductId=:taskProductId', [':taskProductId' =>taskProductId]);






                     ->where('task.taskId=:taskId', [':taskId' => $taskId])



Thanks for any leads.