|
1
|
|
|
<?php namespace Comodojo\Extender\Tasks; |
|
2
|
|
|
|
|
3
|
|
|
use \Comodojo\Extender\Components\Parameters; |
|
4
|
|
|
use \Comodojo\Dispatcher\Components\DataAccess as DataAccessTrait; |
|
5
|
|
|
use \Psr\Log\LoggerInterface; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Task object |
|
9
|
|
|
* |
|
10
|
|
|
* @package Comodojo extender |
|
11
|
|
|
* @author Marco Giovinazzi <[email protected]> |
|
12
|
|
|
* @license GPL-3.0+ |
|
13
|
|
|
* |
|
14
|
|
|
* LICENSE: |
|
15
|
|
|
* |
|
16
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
17
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
18
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
19
|
|
|
* License, or (at your option) any later version. |
|
20
|
|
|
* |
|
21
|
|
|
* This program is distributed in the hope that it will be useful, |
|
22
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
23
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
24
|
|
|
* GNU Affero General Public License for more details. |
|
25
|
|
|
* |
|
26
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
27
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
28
|
|
|
*/ |
|
29
|
|
|
|
|
30
|
|
|
abstract class AbstractTask implements TaskInterface { |
|
31
|
|
|
|
|
32
|
|
|
use DataAccessTrait; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Task constructor. |
|
36
|
|
|
* |
|
37
|
|
|
* @param array $parameters Array of parameters (if any) |
|
38
|
|
|
* @param \Monolog\Logger $logger |
|
39
|
|
|
* @param int $pid Task PID (if any) |
|
|
|
|
|
|
40
|
|
|
* @param string $name Task Name |
|
41
|
|
|
* @param int $timestamp Start timestamp (if null will be retrieved directly) |
|
|
|
|
|
|
42
|
|
|
* @param bool $multithread Multithread switch |
|
|
|
|
|
|
43
|
|
|
* |
|
44
|
|
|
* @return Object $this |
|
|
|
|
|
|
45
|
|
|
*/ |
|
46
|
|
|
final public function __construct( |
|
47
|
|
|
LoggerInterface $logger, |
|
48
|
|
|
$name = 'EXTENDERTASK', |
|
49
|
|
|
$parameters = array() |
|
50
|
|
|
) { |
|
51
|
|
|
|
|
52
|
|
|
// Setup task |
|
53
|
|
|
$this->logger = $logger; |
|
|
|
|
|
|
54
|
|
|
$this->name = $name; |
|
|
|
|
|
|
55
|
|
|
$this->pid = getmypid(); |
|
|
|
|
|
|
56
|
|
|
$this->parameters = new Parameters($parameters); |
|
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* The run method; SHOULD be implemented by each task |
|
62
|
|
|
*/ |
|
63
|
|
|
abstract public function run(); |
|
64
|
|
|
|
|
65
|
|
|
} |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.