GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (8)

src/Socket/StreamSocket.php (1 issue)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Pheanstalk\Socket;
6
7
use Pheanstalk\Exception\ConnectionException;
8
9
/**
10
 * A Socket implementation using the Streams extension
11
 */
12
class StreamSocket extends FileSocket
13
{
14 5
    public function __construct(
15
        string $host,
16
        int $port,
17
        float $connectTimeout
18
    ) {
19 5
        $addresses = gethostbynamel($host);
20 5
        if ($addresses === false) {
21 1
            throw new ConnectionException(0, "Could not resolve hostname $host");
22
        }
23 4
        $target = "tcp://{$addresses[0]}:$port";
24
25 4
        $context = stream_context_create();
26 4
        $this->socket = @stream_socket_client(
0 ignored issues
show
Documentation Bug introduced by
It seems like @stream_socket_client($t...IENT_CONNECT, $context) can also be of type false. However, the property $socket is declared as type null|resource. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
27 4
            $target,
28
            $error,
29
            $errorMessage,
30
            $connectTimeout,
31 4
            STREAM_CLIENT_CONNECT,
32
            $context
33
        );
34 4
        if ($this->socket === false) {
35 1
            throw new ConnectionException($errorMessage, $error);
36
        }
37 3
    }
38
}
39