original_string: public function processNextJob(
          $workQueue,
          callable $callback,
          int $timeout = WorkServerAdapter::DEFAULT_TIMEOUT
      ): void {
          $qe = $this->server->getNextQueueEntry($workQueue, $timeout);
          if (!$qe) {
              $this->onNoJobAvailable((array)$workQueue);
              return;
          }
  
          $job = $qe->getJob();
  
          if ($job->jobIsExpired()) {
              $this->handleExpiredJob($qe);
              return;
          }
  
          $this->log(LogLevel::INFO, "got job", $qe);
          $this->onJobAvailable($qe);
  
          $ret = null;
          try {
              $ret = $callback($job);
          } catch (\Throwable $e) {
              // The job failed.
              $this->handleFailedJob($qe, $e);
  
              if ($this->options[self::WP_RETHROW_EXCEPTIONS]) {
                  // pass exception to caller
                  throw $e;
              } else {
                  // drop it
                  return;
              }
          }
  
          switch ($ret ?? JobResult::DEFAULT) {
              case JobResult::SUCCESS:
                  // The job succeeded!
                  $this->handleFinishedJob($qe);
                  break;
              case JobResult::FAILED:
                  // The job failed.
                  $this->handleFailedJob($qe);
                  break;
              default:
                  // We'll assume the job went well.
                  $this->handleFinishedJob($qe);
                  throw new \UnexpectedValueException('unexpected job handler return value, should be JobResult::... or null or void');
          }
      }
code: public function processNextJob(
          $workQueue,
          callable $callback,
          int $timeout = WorkServerAdapter::DEFAULT_TIMEOUT
      ): void {
          $qe = $this->server->getNextQueueEntry($workQueue, $timeout);
          if (!$qe) {
              $this->onNoJobAvailable((array)$workQueue);
              return;
          }
  
          $job = $qe->getJob();
  
          if ($job->jobIsExpired()) {
              $this->handleExpiredJob($qe);
              return;
          }
  
          $this->log(LogLevel::INFO, "got job", $qe);
          $this->onJobAvailable($qe);
  
          $ret = null;
          try {
              $ret = $callback($job);
          } catch (\Throwable $e) {
              // The job failed.
              $this->handleFailedJob($qe, $e);
  
              if ($this->options[self::WP_RETHROW_EXCEPTIONS]) {
                  // pass exception to caller
                  throw $e;
              } else {
                  // drop it
                  return;
              }
          }
  
          switch ($ret ?? JobResult::DEFAULT) {
              case JobResult::SUCCESS:
                  // The job succeeded!
                  $this->handleFinishedJob($qe);
                  break;
              case JobResult::FAILED:
                  // The job failed.
                  $this->handleFailedJob($qe);
                  break;
              default:
                  // We'll assume the job went well.
                  $this->handleFinishedJob($qe);
                  throw new \UnexpectedValueException('unexpected job handler return value, should be JobResult::... or null or void');
          }
      }
code_tokens: public function processNextJob ( $ workQueue , callable $ callback , int $ timeout = WorkServerAdapter :: DEFAULT_TIMEOUT ) : void { $ qe = $ this -> server -> getNextQueueEntry ( $ workQueue , $ timeout ) ; if ( ! $ qe ) { $ this -> onNoJobAvailable ( ( array ) $ workQueue ) ; return ; } $ job = $ qe -> getJob ( ) ; if ( $ job -> jobIsExpired ( ) ) { $ this -> handleExpiredJob ( $ qe ) ; return ; } $ this -> log ( LogLevel :: INFO , "got job" , $ qe ) ; $ this -> onJobAvailable ( $ qe ) ; $ ret = null ; try { $ ret = $ callback ( $ job ) ; } catch ( \ Throwable $ e ) { // The job failed. $ this -> handleFailedJob ( $ qe , $ e ) ; if ( $ this -> options [ self :: WP_RETHROW_EXCEPTIONS ] ) { // pass exception to caller throw $ e ; } else { // drop it return ; } } switch ( $ ret ?? JobResult :: DEFAULT ) { case JobResult :: SUCCESS : // The job succeeded! $ this -> handleFinishedJob ( $ qe ) ; break ; case JobResult :: FAILED : // The job failed. $ this -> handleFailedJob ( $ qe ) ; break ; default : // We'll assume the job went well. $ this -> handleFinishedJob ( $ qe ) ; throw new \ UnexpectedValueException ( 'unexpected job handler return value, should be JobResult::... or null or void' ) ; } }
docstring: Executes the next job in the Work Queue
  by passing it to the callback function.
  
  If that results in a {@see \RuntimeException},
  the method will try to re-queue the job
  and re-throw the exception.
  
  If the execution results in any other {@see \Throwable},
  no re-queueing will be attempted;
  the job will be buried immediately.
  
  If the next job in the Work Queue is expired,
  it will be silently deleted.
  
  @param string|string[] $workQueue See {@see WorkServerAdapter::getNextJob()}.
  @param callable $callback         The handler callback to execute each Job.
  Expected signature: <tt>function(Job): ?int|void</tt>.
  See {@see JobResult} for possible return values.
  @param int $timeout               See {@see WorkServerAdapter::getNextJob()}.
  @throws \Throwable  Will re-throw on any Exceptions/Throwables from the <tt>$callback</tt>.
  @throws \UnexpectedValueException  in case of an unexpected callback return value (should be a {@see JobResult} constant or NULL or void).
docstring_tokens: Executes the next job in the Work Queue by passing it to the callback function .