for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace flipbox\queue\jobs\traits;
use craft\helpers\ArrayHelper;
use flipbox\queue\helpers\JobHelper;
use flipbox\queue\jobs\JobInterface;
use yii\base\Exception;
trait CollectionTrait
{
use JobTrait;
/**
* @var JobInterface[]
*/
protected $jobs;
* @param string $class
* @return array
protected function jobConfig(string $class): array
return [
'class' => $class
];
}
* @param array $jobs
* @return static
public function setJobs(array $jobs = [])
$this->jobs = null;
null
array<integer,object<fli...eue\jobs\JobInterface>>
$jobs
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..
return $this->addJobs($jobs);
protected function addJobs(array $jobs = [])
foreach ($jobs as $key => $job) {
if (is_numeric($key) || empty($key)) {
$key = null;
$this->addJob($key, $job);
return $this;
* @param $key
* @param $job
public function addJob($key, $job)
if (is_string($job)) {
$job = $this->jobConfig($job);
if (!$job instanceof JobInterface) {
$job = JobHelper::create($job);
$this->jobs[$key] = $job;
* @return JobInterface[]
public function getJobs()
return $this->jobs;
* @param $identifier
* @return JobInterface
public function findJob($identifier)
return ArrayHelper::getValue($this->jobs, $identifier);
* @throws Exception
public function getJob($identifier)
if (!$job = $this->findJob($identifier)) {
throw new Exception("Job not found.");
return $job;
* @param array $config
public function createJob($identifier, array $config = [])
$config['class'] = $this->getJob($identifier);
return JobHelper::create($config);
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..