1 | <?php |
||
17 | class RunCommand extends ContainerAwareCommand |
||
18 | { |
||
19 | protected $loggerPrivate = false; |
||
20 | protected $nanoSleepOption = null; |
||
21 | |||
22 | 1 | protected function symfonyDetect() |
|
23 | { |
||
24 | 1 | $this->nanoSleepOption = null; |
|
25 | 1 | if (class_exists('Symfony\Component\HttpKernel\Kernel')) { |
|
26 | 1 | if (Kernel::VERSION_ID >= 30000) { |
|
27 | 1 | $this->nanoSleepOption = 's'; |
|
28 | 1 | } |
|
29 | 1 | if (Kernel::VERSION_ID >= 30400) { |
|
30 | 1 | $this->loggerPrivate = true; |
|
31 | 1 | } |
|
32 | 1 | } |
|
33 | 1 | } |
|
34 | |||
35 | 1 | protected function configure() |
|
36 | { |
||
37 | 1 | $this->symfonyDetect(); |
|
38 | $options = array( |
||
39 | 1 | new InputArgument('worker-name', InputArgument::OPTIONAL, 'Name of worker', null), |
|
40 | 1 | new InputArgument('method', InputArgument::OPTIONAL, 'DI method of worker', null), |
|
41 | 1 | new InputOption( |
|
42 | 1 | 'id', |
|
43 | 1 | 'i', |
|
44 | 1 | InputOption::VALUE_REQUIRED, |
|
45 | 1 | 'Id of Job to run', |
|
46 | null |
||
47 | 1 | ), |
|
48 | 1 | new InputOption( |
|
49 | 1 | 'max-count', |
|
50 | 1 | 'm', |
|
51 | 1 | InputOption::VALUE_REQUIRED, |
|
52 | 1 | 'Maximum number of jobs to work on before exiting', |
|
53 | null |
||
54 | 1 | ), |
|
55 | 1 | new InputOption( |
|
56 | 1 | 'duration', |
|
57 | 1 | 'd', |
|
58 | 1 | InputOption::VALUE_REQUIRED, |
|
59 | 1 | 'Duration to run for in seconds', |
|
60 | null |
||
61 | 1 | ), |
|
62 | 1 | new InputOption( |
|
63 | 1 | 'timeout', |
|
64 | 1 | 't', |
|
65 | 1 | InputOption::VALUE_REQUIRED, |
|
66 | 1 | 'Process timeout in seconds (hard exit of process regardless)', |
|
67 | 3600 |
||
68 | 1 | ), |
|
69 | 1 | new InputOption( |
|
70 | 1 | 'nano-sleep', |
|
71 | 1 | $this->nanoSleepOption, |
|
72 | 1 | InputOption::VALUE_REQUIRED, |
|
73 | 1 | 'If using duration, this is the time to sleep when there\'s no jobs in nanoseconds', |
|
74 | 500000000 |
||
75 | 1 | ), |
|
76 | 1 | new InputOption( |
|
77 | 1 | 'disable-gc', |
|
78 | 1 | null, |
|
79 | 1 | InputOption::VALUE_NONE, |
|
80 | 'Disable garbage collection' |
||
81 | 1 | ), |
|
82 | 1 | ); |
|
83 | |||
84 | // Symfony 4 and Symfony 3.4 out-of-the-box makes the logger private |
||
85 | 1 | if (!$this->loggerPrivate) { |
|
86 | $options[] = |
||
87 | new InputOption( |
||
88 | 'logger', |
||
89 | 'l', |
||
90 | InputOption::VALUE_REQUIRED, |
||
91 | 'Log using the logger service specified, or output to console if null (or an invalid logger service id) is passed in' |
||
92 | ); |
||
93 | } |
||
94 | |||
95 | 1 | $this |
|
96 | 1 | ->setName('dtc:queue:run') |
|
97 | 1 | ->setDefinition($options) |
|
98 | 1 | ->setDescription('Start up a job in queue'); |
|
99 | 1 | } |
|
100 | |||
101 | 1 | protected function execute(InputInterface $input, OutputInterface $output) |
|
134 | |||
135 | /** |
||
136 | * @param bool $disableGc |
||
137 | */ |
||
138 | 1 | protected function setGc($disableGc) |
|
139 | { |
||
140 | 1 | if ($disableGc) { |
|
141 | if (gc_enabled()) { |
||
142 | gc_disable(); |
||
143 | } |
||
144 | |||
145 | return; |
||
146 | } |
||
147 | |||
148 | 1 | if (!gc_enabled()) { |
|
149 | gc_enable(); |
||
150 | } |
||
151 | 1 | } |
|
152 | |||
153 | 1 | protected function setLoggerService(Loop $loop, $loggerService) |
|
170 | } |
||
171 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.