A job handle is not assigned to a task until the task is received and queued by the Gearman job server.
However, you can use GearmanClient::setCreatedCallback() to get the handle once it has been queued. This must be done before both adding and running the tasks:
$client = new \GearmanClient();
$client->addServer('127.0.0.1');
$handles = array();
$client->setCreatedCallback(function (\GearmanTask $task) use (&$handles) {
$handles[] = $task->jobHandle();
});
$client->addTask('functionName', 'workload'); // ...
$client->runTasks();