You can use this syntax:
<?php
$worker = new GearmanWorker();
$worker->addServer();
$worker->addFunction(new MyClass($test), 'myMethod');
class MyClass
{
public function __construct($test)
{
$this->test = $test;
}
public function myMethod(GearmanJob $job)
{
// you can access to $this->test;
}
}