File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,9 @@ public function build(): AProtocol
6161 */
6262 public function setProtocolVersions (...$ v ): Bolt
6363 {
64- $ this ->versions = $ v ;
64+ $ this ->versions = array_slice ($ v , 0 , 4 );
65+ while (count ($ this ->versions ) < 4 )
66+ $ this ->versions [] = 0 ;
6567 return $ this ;
6668 }
6769
@@ -109,9 +111,9 @@ private function handshake(): string
109111
110112 /**
111113 * Read and compose selected protocol version
112- * @return string
114+ * @return string|null
113115 */
114- private function unpackProtocolVersion (): string
116+ private function unpackProtocolVersion (): ? string
115117 {
116118 $ result = [];
117119
@@ -123,7 +125,8 @@ private function unpackProtocolVersion(): string
123125 array_shift ($ result );
124126 }
125127
126- return implode ('. ' , array_reverse ($ result ));
128+ $ version = implode ('. ' , array_reverse ($ result ));
129+ return in_array ($ version , $ this ->versions ) ? $ version : null ;
127130 }
128131
129132 /**
@@ -134,9 +137,6 @@ private function packProtocolVersions(): string
134137 {
135138 $ versions = [];
136139
137- while (count ($ this ->versions ) < 4 )
138- $ this ->versions [] = '0 ' ;
139-
140140 foreach ($ this ->versions as $ v ) {
141141 if (is_int ($ v ))
142142 $ versions [] = pack ('N ' , $ v );
You can’t perform that action at this time.
0 commit comments