dereuromark / cakephp-queue
Showing 22 of 33 files from the diff.

@@ -17,7 +17,7 @@
Loading
17 17
	use LoadHelperTrait;
18 18
19 19
	/**
20 -
	 * @var array
20 +
	 * @var array<mixed>
21 21
	 */
22 22
	public $paginate = [
23 23
		'order' => [

@@ -19,14 +19,14 @@
Loading
19 19
	use ModelAwareTrait;
20 20
21 21
	/**
22 -
	 * @var array
22 +
	 * @var array<mixed>
23 23
	 */
24 24
	protected $helpers = [
25 25
		'Tools.Progress',
26 26
	];
27 27
28 28
	/**
29 -
	 * @var array|null
29 +
	 * @var array<string, array<int>>|null
30 30
	 */
31 31
	protected $statistics;
32 32
@@ -191,7 +191,7 @@
Loading
191 191
192 192
	/**
193 193
	 * @param string $jobType
194 -
	 * @return array
194 +
	 * @return array<int>
195 195
	 */
196 196
	protected function getJobStatistics(string $jobType): array {
197 197
		$statistics = $this->readStatistics();
@@ -213,7 +213,7 @@
Loading
213 213
	public const CONFIG = 'default';
214 214
215 215
	/**
216 -
	 * @return array
216 +
	 * @return array<string, array<int>>
217 217
	 */
218 218
	protected function readStatistics(): array {
219 219
		if ($this->statistics !== null) {
@@ -232,7 +232,9 @@
Loading
232 232
233 233
		$statistics = [];
234 234
		foreach ((array)$queuedJobStatistics as $statistic) {
235 -
			$statistics[$statistic['job_task']][] = $statistic['runtime'];
235 +
			/** @var string $name */
236 +
			$name = $statistic['job_task'];
237 +
			$statistics[$name][] = $statistic['runtime'];
236 238
		}
237 239
238 240
		$this->statistics = $statistics;

@@ -51,7 +51,7 @@
Loading
51 51
	 * This function is executed, when a worker is executing a task.
52 52
	 * The return parameter will determine, if the task will be marked completed, or be requeued.
53 53
	 *
54 -
	 * @param array $data The array passed to QueuedJobsTable::createJob()
54 +
	 * @param array<string, mixed> $data The array passed to QueuedJobsTable::createJob()
55 55
	 * @param int $jobId The id of the QueuedJob entity
56 56
	 * @return void
57 57
	 */

@@ -65,7 +65,7 @@
Loading
65 65
	public const STATS_LIMIT = 100000;
66 66
67 67
	/**
68 -
	 * @var array
68 +
	 * @var array<string, string>
69 69
	 */
70 70
	public $rateHistory = [];
71 71
@@ -96,7 +96,7 @@
Loading
96 96
	/**
97 97
	 * initialize Table
98 98
	 *
99 -
	 * @param array $config Configuration
99 +
	 * @param array<string, mixed> $config Configuration
100 100
	 * @return void
101 101
	 */
102 102
	public function initialize(array $config): void {
@@ -118,8 +118,8 @@
Loading
118 118
119 119
	/**
120 120
	 * @param \Cake\Event\EventInterface $event
121 -
	 * @param \ArrayObject $data
122 -
	 * @param \ArrayObject $options
121 +
	 * @param \ArrayObject<string, mixed> $data
122 +
	 * @param \ArrayObject<string, mixed> $options
123 123
	 * @return void
124 124
	 */
125 125
	public function beforeMarshal(EventInterface $event, ArrayObject $data, ArrayObject $options) {
@@ -185,8 +185,8 @@
Loading
185 185
	 * - reference: An optional reference string
186 186
	 *
187 187
	 * @param string $jobTask Job task name or FQCN
188 -
	 * @param array|null $data Array of data
189 -
	 * @param array $config Config to save along with the job
188 +
	 * @param array<string, mixed>|null $data Array of data
189 +
	 * @param array<string, mixed> $config Config to save along with the job
190 190
	 * @return \Queue\Model\Entity\QueuedJob Saved job entity
191 191
	 */
192 192
	public function createJob(string $jobTask, ?array $data = null, array $config = []) {
@@ -355,10 +355,10 @@
Loading
355 355
	 *   ]
356 356
	 * ]
357 357
	 *
358 -
	 * @param string|null $jobType
359 -
	 * @return array
358 +
	 * @param string|null $jobTask
359 +
	 * @return array<string, array<string, mixed>>
360 360
	 */
361 -
	public function getFullStats(?string $jobType = null): array {
361 +
	public function getFullStats(?string $jobTask = null): array {
362 362
		$driverName = $this->getDriverName();
363 363
		$fields = function (Query $query) use ($driverName) {
364 364
			$runtime = $query->newExpr('UNIX_TIMESTAMP(completed) - UNIX_TIMESTAMP(fetched)');
@@ -385,8 +385,8 @@
Loading
385 385
		};
386 386
387 387
		$conditions = ['completed IS NOT' => null];
388 -
		if ($jobType) {
389 -
			$conditions['job_task'] = $jobType;
388 +
		if ($jobTask) {
389 +
			$conditions['job_task'] = $jobTask;
390 390
		}
391 391
392 392
		$jobs = $this->find()
@@ -415,28 +415,30 @@
Loading
415 415
				$runtime = (int)round($runtime * DAY);
416 416
			}
417 417
418 -
			$result[$job['job_task']][$day][] = $runtime;
418 +
			/** @var string $name */
419 +
			$name = $job['job_task'];
420 +
			$result[$name][$day][] = $runtime;
419 421
		}
420 422
421 -
		foreach ($result as $jobType => $jobs) {
423 +
		foreach ($result as $jobTask => $jobs) {
422 424
			/**
423 425
			 * @var string $day
424 -
			 * @var array $durations
426 +
			 * @var array<int> $durations
425 427
			 */
426 428
			foreach ($jobs as $day => $durations) {
427 429
				$average = array_sum($durations) / count($durations);
428 -
				$result[$jobType][$day] = (int)$average;
430 +
				$result[$jobTask][$day] = (int)$average;
429 431
			}
430 432
431 433
			foreach ($days as $day) {
432 -
				if (isset($result[$jobType][$day])) {
434 +
				if (isset($result[$jobTask][$day])) {
433 435
					continue;
434 436
				}
435 437
436 -
				$result[$jobType][$day] = 0;
438 +
				$result[$jobTask][$day] = 0;
437 439
			}
438 440
439 -
			ksort($result[$jobType]);
441 +
			ksort($result[$jobTask]);
440 442
		}
441 443
442 444
		return $result;
@@ -446,7 +448,7 @@
Loading
446 448
	 * Look for a new job that can be processed with the current abilities and
447 449
	 * from the specified group (or any if null).
448 450
	 *
449 -
	 * @param array $tasks Available QueueWorkerTasks.
451 +
	 * @param array<string, array<string, mixed>> $tasks Available QueueWorkerTasks.
450 452
	 * @param array<string> $groups Request a job from these groups (or exclude certain groups), or any otherwise.
451 453
	 * @param array<string> $types Request a job from these types (or exclude certain types), or any otherwise.
452 454
	 * @return \Queue\Model\Entity\QueuedJob|null
@@ -820,7 +822,7 @@
Loading
820 822
821 823
	/**
822 824
	 * @param \Queue\Model\Entity\QueuedJob $queuedTask
823 -
	 * @param array $taskConfiguration
825 +
	 * @param array<string, array<string, mixed>> $taskConfiguration
824 826
	 * @return string
825 827
	 */
826 828
	public function getFailedStatus(QueuedJob $queuedTask, array $taskConfiguration): string {
@@ -842,7 +844,7 @@
Loading
842 844
	 * Custom find method, as in `find('queued', ...)`.
843 845
	 *
844 846
	 * @param \Cake\ORM\Query $query The query to find with
845 -
	 * @param array $options The options to find with
847 +
	 * @param array<string, mixed> $options The options to find with
846 848
	 * @return \Cake\ORM\Query The query builder
847 849
	 */
848 850
	public function findQueued(Query $query, array $options) {
@@ -855,7 +857,7 @@
Loading
855 857
	 * @return void
856 858
	 */
857 859
	public function clearDoublettes(): void {
858 -
		/** @var array $x */
860 +
		/** @var array<int> $x */
859 861
		$x = $this->getConnection()->query('SELECT max(id) as id FROM `' . $this->getTable() . '`
860 862
	WHERE completed is NULL
861 863
	GROUP BY data
@@ -927,10 +929,10 @@
Loading
927 929
	}
928 930
929 931
	/**
930 -
	 * @param array $conditions
932 +
	 * @param array<mixed> $conditions
931 933
	 * @param string $key
932 934
	 * @param array<string> $values
933 -
	 * @return array
935 +
	 * @return array<mixed>
934 936
	 */
935 937
	protected function addFilter(array $conditions, string $key, array $values): array {
936 938
		$include = [];

@@ -56,7 +56,7 @@
Loading
56 56
	 *
57 57
	 * Defaults to 120 seconds
58 58
	 *
59 -
	 * @param array $data The array passed to QueuedJobsTable::createJob()
59 +
	 * @param array<string, mixed> $data The array passed to QueuedJobsTable::createJob()
60 60
	 * @param int $jobId The id of the QueuedJob entity
61 61
	 * @return void
62 62
	 */

@@ -196,7 +196,7 @@
Loading
196 196
	}
197 197
198 198
	/**
199 -
	 * @param array|string $default
199 +
	 * @param array<mixed>|string $default
200 200
	 *
201 201
	 * @return \Cake\Http\Response|null
202 202
	 */

@@ -20,7 +20,7 @@
Loading
20 20
	 * Send mail
21 21
	 *
22 22
	 * @param \Cake\Mailer\Message $message
23 -
	 * @return array
23 +
	 * @return array<string, mixed>
24 24
	 */
25 25
	public function send(Message $message): array {
26 26
		if (!empty($this->_config['queue'])) {

@@ -36,7 +36,7 @@
Loading
36 36
	/**
37 37
	 * List of default variables for Email class.
38 38
	 *
39 -
	 * @var array
39 +
	 * @var array<string, mixed>
40 40
	 */
41 41
	protected $defaults = [];
42 42
@@ -94,7 +94,7 @@
Loading
94 94
	}
95 95
96 96
	/**
97 -
	 * @param array $data The array passed to QueuedJobsTable::createJob()
97 +
	 * @param array<string, mixed> $data The array passed to QueuedJobsTable::createJob()
98 98
	 * @param int $jobId The id of the QueuedJob entity
99 99
	 * @throws \Queue\Model\QueueException
100 100
	 * @throws \Throwable

@@ -52,7 +52,7 @@
Loading
52 52
	 * This function is executed, when a worker is executing a task.
53 53
	 * The return parameter will determine, if the task will be marked completed, or be requeued.
54 54
	 *
55 -
	 * @param array $data The array passed to QueuedJobsTable::createJob()
55 +
	 * @param array<string, mixed> $data The array passed to QueuedJobsTable::createJob()
56 56
	 * @param int $jobId The id of the QueuedJob entity
57 57
	 * @throws \Queue\Model\QueueException
58 58
	 * @return void

@@ -50,7 +50,7 @@
Loading
50 50
	 * CostsExample run function.
51 51
	 * This function is executed, when a worker is executing a task.
52 52
	 *
53 -
	 * @param array $data The array passed to QueuedJobsTable::createJob()
53 +
	 * @param array<string, mixed> $data The array passed to QueuedJobsTable::createJob()
54 54
	 * @param int $jobId The id of the QueuedJob entity
55 55
	 * @return void
56 56
	 */

@@ -19,7 +19,7 @@
Loading
19 19
	 * Send mail
20 20
	 *
21 21
	 * @param \Cake\Mailer\Message $message
22 -
	 * @return array
22 +
	 * @return array<string, mixed>
23 23
	 */
24 24
	public function send(Message $message): array {
25 25
		if (!empty($this->_config['queue'])) {

@@ -27,7 +27,7 @@
Loading
27 27
	/**
28 28
	 * Output at the verbose level.
29 29
	 *
30 -
	 * @param array|string $message A string or an array of strings to output
30 +
	 * @param array<string>|string $message A string or an array of strings to output
31 31
	 * @param int $newlines Number of newlines to append
32 32
	 * @return int|null The number of bytes returned from writing to stdout.
33 33
	 */
@@ -38,7 +38,7 @@
Loading
38 38
	/**
39 39
	 * Output at all levels.
40 40
	 *
41 -
	 * @param array|string $message A string or an array of strings to output
41 +
	 * @param array<string>|string $message A string or an array of strings to output
42 42
	 * @param int $newlines Number of newlines to append
43 43
	 * @return int|null The number of bytes returned from writing to stdout.
44 44
	 */
@@ -199,7 +199,7 @@
Loading
199 199
	 * object has not already been loaded, it will be loaded and constructed.
200 200
	 *
201 201
	 * @param string $name The name of the helper to render
202 -
	 * @param array $settings Configuration data for the helper.
202 +
	 * @param array<string, mixed> $settings Configuration data for the helper.
203 203
	 * @return \Cake\Console\Helper The created helper instance.
204 204
	 */
205 205
	public function helper(string $name, array $settings = []): Helper {
@@ -214,7 +214,7 @@
Loading
214 214
	 *
215 215
	 * **Warning** You cannot overwrite text that contains newlines.
216 216
	 *
217 -
	 * @param array|string $message The message to output.
217 +
	 * @param array<string>|string $message The message to output.
218 218
	 * @param int $newlines Number of newlines to append.
219 219
	 * @param int|null $size The number of bytes to overwrite. Defaults to the
220 220
	 *    length of the last message output.

@@ -55,7 +55,7 @@
Loading
55 55
	 * This function is executed, when a worker is executing a task.
56 56
	 * The return parameter will determine, if the task will be marked completed, or be requeued.
57 57
	 *
58 -
	 * @param array $data The array passed to QueuedJobsTable::createJob()
58 +
	 * @param array<string, mixed> $data The array passed to QueuedJobsTable::createJob()
59 59
	 * @param int $jobId The id of the QueuedJob entity
60 60
	 * @return void
61 61
	 */

@@ -66,7 +66,7 @@
Loading
66 66
	 * This function is executed, when a worker is executing a task.
67 67
	 * The return parameter will determine, if the task will be marked completed, or be requeued.
68 68
	 *
69 -
	 * @param array $data The array passed to QueuedJobsTable::createJob()
69 +
	 * @param array<string, mixed> $data The array passed to QueuedJobsTable::createJob()
70 70
	 * @param int $jobId The id of the QueuedJob entity
71 71
	 * @throws \Queue\Model\QueueException
72 72
	 * @return void

@@ -16,7 +16,7 @@
Loading
16 16
	use ModelAwareTrait;
17 17
18 18
	/**
19 -
	 * @var array|null
19 +
	 * @var array<string, mixed>|null
20 20
	 */
21 21
	protected $taskConfig;
22 22
@@ -90,7 +90,7 @@
Loading
90 90
	/**
91 91
	 * @param string $jobTask
92 92
	 *
93 -
	 * @return array
93 +
	 * @return array<string, mixed>
94 94
	 */
95 95
	protected function taskConfig(string $jobTask): array {
96 96
		if (!$this->taskConfig) {

@@ -56,7 +56,7 @@
Loading
56 56
	 * This function is executed, when a worker is executing a task.
57 57
	 * The return parameter will determine, if the task will be marked completed, or be requeued.
58 58
	 *
59 -
	 * @param array $data The array passed to QueuedJobsTable::createJob()
59 +
	 * @param array<string, mixed> $data The array passed to QueuedJobsTable::createJob()
60 60
	 * @param int $jobId The id of the QueuedJob entity
61 61
	 * @return void
62 62
	 */

@@ -68,7 +68,7 @@
Loading
68 68
	 * @param array<string> $tasks
69 69
	 *
70 70
	 * @throws \RuntimeException
71 -
	 * @return array
71 +
	 * @return array<string, array<string, mixed>>
72 72
	 */
73 73
	public static function taskConfig(array $tasks): array {
74 74
		$config = [];

@@ -56,7 +56,7 @@
Loading
56 56
	 * This function is executed, when a worker is executing a task.
57 57
	 * The return parameter will determine, if the task will be marked completed, or be requeued.
58 58
	 *
59 -
	 * @param array $data The array passed to QueuedJobsTable::createJob()
59 +
	 * @param array<string, mixed> $data The array passed to QueuedJobsTable::createJob()
60 60
	 * @param int $jobId The id of the QueuedJob entity
61 61
	 * @return void
62 62
	 */

@@ -48,7 +48,7 @@
Loading
48 48
	/**
49 49
	 * Initialize method
50 50
	 *
51 -
	 * @param array $config The configuration for the Table.
51 +
	 * @param array<string, mixed> $config The configuration for the Table.
52 52
	 * @return void
53 53
	 */
54 54
	public function initialize(array $config): void {
@@ -102,7 +102,7 @@
Loading
102 102
103 103
	/**
104 104
	 * @param string $value
105 -
	 * @param array $context
105 +
	 * @param array<string, mixed> $context
106 106
	 *
107 107
	 * @return bool
108 108
	 */
@@ -199,7 +199,7 @@
Loading
199 199
	 * - time: Timestamp as FrozenTime object
200 200
	 * - workers: int Count of currently running workers
201 201
	 *
202 -
	 * @return array
202 +
	 * @return array<string, mixed>
203 203
	 */
204 204
	public function status(): array {
205 205
		$timeout = Config::defaultworkertimeout();

@@ -39,7 +39,7 @@
Loading
39 39
	protected $logger;
40 40
41 41
	/**
42 -
	 * @var array|null
42 +
	 * @var array<string, array<string, mixed>>|null
43 43
	 */
44 44
	protected $taskConf;
45 45
@@ -72,7 +72,7 @@
Loading
72 72
	}
73 73
74 74
	/**
75 -
	 * @param array $args
75 +
	 * @param array<string, mixed> $args
76 76
	 *
77 77
	 * @return int
78 78
	 */
@@ -261,11 +261,10 @@
Loading
261 261
	/**
262 262
	 * Returns a List of available QueueTasks and their individual configuration.
263 263
	 *
264 -
	 * @return array
264 +
	 * @return array<string, array<string, mixed>>
265 265
	 */
266 266
	protected function getTaskConf(): array {
267 267
		if (!is_array($this->taskConf)) {
268 -
			/** @var array $tasks */
269 268
			$tasks = (new TaskFinder())->all();
270 269
			$this->taskConf = Config::taskConfig($tasks);
271 270
		}
@@ -413,9 +412,9 @@
Loading
413 412
	}
414 413
415 414
	/**
416 -
	 * @param array $args
415 +
	 * @param array<string, mixed> $args
417 416
	 *
418 -
	 * @return array
417 +
	 * @return array<string, mixed>
419 418
	 */
420 419
	protected function getConfig(array $args): array {
421 420
		$config = [

@@ -22,7 +22,7 @@
Loading
22 22
	use LoadHelperTrait;
23 23
24 24
	/**
25 -
	 * @var array
25 +
	 * @var array<mixed>
26 26
	 */
27 27
	public $paginate = [
28 28
		'order' => [
@@ -126,7 +126,7 @@
Loading
126 126
	 */
127 127
	public function import() {
128 128
		if ($this->request->is(['post'])) {
129 -
			/** @var \Laminas\Diactoros\UploadedFile|array $file */
129 +
			/** @var \Laminas\Diactoros\UploadedFile|array<string, mixed> $file */
130 130
			$file = $this->request->getData('file');
131 131
			if ($file instanceof UploadedFile) {
132 132
				$file = $this->fileToArray($file);
@@ -323,7 +323,7 @@
Loading
323 323
	/**
324 324
	 * @param \Laminas\Diactoros\UploadedFile $file
325 325
	 *
326 -
	 * @return array
326 +
	 * @return array<string, mixed>
327 327
	 */
328 328
	protected function fileToArray(UploadedFile $file): array {
329 329
		return [

@@ -94,7 +94,7 @@
Loading
94 94
	 * This function is executed, when a worker is executing a task.
95 95
	 * The return parameter will determine, if the task will be marked completed, or be requeued.
96 96
	 *
97 -
	 * @param array $data The array passed to QueuedJobsTable::createJob()
97 +
	 * @param array<string, mixed> $data The array passed to QueuedJobsTable::createJob()
98 98
	 * @param int $jobId The id of the QueuedJob entity
99 99
	 * @return void
100 100
	 */
Files Complexity Coverage
src 646 57.86%
Project Totals (35 files) 646 57.86%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading