File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments