These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | namespace Tavii\SQSJobQueueBundle; |
||
| 3 | |||
| 4 | use Symfony\Component\EventDispatcher\EventDispatcher; |
||
| 5 | use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
||
| 6 | use Tavii\SQSJobQueue\Job\JobInterface; |
||
| 7 | use Tavii\SQSJobQueue\Message\MessageInterface; |
||
| 8 | use Tavii\SQSJobQueue\Queue\QueueInterface; |
||
| 9 | use Tavii\SQSJobQueueBundle\Event\ReceiveQueueEvent; |
||
| 10 | use Tavii\SQSJobQueueBundle\Event\SentQueueEvent; |
||
| 11 | |||
| 12 | class Queue implements QueueInterface |
||
| 13 | { |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var Queue |
||
| 17 | */ |
||
| 18 | private $baseQueue; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var array |
||
| 22 | */ |
||
| 23 | private $kernelOptions; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var EventDispatcher |
||
| 27 | */ |
||
| 28 | private $dispatcher; |
||
| 29 | |||
| 30 | |||
| 31 | /** |
||
| 32 | * Queue constructor. |
||
| 33 | * @param QueueInterface $baseQueue |
||
| 34 | * @param EventDispatcherInterface $dispatcher |
||
| 35 | * @param array $kernelOptions |
||
| 36 | */ |
||
| 37 | public function __construct(QueueInterface $baseQueue, EventDispatcherInterface $dispatcher, array $kernelOptions) |
||
| 38 | { |
||
| 39 | $this->baseQueue = $baseQueue; |
||
|
0 ignored issues
–
show
|
|||
| 40 | $this->kernelOptions = $kernelOptions; |
||
| 41 | $this->dispatcher = $dispatcher; |
||
|
0 ignored issues
–
show
$dispatcher is of type object<Symfony\Component...entDispatcherInterface>, but the property $dispatcher was declared to be of type object<Symfony\Component...atcher\EventDispatcher>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly. Either this assignment is in error or an instanceof check should be added for that assignment. class Alien {}
class Dalek extends Alien {}
class Plot
{
/** @var Dalek */
public $villain;
}
$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
$plot->villain = $alien;
}
Loading history...
|
|||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * {@inheritdoc} |
||
| 46 | */ |
||
| 47 | public function receive($name) |
||
| 48 | { |
||
| 49 | $message = $this->baseQueue->receive($name); |
||
| 50 | if ($message instanceof MessageInterface) { |
||
| 51 | $job = $message->getJob(); |
||
| 52 | if ($job instanceof ContainerAwareJob) { |
||
| 53 | $job->setKernelOptions($this->kernelOptions); |
||
| 54 | } |
||
| 55 | $this->dispatcher->dispatch(SQSJobQueueEvents::QUEUE_RECEIVED, new ReceiveQueueEvent($message)); |
||
| 56 | return $message; |
||
| 57 | } |
||
| 58 | return null; |
||
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * {@inheritdoc} |
||
| 63 | */ |
||
| 64 | public function send(JobInterface $job) |
||
| 65 | { |
||
| 66 | if ($job instanceof ContainerAwareJob) { |
||
| 67 | $job->setKernelOptions($this->kernelOptions); |
||
| 68 | } |
||
| 69 | $result = $this->baseQueue->send($job); |
||
| 70 | $this->dispatcher->dispatch(SQSJobQueueEvents::QUEUE_SENT, new SentQueueEvent($job, $result)); |
||
| 71 | return $result; |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * {@inheritdoc} |
||
| 76 | */ |
||
| 77 | public function delete(MessageInterface $message) |
||
| 78 | { |
||
| 79 | $result = false; |
||
| 80 | if ($this->baseQueue->delete($message)) { |
||
| 81 | $job = $message->getJob(); |
||
| 82 | unset($job); |
||
| 83 | $result = true; |
||
| 84 | } |
||
| 85 | return $result; |
||
| 86 | } |
||
| 87 | |||
| 88 | |||
| 89 | } |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.