Completed
Push — mater ( 02259a )
by Vasily
05:33
created

Scan::onReady()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 25
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 25
rs 8.8571
cc 2
eloc 13
nc 2
nop 0
1
<?php
2
/**
3
 * `phpd.conf`
4
 * Clients\Redis\Examples\Scan {}
5
 */
6
namespace PHPDaemon\Clients\Redis\Examples;
7
8
use PHPDaemon\Core\Daemon;
9
use PHPDaemon\Core\Debug;
10
11
/**
12
 * @package    NetworkClients
13
 * @subpackage RedisClientExample
14
 * @author     Efimenko Dmitriy <[email protected]>
15
 */
16
class Scan extends \PHPDaemon\Core\AppInstance {
17
	/**
18
	 * @var Pool
19
	 */
20
	public $redis;
21
22
	/**
23
	 * Called when the worker is ready to go
24
	 * @return void
25
	 */
26
	public function onReady() {
27
		$this->redis = \PHPDaemon\Clients\Redis\Pool::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like \PHPDaemon\Clients\Redis\Pool::getInstance() of type object<PHPDaemon\Network\this> is incompatible with the declared type object<PHPDaemon\Clients\Redis\Examples\Pool> of property $redis.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
28
29
		$params = [];
30
		foreach (range(0, 100) as $i) {
31
			$params[] = 'myset' . $i;
32
			$params[] = 'value' . $i;
33
		}
34
		$params[] = function($redis) {
0 ignored issues
show
Unused Code introduced by
The parameter $redis is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
35
			$params = [function($redis) {
36
				D('Count: ' . count($redis->result[1]) . '; Next: ' . $redis->result[0]);
37
			}];
38
			
39
			$cbEnd = function($redis, $scan) {
0 ignored issues
show
Unused Code introduced by
The parameter $redis is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $scan is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40
				D('Full scan end!');
41
			};
42
43
			// test 1
44
			// call_user_func_array([$this->redis, 'scan'], $params);
0 ignored issues
show
Unused Code Comprehensibility introduced by
69% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
45
46
			// test 2
47
			$this->redis->autoscan('scan', $params, $cbEnd, 50);
48
		};
49
		call_user_func_array([$this->redis, 'mset'], $params);
50
	}
51
}
52