These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Symbiote\QueuedJobs\Tasks; |
||
4 | |||
5 | use Symbiote\QueuedJobs\Services\AbstractQueuedJob; |
||
6 | use Symbiote\QueuedJobs\Services\QueuedJob; |
||
7 | |||
8 | class DummyQueuedJob extends AbstractQueuedJob implements QueuedJob |
||
9 | { |
||
10 | /** |
||
11 | * @param int $number |
||
12 | */ |
||
13 | public function __construct($number = 0) |
||
14 | { |
||
15 | if ($number) { |
||
16 | $this->startNumber = $number; |
||
17 | $this->totalSteps = $this->startNumber; |
||
18 | } |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * @return string |
||
23 | */ |
||
24 | public function getTitle() |
||
25 | { |
||
26 | return 'Some test job for ' . $this->startNumber . ' seconds'; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @return string |
||
31 | */ |
||
32 | public function getJobType() |
||
33 | { |
||
34 | return QueuedJob::QUEUED; |
||
35 | } |
||
36 | |||
37 | public function setup() |
||
38 | { |
||
39 | // just demonstrating how to get a job going... |
||
40 | $this->totalSteps = $this->startNumber; |
||
41 | $this->times = array(); |
||
42 | } |
||
43 | |||
44 | View Code Duplication | public function process() |
|
45 | { |
||
46 | $times = $this->times; |
||
47 | // needed due to quirks with __set |
||
48 | $times[] = date('Y-m-d H:i:s'); |
||
49 | $this->times = $times; |
||
0 ignored issues
–
show
|
|||
50 | |||
51 | $this->addMessage('Updated time to ' . date('Y-m-d H:i:s')); |
||
52 | sleep(1); |
||
53 | |||
54 | // make sure we're incrementing |
||
55 | $this->currentStep++; |
||
56 | |||
57 | // if ($this->currentStep > 1) { |
||
58 | // $this->currentStep = 1; |
||
59 | // } |
||
60 | |||
61 | // and checking whether we're complete |
||
62 | if ($this->currentStep >= $this->totalSteps) { |
||
63 | $this->isComplete = true; |
||
64 | } |
||
65 | } |
||
66 | } |
||
67 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.