1 | <?php |
||
16 | class MongoJobContract extends JobContract implements JobContractInterface |
||
17 | { |
||
18 | /** |
||
19 | * Job resolver |
||
20 | * |
||
21 | * @var JobResolverInterface |
||
22 | */ |
||
23 | protected $resolver; |
||
24 | |||
25 | /** |
||
26 | * The database queue instance. |
||
27 | * |
||
28 | * @var QueueInterface |
||
29 | */ |
||
30 | protected $database; |
||
31 | |||
32 | /** |
||
33 | * The database job payload. |
||
34 | * |
||
35 | * @var StdClass |
||
36 | */ |
||
37 | protected $job; |
||
38 | |||
39 | /** |
||
40 | * Create a new job instance. |
||
41 | * |
||
42 | * @param JobResolverInterface $resolver |
||
43 | * @param QueueInterface $database |
||
44 | * @param StdClass|MongoDB\Model\BSONDocument $job |
||
45 | * @param string $queue |
||
46 | */ |
||
47 | public function __construct(JobResolverInterface $resolver, QueueInterface $database, $job, string $queue) |
||
54 | |||
55 | /** |
||
56 | * Delete the job from the queue. |
||
57 | */ |
||
58 | public function delete() |
||
66 | |||
67 | /** |
||
68 | * Get the number of times the job has been attempted. |
||
69 | * |
||
70 | * @return int |
||
71 | */ |
||
72 | public function attempts(): int |
||
76 | |||
77 | /** |
||
78 | * Check if job reserved |
||
79 | * |
||
80 | * @return bool |
||
81 | */ |
||
82 | public function reserved(): bool |
||
86 | |||
87 | /** |
||
88 | * Get reserved at time |
||
89 | * |
||
90 | * @return int |
||
91 | */ |
||
92 | public function reservedAt(): int |
||
96 | |||
97 | /** |
||
98 | * Get the job identifier. |
||
99 | * |
||
100 | * @return string |
||
101 | */ |
||
102 | public function getJobId(): string |
||
106 | |||
107 | /** |
||
108 | * Get the raw body string for the job. |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | public function getRawBody(): string |
||
116 | |||
117 | /** |
||
118 | * Resolve job |
||
119 | * |
||
120 | * @param string $class |
||
121 | * |
||
122 | * @return JobInterface |
||
123 | */ |
||
124 | protected function resolve(string $class): JobInterface |
||
128 | } |
||
129 |
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 mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.