bernardphp /
bernard
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
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 Bernard\Driver\PhpRedis; |
||
| 4 | |||
| 5 | use Redis; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Implements a Driver for use with https://github.com/nicolasff/phpredis. |
||
| 9 | */ |
||
| 10 | class Driver implements \Bernard\Driver |
||
| 11 | { |
||
| 12 | const QUEUE_PREFIX = 'queue:'; |
||
| 13 | |||
| 14 | protected $redis; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @param Redis $redis |
||
| 18 | */ |
||
| 19 | 8 | public function __construct(Redis $redis) |
|
| 20 | { |
||
| 21 | 8 | $this->redis = $redis; |
|
| 22 | 8 | } |
|
| 23 | |||
| 24 | /** |
||
| 25 | * {@inheritdoc} |
||
| 26 | */ |
||
| 27 | 2 | public function listQueues() |
|
| 28 | { |
||
| 29 | 2 | return $this->redis->sMembers('queues'); |
|
|
0 ignored issues
–
show
|
|||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * {@inheritdoc} |
||
| 34 | */ |
||
| 35 | 2 | public function createQueue($queueName) |
|
| 36 | { |
||
| 37 | 2 | $this->redis->sAdd('queues', $queueName); |
|
|
0 ignored issues
–
show
The method
sAdd does only exist in Redis, but not in Predis\ClientInterface.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 38 | 2 | } |
|
| 39 | |||
| 40 | /** |
||
| 41 | * {@inheritdoc} |
||
| 42 | */ |
||
| 43 | 2 | public function countMessages($queueName) |
|
| 44 | { |
||
| 45 | 2 | return $this->redis->lLen(self::QUEUE_PREFIX.$queueName); |
|
|
0 ignored issues
–
show
The method
lLen does only exist in Redis, but not in Predis\ClientInterface.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * {@inheritdoc} |
||
| 50 | */ |
||
| 51 | 2 | public function pushMessage($queueName, $message) |
|
| 52 | { |
||
| 53 | 2 | $this->redis->rpush($this->resolveKey($queueName), $message); |
|
|
0 ignored issues
–
show
The method
rpush does only exist in Redis, but not in Predis\ClientInterface.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 54 | 2 | } |
|
| 55 | |||
| 56 | /** |
||
| 57 | * {@inheritdoc} |
||
| 58 | */ |
||
| 59 | 1 | public function popMessage($queueName, $duration = 5) |
|
| 60 | { |
||
| 61 | // When PhpRedis is set up with an Redis::OPT_PREFIX |
||
| 62 | // it does set the prefix to the key and to the timeout value something like: |
||
| 63 | // "BLPOP" "bernard:queue:my-queue" "bernard:5" |
||
| 64 | // |
||
| 65 | // To set the resolved key in an array seems fixing this issue. We get: |
||
| 66 | // "BLPOP" "bernard:queue:my-queue" "5" |
||
| 67 | // |
||
| 68 | // see https://github.com/nicolasff/phpredis/issues/158 |
||
| 69 | 1 | list(, $message) = $this->redis->blpop([$this->resolveKey($queueName)], $duration) ?: null; |
|
|
0 ignored issues
–
show
The method
blpop does only exist in Redis, but not in Predis\ClientInterface.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 70 | |||
| 71 | 1 | return [$message, null]; |
|
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * {@inheritdoc} |
||
| 76 | */ |
||
| 77 | 2 | public function peekQueue($queueName, $index = 0, $limit = 20) |
|
| 78 | { |
||
| 79 | 2 | $limit += $index - 1; |
|
| 80 | |||
| 81 | 2 | return $this->redis->lRange($this->resolveKey($queueName), $index, $limit); |
|
|
0 ignored issues
–
show
The method
lRange does only exist in Redis, but not in Predis\ClientInterface.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * {@inheritdoc} |
||
| 86 | */ |
||
| 87 | public function acknowledgeMessage($queueName, $receipt) |
||
| 88 | { |
||
| 89 | } |
||
| 90 | |||
| 91 | /** |
||
| 92 | * {@inheritdoc} |
||
| 93 | */ |
||
| 94 | 2 | public function removeQueue($queueName) |
|
| 95 | { |
||
| 96 | 2 | $this->redis->sRem('queues', $queueName); |
|
|
0 ignored issues
–
show
The method
sRem does only exist in Redis, but not in Predis\ClientInterface.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 97 | 2 | $this->redis->del($this->resolveKey($queueName)); |
|
|
0 ignored issues
–
show
The method
del does only exist in Redis, but not in Predis\ClientInterface.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 98 | 2 | } |
|
| 99 | |||
| 100 | /** |
||
| 101 | * {@inheritdoc} |
||
| 102 | */ |
||
| 103 | public function info() |
||
| 104 | { |
||
| 105 | return $this->redis->info(); |
||
|
0 ignored issues
–
show
The method
info does only exist in Redis, but not in Predis\ClientInterface.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 106 | } |
||
| 107 | |||
| 108 | /** |
||
| 109 | * Transform the queueName into a key. |
||
| 110 | * |
||
| 111 | * @param string $queueName |
||
| 112 | * |
||
| 113 | * @return string |
||
| 114 | */ |
||
| 115 | 8 | protected function resolveKey($queueName) |
|
| 116 | { |
||
| 117 | 8 | return self::QUEUE_PREFIX.$queueName; |
|
| 118 | } |
||
| 119 | } |
||
| 120 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: