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\SQSJobQueue\Queue\QueueName; |
||
10 | use Tavii\SQSJobQueueBundle\Event\ReceiveQueueEvent; |
||
11 | use Tavii\SQSJobQueueBundle\Event\SentQueueEvent; |
||
12 | |||
13 | class Queue implements QueueInterface |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * @var Queue |
||
18 | */ |
||
19 | private $baseQueue; |
||
20 | |||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | private $kernelOptions; |
||
25 | |||
26 | /** |
||
27 | * @var EventDispatcher |
||
28 | */ |
||
29 | private $dispatcher; |
||
30 | |||
31 | |||
32 | /** |
||
33 | * Queue constructor. |
||
34 | * @param QueueInterface $baseQueue |
||
35 | * @param EventDispatcherInterface $dispatcher |
||
36 | * @param array $kernelOptions |
||
37 | */ |
||
38 | public function __construct(QueueInterface $baseQueue, EventDispatcherInterface $dispatcher, array $kernelOptions) |
||
39 | { |
||
40 | $this->baseQueue = $baseQueue; |
||
0 ignored issues
–
show
|
|||
41 | $this->kernelOptions = $kernelOptions; |
||
42 | $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;
}
![]() |
|||
43 | } |
||
44 | |||
45 | /** |
||
46 | * {@inheritdoc} |
||
47 | */ |
||
48 | public function receive(QueueName $queueName) |
||
49 | { |
||
50 | $message = $this->baseQueue->receive($queueName); |
||
51 | if ($message instanceof MessageInterface) { |
||
52 | $job = $message->getJob(); |
||
53 | if ($job instanceof ContainerAwareJob) { |
||
54 | $job->setKernelOptions($this->kernelOptions); |
||
55 | } |
||
56 | $this->dispatcher->dispatch(SQSJobQueueEvents::QUEUE_RECEIVED, new ReceiveQueueEvent($message)); |
||
57 | return $message; |
||
58 | } |
||
59 | return null; |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | */ |
||
65 | public function send(JobInterface $job) |
||
66 | { |
||
67 | if ($job instanceof ContainerAwareJob) { |
||
68 | $job->setKernelOptions($this->kernelOptions); |
||
69 | } |
||
70 | $result = $this->baseQueue->send($job); |
||
71 | $this->dispatcher->dispatch(SQSJobQueueEvents::QUEUE_SENT, new SentQueueEvent($job, $result)); |
||
72 | return $result; |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * {@inheritdoc} |
||
77 | */ |
||
78 | public function delete(MessageInterface $message) |
||
79 | { |
||
80 | $result = false; |
||
81 | if ($this->baseQueue->delete($message)) { |
||
82 | $job = $message->getJob(); |
||
83 | unset($job); |
||
84 | $result = true; |
||
85 | } |
||
86 | return $result; |
||
87 | } |
||
88 | |||
89 | |||
90 | } |
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.