1 | <?php |
||
9 | abstract class StallableJobManager extends PriorityJobManager |
||
10 | { |
||
11 | protected $defaultMaxStalls; |
||
12 | |||
13 | abstract protected function stallableSave(StallableJob $job); |
||
14 | |||
15 | 43 | protected function prioritySave(Job $job) |
|
16 | { |
||
17 | 43 | if (!$job instanceof StallableJob) { |
|
18 | throw new \InvalidArgumentException('Job is not instanceof '.StallableJob::class); |
||
19 | } |
||
20 | |||
21 | 43 | if (!$job->getId()) { |
|
22 | 43 | if ($job instanceof StallableJob) { |
|
23 | 43 | $this->setStallableJobDefaults($job); |
|
24 | 43 | } |
|
25 | 43 | } |
|
26 | |||
27 | 43 | return $this->stallableSave($job); |
|
28 | } |
||
29 | |||
30 | /** |
||
31 | * @param StallableJob $job |
||
32 | * @param $retry true if retry |
||
33 | * |
||
34 | * @return bool true if retry |
||
35 | */ |
||
36 | abstract protected function stallableSaveHistory(StallableJob $job, $retry); |
||
37 | |||
38 | /** |
||
39 | * @return bool true if retry |
||
40 | * |
||
41 | * @param Job $job |
||
42 | */ |
||
43 | 8 | protected function retryableSaveHistory(RetryableJob $job, $retry) |
|
44 | { |
||
45 | 8 | if (!$job instanceof StallableJob) { |
|
46 | throw new \InvalidArgumentException('job not instance of '.StallableJob::class); |
||
47 | } |
||
48 | |||
49 | 8 | if ($retry) { |
|
50 | 4 | return $this->stallableSaveHistory($job, $retry); |
|
51 | } |
||
52 | |||
53 | 8 | if (StallableJob::STATUS_STALLED === $job->getStatus()) { |
|
54 | 2 | return $this->stallableSaveHistory($job, $this->updateJobStalled($job)); |
|
55 | } |
||
56 | |||
57 | 6 | return $this->stallableSaveHistory($job, false); |
|
58 | } |
||
59 | |||
60 | /** |
||
61 | * @param StallableJob $job |
||
62 | * |
||
63 | * @return bool false if |
||
64 | */ |
||
65 | 2 | private function updateJobStalled(StallableJob $job) |
|
66 | { |
||
67 | 2 | return $this->updateJobMax($job, 'Stalls', StallableJob::STATUS_MAX_STALLS, true); |
|
68 | } |
||
69 | |||
70 | 43 | protected function setStallableJobDefaults(StallableJob $job) |
|
71 | { |
||
72 | 43 | if (null === $job->getMaxStalls()) { |
|
73 | 43 | $job->setMaxStalls($this->defaultMaxStalls); |
|
74 | 43 | } |
|
75 | 43 | } |
|
76 | |||
77 | /** |
||
78 | * @return int|null |
||
79 | */ |
||
80 | public function getDefaultMaxStalls() |
||
84 | |||
85 | /** |
||
86 | * @param int|null $defaultMaxStalled |
||
|
|||
87 | */ |
||
88 | public function setDefaultMaxStalls($defaultMaxStalls) |
||
92 | } |
||
93 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.