sfcod /
jobqueue
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace SfCod\QueueBundle\Command; |
||
| 4 | |||
| 5 | use Psr\Log\LoggerInterface; |
||
| 6 | use SfCod\QueueBundle\Options; |
||
| 7 | use SfCod\QueueBundle\Worker; |
||
| 8 | use Symfony\Component\Console\Command\Command; |
||
| 9 | use Symfony\Component\Console\Input\InputArgument; |
||
| 10 | use Symfony\Component\Console\Input\InputInterface; |
||
| 11 | use Symfony\Component\Console\Output\OutputInterface; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Command to run jobs by id |
||
| 15 | * |
||
| 16 | * @author Virchenko Maksim <[email protected]> |
||
| 17 | */ |
||
| 18 | class RunJobCommand extends Command |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * @var Worker |
||
| 22 | */ |
||
| 23 | protected $worker; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * RunJobCommand constructor. |
||
| 27 | * |
||
| 28 | * @param LoggerInterface $logger |
||
|
0 ignored issues
–
show
|
|||
| 29 | * @param Worker $worker |
||
| 30 | */ |
||
| 31 | public function __construct(Worker $worker) |
||
| 32 | { |
||
| 33 | $this->worker = $worker; |
||
| 34 | |||
| 35 | parent::__construct(); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Configure command |
||
| 40 | */ |
||
| 41 | protected function configure() |
||
| 42 | { |
||
| 43 | $this->setName('job-queue:run-job') |
||
| 44 | ->setDescription('Runs single job by id.') |
||
| 45 | ->addArgument('id', InputArgument::REQUIRED, 'The id of the job.') |
||
| 46 | ->addOption('connection', null, InputArgument::OPTIONAL, 'The name of the connection.', 'default') |
||
| 47 | ->addOption('queue', null, InputArgument::OPTIONAL, 'The name of the queue.', null) |
||
| 48 | ->addOption('delay', null, InputArgument::OPTIONAL, 'Delay before getting jobs.', 0) |
||
| 49 | ->addOption('memory', null, InputArgument::OPTIONAL, 'Maximum memory usage limit.', 128) |
||
| 50 | ->addOption('sleep', null, InputArgument::OPTIONAL, 'Sleep time before getting new job.', 3) |
||
| 51 | ->addOption('maxTries', null, InputArgument::OPTIONAL, 'Max tries to run job.', 1) |
||
| 52 | ->addOption('timeout', null, InputArgument::OPTIONAL, 'Daemon timeout.', 60); |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Execute command |
||
| 57 | * |
||
| 58 | * @param InputInterface $input |
||
| 59 | * @param OutputInterface $output |
||
| 60 | * |
||
| 61 | * @return int|null|void |
||
| 62 | */ |
||
| 63 | public function execute(InputInterface $input, OutputInterface $output) |
||
| 64 | { |
||
| 65 | $options = new Options( |
||
| 66 | $input->getOption('delay'), |
||
| 67 | $input->getOption('memory'), |
||
| 68 | $input->getOption('timeout'), |
||
| 69 | $input->getOption('sleep'), |
||
| 70 | $input->getOption('maxTries') |
||
| 71 | ); |
||
| 72 | $connection = $input->getOption('connection'); |
||
| 73 | $jobId = $input->getArgument('id'); |
||
| 74 | |||
| 75 | $this->worker->runJobById($connection, $jobId, $options); |
||
| 76 | } |
||
| 77 | } |
||
| 78 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.