Completed
Push — master ( 282f78...6dce89 )
by Sam
05:20
created

ServerStartEvent::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/*
3
 * This file is part of PHP DNS Server.
4
 *
5
 * (c) Yif Swery <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace yswery\DNS\Event;
12
13
use React\Datagram\Socket;
14
use React\Datagram\SocketInterface;
15
use Symfony\Component\EventDispatcher\Event;
16
17
class ServerStartEvent extends Event
18
{
19
    /**
20
     * @var Socket
21
     */
22
    private $socket;
23
24
    /**
25
     * ServerStartEvent constructor.
26
     *
27
     * @param SocketInterface $socket
28
     */
29
    public function __construct(SocketInterface $socket)
30
    {
31
        $this->socket = $socket;
0 ignored issues
show
Documentation Bug introduced by
$socket is of type React\Datagram\SocketInterface, but the property $socket was declared to be of type React\Datagram\Socket. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof 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 given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
32
    }
33
34
    /**
35
     * @return Socket
36
     */
37
    public function getSocket(): Socket
38
    {
39
        return $this->socket;
40
    }
41
}
42