1 | <?php |
||
18 | final class Server |
||
19 | { |
||
20 | /** |
||
21 | * @var ConnectionListenerInterface |
||
22 | */ |
||
23 | private $listener; |
||
24 | |||
25 | /** |
||
26 | * @var CapabilityInterface[] |
||
27 | */ |
||
28 | private $capabilities = []; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | private $serverName; |
||
34 | |||
35 | /** |
||
36 | * @param ConnectionListenerInterface $connection |
||
37 | * @param array|CapabilityInterface[] $capabilities |
||
38 | * @param string $serverName |
||
39 | */ |
||
40 | 6 | public function __construct(ConnectionListenerInterface $connection, array $capabilities, string $serverName) |
|
54 | |||
55 | 6 | public function start(): void |
|
56 | { |
||
57 | 6 | while ($connection = $this->listener->listen()) { |
|
58 | 6 | $connection = new TrimCrlfConnection(new AppendCrlfConnection($connection)); |
|
59 | 6 | $connection->send('220 Welcome to Genkgo Mail Server'); |
|
60 | |||
61 | 6 | $this->transport( |
|
62 | 6 | $connection, |
|
63 | function (ConnectionInterface $connection) { |
||
64 | 6 | $session = new Session(); |
|
65 | |||
66 | 6 | while ($session = $session->withCommand($connection->receive())) { |
|
67 | try { |
||
68 | 2 | $session = $this->handleCommand($connection, $session); |
|
69 | 1 | } catch (UnknownSmtpCommandException $e) { |
|
70 | 1 | $connection->send('500 unrecognized command'); |
|
71 | } |
||
72 | |||
73 | 2 | if ($session->getState() === Session::STATE_DISCONNECT) { |
|
74 | 2 | break; |
|
75 | } |
||
76 | } |
||
77 | 6 | } |
|
78 | ); |
||
79 | } |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * @param ConnectionInterface $connection |
||
84 | * @param \Closure $callback |
||
85 | */ |
||
86 | 6 | private function transport(ConnectionInterface $connection, \Closure $callback): void |
|
104 | |||
105 | /** |
||
106 | * @param ConnectionInterface $connection |
||
107 | * @param Session $session |
||
108 | * @return Session |
||
109 | * @throws UnknownSmtpCommandException |
||
110 | */ |
||
111 | 2 | private function handleCommand(ConnectionInterface $connection, Session $session): Session |
|
124 | } |
||
125 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..