Bit-Wasp /
bitcoin-p2p-php
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 BitWasp\Bitcoin\Networking\Peer; |
||
| 4 | |||
| 5 | use BitWasp\Bitcoin\Networking\Messages\Factory as MsgFactory; |
||
| 6 | use BitWasp\Bitcoin\Networking\Structure\NetworkAddressInterface; |
||
| 7 | use React\Dns\Resolver\Resolver; |
||
| 8 | use React\EventLoop\LoopInterface; |
||
| 9 | use React\Stream\Stream; |
||
| 10 | |||
| 11 | class Connector extends \React\SocketClient\Connector |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var ConnectionParams |
||
| 15 | */ |
||
| 16 | private $params; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var MsgFactory |
||
| 20 | */ |
||
| 21 | private $msgs; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var LoopInterface |
||
| 25 | */ |
||
| 26 | private $loop; |
||
|
0 ignored issues
–
show
Comprehensibility
introduced
by
Loading history...
|
|||
| 27 | |||
| 28 | /** |
||
| 29 | * Connector constructor. |
||
| 30 | * @param MsgFactory $msgs |
||
| 31 | * @param ConnectionParams $params |
||
| 32 | * @param LoopInterface $loop |
||
| 33 | * @param Resolver $resolver |
||
| 34 | */ |
||
| 35 | public function __construct(MsgFactory $msgs, ConnectionParams $params, LoopInterface $loop, Resolver $resolver) |
||
| 36 | { |
||
| 37 | $this->params = $params; |
||
| 38 | $this->msgs = $msgs; |
||
| 39 | $this->loop = $loop; |
||
| 40 | |||
| 41 | parent::__construct($loop, $resolver); |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @param NetworkAddressInterface $remotePeer |
||
| 46 | * @return \React\Promise\PromiseInterface|static |
||
| 47 | */ |
||
| 48 | public function rawConnect(NetworkAddressInterface $remotePeer) |
||
| 49 | { |
||
| 50 | return $this |
||
| 51 | ->create($remotePeer->getIp(), $remotePeer->getPort()) |
||
| 52 | ->then(function (Stream $stream) { |
||
| 53 | $peer = new Peer($this->msgs, $this->loop); |
||
| 54 | $peer->setupStream($stream); |
||
| 55 | return $peer; |
||
| 56 | }); |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @param NetworkAddressInterface $remotePeer |
||
| 61 | * @return \React\Promise\PromiseInterface|static |
||
| 62 | */ |
||
| 63 | public function connect(NetworkAddressInterface $remotePeer) |
||
| 64 | { |
||
| 65 | return $this |
||
|
0 ignored issues
–
show
The method
then does only exist in React\Promise\PromiseInterface, but not in BitWasp\Bitcoin\Networking\Peer\Connector.
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...
|
|||
| 66 | ->rawConnect($remotePeer) |
||
| 67 | ->then(function (Peer $peer) use ($remotePeer) { |
||
| 68 | return $peer->outboundHandshake($remotePeer, $this->params); |
||
| 69 | }); |
||
| 70 | } |
||
| 71 | } |
||
| 72 |