thomasvargiu /
AMQPAL
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 AMQPAL\Adapter\PhpAmqpLib; |
||
| 4 | |||
| 5 | use PhpAmqpLib\Channel\AMQPChannel; |
||
| 6 | use Prophecy\Argument; |
||
| 7 | use AMQPAL\Options\ExchangeOptions; |
||
| 8 | use AMQPAL\Options\QueueOptions; |
||
| 9 | |||
| 10 | class ChannelTest extends \PHPUnit_Framework_TestCase |
||
| 11 | { |
||
| 12 | public function testSetResource() |
||
| 13 | { |
||
| 14 | $resource = $this->prophesize(AMQPChannel::class); |
||
| 15 | |||
| 16 | $channel = new Channel(); |
||
| 17 | $channel->setResource($resource->reveal()); |
||
| 18 | |||
| 19 | static::assertSame($resource->reveal(), $channel->getResource()); |
||
| 20 | } |
||
| 21 | |||
| 22 | public function testIsConnected() |
||
| 23 | { |
||
| 24 | $resource = $this->prophesize(AMQPChannel::class); |
||
| 25 | $connection = $this->prophesize(Connection::class); |
||
| 26 | |||
| 27 | $connection->isConnected()->shouldBeCalled()->willReturn(true); |
||
| 28 | |||
| 29 | $channel = new Channel(); |
||
| 30 | $channel->setConnection($connection->reveal()); |
||
| 31 | $channel->setResource($resource->reveal()); |
||
| 32 | |||
| 33 | static::assertTrue($channel->isConnected()); |
||
| 34 | } |
||
| 35 | |||
| 36 | public function testGetChannelId() |
||
| 37 | { |
||
| 38 | $resource = $this->prophesize(AMQPChannel::class); |
||
| 39 | |||
| 40 | $resource->getChannelId()->shouldBeCalled()->willReturn(1234); |
||
| 41 | |||
| 42 | $channel = new Channel(); |
||
| 43 | $channel->setResource($resource->reveal()); |
||
| 44 | |||
| 45 | static::assertEquals(1234, $channel->getChannelId()); |
||
| 46 | } |
||
| 47 | |||
| 48 | public function testSetQos() |
||
| 49 | { |
||
| 50 | $resource = $this->prophesize(AMQPChannel::class); |
||
| 51 | |||
| 52 | $resource->basic_qos(2, 3, false)->shouldBeCalled(); |
||
| 53 | |||
| 54 | $channel = new Channel(); |
||
| 55 | $channel->setResource($resource->reveal()); |
||
| 56 | |||
| 57 | $channel->setQos(2, 3); |
||
| 58 | } |
||
| 59 | |||
| 60 | public function testStartTransaction() |
||
| 61 | { |
||
| 62 | /** @var \Prophecy\Prophecy\ObjectProphecy|AMQPChannel $resource */ |
||
| 63 | $resource = $this->prophesize(AMQPChannel::class); |
||
| 64 | |||
| 65 | $resource->tx_select()->shouldBeCalled(); |
||
|
0 ignored issues
–
show
|
|||
| 66 | |||
| 67 | $channel = new Channel(); |
||
| 68 | $channel->setResource($resource->reveal()); |
||
|
0 ignored issues
–
show
The method
reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in PhpAmqpLib\Channel\AMQPChannel.
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...
|
|||
| 69 | |||
| 70 | $channel->startTransaction(); |
||
| 71 | } |
||
| 72 | |||
| 73 | public function testCommitTransaction() |
||
| 74 | { |
||
| 75 | /** @var \Prophecy\Prophecy\ObjectProphecy|AMQPChannel $resource */ |
||
| 76 | $resource = $this->prophesize(AMQPChannel::class); |
||
| 77 | |||
| 78 | $resource->tx_commit()->shouldBeCalled(); |
||
|
0 ignored issues
–
show
The method
tx_commit does only exist in PhpAmqpLib\Channel\AMQPChannel, but not in Prophecy\Prophecy\ObjectProphecy.
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...
|
|||
| 79 | |||
| 80 | $channel = new Channel(); |
||
| 81 | $channel->setResource($resource->reveal()); |
||
|
0 ignored issues
–
show
The method
reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in PhpAmqpLib\Channel\AMQPChannel.
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 | $channel->commitTransaction(); |
||
| 84 | } |
||
| 85 | |||
| 86 | public function testRollbackTransaction() |
||
| 87 | { |
||
| 88 | /** @var \Prophecy\Prophecy\ObjectProphecy|AMQPChannel $resource */ |
||
| 89 | $resource = $this->prophesize(AMQPChannel::class); |
||
| 90 | |||
| 91 | $resource->tx_rollback()->shouldBeCalled(); |
||
|
0 ignored issues
–
show
The method
tx_rollback does only exist in PhpAmqpLib\Channel\AMQPChannel, but not in Prophecy\Prophecy\ObjectProphecy.
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...
|
|||
| 92 | |||
| 93 | $channel = new Channel(); |
||
| 94 | $channel->setResource($resource->reveal()); |
||
|
0 ignored issues
–
show
The method
reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in PhpAmqpLib\Channel\AMQPChannel.
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...
|
|||
| 95 | |||
| 96 | $channel->rollbackTransaction(); |
||
| 97 | } |
||
| 98 | |||
| 99 | public function testBasicRecoverWithDefaults() |
||
| 100 | { |
||
| 101 | /** @var \Prophecy\Prophecy\ObjectProphecy|AMQPChannel $resource */ |
||
| 102 | $resource = $this->prophesize(AMQPChannel::class); |
||
| 103 | |||
| 104 | $resource->basic_recover(true)->shouldBeCalled(); |
||
|
0 ignored issues
–
show
The method
basic_recover does only exist in PhpAmqpLib\Channel\AMQPChannel, but not in Prophecy\Prophecy\ObjectProphecy.
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...
|
|||
| 105 | |||
| 106 | $channel = new Channel(); |
||
| 107 | $channel->setResource($resource->reveal()); |
||
|
0 ignored issues
–
show
The method
reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in PhpAmqpLib\Channel\AMQPChannel.
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...
|
|||
| 108 | |||
| 109 | $channel->basicRecover(); |
||
| 110 | } |
||
| 111 | |||
| 112 | public function testBasicRecoverWithNoRequeue() |
||
| 113 | { |
||
| 114 | /** @var \Prophecy\Prophecy\ObjectProphecy|AMQPChannel $resource */ |
||
| 115 | $resource = $this->prophesize(AMQPChannel::class); |
||
| 116 | |||
| 117 | $resource->basic_recover(false)->shouldBeCalled(); |
||
|
0 ignored issues
–
show
The method
basic_recover does only exist in PhpAmqpLib\Channel\AMQPChannel, but not in Prophecy\Prophecy\ObjectProphecy.
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...
|
|||
| 118 | |||
| 119 | $channel = new Channel(); |
||
| 120 | $channel->setResource($resource->reveal()); |
||
|
0 ignored issues
–
show
The method
reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in PhpAmqpLib\Channel\AMQPChannel.
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...
|
|||
| 121 | |||
| 122 | $channel->basicRecover(false); |
||
| 123 | } |
||
| 124 | |||
| 125 | public function testGetConnection() |
||
| 126 | { |
||
| 127 | $connection = $this->prophesize(Connection::class); |
||
| 128 | $adapter = $this->prophesize(PhpAmqpLib::class); |
||
|
0 ignored issues
–
show
$adapter is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the Loading history...
|
|||
| 129 | |||
| 130 | $channel = new Channel(); |
||
| 131 | $channel->setConnection($connection->reveal()); |
||
| 132 | |||
| 133 | static::assertSame($connection->reveal(), $channel->getConnection()); |
||
| 134 | } |
||
| 135 | |||
| 136 | public function testCreateExchange() |
||
| 137 | { |
||
| 138 | $exchangeOptions = $this->prophesize(ExchangeOptions::class); |
||
| 139 | $exchangePrototype = $this->prophesize(Exchange::class); |
||
| 140 | |||
| 141 | $exchangePrototype->setChannel(Argument::type(Channel::class))->shouldBeCalled(); |
||
| 142 | $exchangePrototype->setOptions($exchangeOptions->reveal())->shouldBeCalled(); |
||
| 143 | |||
| 144 | $channel = new Channel($exchangePrototype->reveal()); |
||
| 145 | |||
| 146 | $exchange = $channel->createExchange($exchangeOptions->reveal()); |
||
| 147 | |||
| 148 | static::assertInstanceOf(Exchange::class, $exchange); |
||
| 149 | } |
||
| 150 | |||
| 151 | public function testCreateQueue() |
||
| 152 | { |
||
| 153 | $queueOptions = $this->prophesize(QueueOptions::class); |
||
| 154 | $queuePrototype = $this->prophesize(Queue::class); |
||
| 155 | |||
| 156 | $queuePrototype->setChannel(Argument::type(Channel::class))->shouldBeCalled(); |
||
| 157 | $queuePrototype->setOptions($queueOptions->reveal())->shouldBeCalled(); |
||
| 158 | |||
| 159 | $channel = new Channel(null, $queuePrototype->reveal()); |
||
| 160 | |||
| 161 | $exchange = $channel->createQueue($queueOptions->reveal()); |
||
| 162 | |||
| 163 | static::assertInstanceOf(Queue::class, $exchange); |
||
| 164 | } |
||
| 165 | } |
||
| 166 |
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: