Fixed UUID variant corruption in UUID->toString(), close #1286

This class may encapsulate any type of UUID, not just RFC 4122. Additionally, an RFC 4122 UUID may have this set as 8, 9, A or B.
This commit is contained in:
Dylan K. Taylor 2017-08-24 12:51:46 +01:00
parent 90edb8ebe7
commit 238b3ca4c1

View File

@ -94,9 +94,6 @@ class UUID{
$hex = bin2hex($this->toBinary());
//xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx 8-4-4-4-12
if($this->version !== null){
return substr($hex, 0, 8) . "-" . substr($hex, 8, 4) . "-" . hexdec($this->version) . substr($hex, 13, 3) . "-8" . substr($hex, 17, 3) . "-" . substr($hex, 20, 12);
}
return substr($hex, 0, 8) . "-" . substr($hex, 8, 4) . "-" . substr($hex, 12, 4) . "-" . substr($hex, 16, 4) . "-" . substr($hex, 20, 12);
}