Skip to content

Commit 7f3085f

Browse files
additional check if version response is available in requested.
1 parent 1399419 commit 7f3085f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Bolt.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ private function handshake(): string
109109

110110
/**
111111
* Read and compose selected protocol version
112-
* @return string
112+
* @return string|null
113113
*/
114-
private function unpackProtocolVersion(): string
114+
private function unpackProtocolVersion(): ?string
115115
{
116116
$result = [];
117117

@@ -123,7 +123,8 @@ private function unpackProtocolVersion(): string
123123
array_shift($result);
124124
}
125125

126-
return implode('.', array_reverse($result));
126+
$version = implode('.', array_reverse($result));
127+
return in_array($version, $this->versions) ? $version : null;
127128
}
128129

129130
/**
@@ -137,7 +138,7 @@ private function packProtocolVersions(): string
137138
while (count($this->versions) < 4)
138139
$this->versions[] = '0';
139140

140-
foreach ($this->versions as $v) {
141+
foreach (array_slice($this->versions, 0, 4) as $v) {
141142
if (is_int($v))
142143
$versions[] = pack('N', $v);
143144
else {

0 commit comments

Comments
 (0)