File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -335,19 +335,35 @@ private function collectHistograms(): array
335335 /**
336336 * @param mixed $val
337337 * @return int
338+ * @throws RuntimeException
338339 */
339340 private function toBinaryRepresentationAsInteger ($ val ): int
340341 {
341- return unpack ('Q ' , pack ('d ' , $ val ))[1 ];
342+ $ packedDouble = pack ('d ' , $ val );
343+ if ((bool )$ packedDouble !== false ) {
344+ $ unpackedData = unpack ("Q " , $ packedDouble );
345+ if (is_array ($ unpackedData )) {
346+ return $ unpackedData [1 ];
347+ }
348+ }
349+ throw new RuntimeException ("Formatting from binary representation to integer did not work " );
342350 }
343351
344352 /**
345353 * @param mixed $val
346354 * @return float
355+ * @throws RuntimeException
347356 */
348357 private function fromBinaryRepresentationAsInteger ($ val ): float
349358 {
350- return unpack ('d ' , pack ('Q ' , $ val ))[1 ];
359+ $ packedBinary = pack ('Q ' , $ val );
360+ if ((bool )$ packedBinary !== false ) {
361+ $ unpackedData = unpack ("d " , $ packedBinary );
362+ if (is_array ($ unpackedData )) {
363+ return $ unpackedData [1 ];
364+ }
365+ }
366+ throw new RuntimeException ("Formatting from integer to binary representation did not work " );
351367 }
352368
353369 /**
You can’t perform that action at this time.
0 commit comments