These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | require_once "vendor/autoload.php"; |
||
4 | |||
5 | use BitWasp\Bitcoin\Networking\Peer\Peer; |
||
6 | |||
7 | $loop = React\EventLoop\Factory::create(); |
||
8 | $factory = new \BitWasp\Bitcoin\Networking\Factory($loop); |
||
9 | |||
10 | $msgs = $factory->getMessages(new \BitWasp\Bitcoin\Crypto\Random\Random()); |
||
11 | $dns = $factory->getDns(); |
||
12 | $host = $factory->getAddress('80.57.227.14'); |
||
13 | $local = $factory->getAddress('192.168.192.39'); |
||
14 | |||
15 | $params = new \BitWasp\Bitcoin\Networking\Peer\ConnectionParams(); |
||
16 | $params->requestTxRelay(true); |
||
17 | |||
18 | $connector = new \BitWasp\Bitcoin\Networking\Peer\Connector( |
||
19 | $msgs, |
||
20 | $params, |
||
21 | $loop, |
||
22 | $dns |
||
23 | ); |
||
24 | |||
25 | $connector |
||
0 ignored issues
–
show
|
|||
26 | ->connect($host) |
||
27 | ->then(function (Peer $peer) { |
||
28 | $remoteVersion = $peer->getRemoteVersion(); |
||
29 | $protoVersion = $remoteVersion->getVersion(); |
||
30 | $services = $remoteVersion->getServices(); |
||
31 | |||
32 | if ($protoVersion < 70012) { |
||
33 | echo "Found peer with version: ".$protoVersion. " - disconnecting\n"; |
||
34 | $peer->close(); |
||
35 | } |
||
36 | |||
37 | if ($services->getInt() != '5') { |
||
38 | echo "Peer was not a full node - disconnecting\n"; |
||
39 | $peer->close(); |
||
40 | } |
||
41 | }); |
||
42 | |||
43 | $loop->run(); |
||
44 |
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: