3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Uuid { const MD5 = 3; const SHA1 = 5; /** * 00001111 Clears all bits of version byte with AND * @var int */ const CLEAR_VER = 15; /** * 00111111 Clears all relevant bits of variant byte with AND * @var int */ const CLEAR_VAR = 63; /** * 11100000 Variant reserved for future use * @var int */ const VAR_RES = 224; /** * 11000000 Microsoft UUID variant * @var int */ const VAR_MS = 192; /** * 10000000 The RFC 4122 variant (this variant) * @var int */ const VAR_RFC = 128; /** * 00000000 The NCS compatibility variant * @var int */ const VAR_NCS = 0; /** * 00010000 * @var int */ const VERSION_1 = 16; /** * 00110000 * @var int */ const VERSION_3 = 48; /** * 01000000 * @var int */ const VERSION_4 = 64; /** * 01010000 * @var int */ const VERSION_5 = 80; /** * Time (in 100ns steps) between the start of the UTC and Unix epochs * @var int */ const INTERVAL = 0x01b21dd213814000; /** * @var string */ const NS_DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; /** * @var string */ const NS_URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; /** * @var string */ const NS_OID = '6ba7b812-9dad-11d1-80b4-00c04fd430c8'; /** * @var string */ const NS_X500 = '6ba7b814-9dad-11d1-80b4-00c04fd430c8'; /** * @var string */ protected static $randomFunc = 'randomMcrypt'; protected $bytes; protected $hex; protected $string; protected $urn; protected $version; protected $variant; protected $node; protected $time; /** * @param string $uuid * @throws Exception */ protected function __construct($uuid) { if (!empty($uuid) && strlen($uuid) !== 16) { throw new Exception('Input must be a 128-bit integer.'); } $this->bytes = $uuid; // Optimize the most common use $this->string = bin2hex(substr($uuid, 0, 4)) . "-" . bin2hex(substr($uuid, 4, 2)) . "-" . bin2hex(substr($uuid, 6, 2)) . "-" . bin2hex(substr($uuid, 8, 2)) . "-" . bin2hex(substr($uuid, 10, 6)); } /** * @param int $ver * @param string $node * @param string $ns * @return Uuid * @throws Exception */ public static function generate($ver = 1, $node = null, $ns = null) { /* Create a new UUID based on provided data. */ switch ((int)$ver) { case 1: return new static(static::mintTime($node)); case 2: // Version 2 is not supported throw new \Exception('Version 2 is unsupported.'); case 3: return new static(static::mintName(static::MD5, $node, $ns)); case 4: return new static(static::mintRand()); case 5: return new static(static::mintName(static::SHA1, $node, $ns)); default: throw new \Exception('Selected version is invalid or unsupported.'); } } /** * Generates a Version 1 UUID. * These are derived from the time at which they were generated. * * @param string $node * @return string */ protected static function mintTime($node = null) { /** Get time since Gregorian calendar reform in 100ns intervals * This is exceedingly difficult because of PHP's (and pack()'s) * integer size limits. * Note that this will never be more accurate than to the microsecond. */ $time = microtime(1) * 10000000 + static::INTERVAL; // Convert to a string representation $time = sprintf("%F", $time); //strip decimal point preg_match("/^\d+/", $time, $time); // And now to a 64-bit binary representation $time = base_convert($time[0], 10, 16); $time = pack("H*", str_pad($time, 16, "0", STR_PAD_LEFT)); // Reorder bytes to their proper locations in the UUID // $uuid = $time[4] . $time[5] . $time[6] . $time[7] . $time[2] . $time[3] . $time[0] . $time[1]; $uuid = $time[0] . $time[1] . $time[2] . $time[3] . $time[4] . $time[5] . $time[6] . $time[7]; // Generate a random clock sequence $uuid .= static::randomBytes(2); // set variant $uuid[8] = chr(ord($uuid[8]) & static::CLEAR_VAR | static::VAR_RFC); // set version $uuid[6] = chr(ord($uuid[6]) & static::CLEAR_VER | static::VERSION_1); // Set the final 'node' parameter, a MAC address /* if (!is_null($node)) { $node = static::makeBin($node, 6); } //If no node was provided or if the node was invalid, generate a random MAC address and set the multicast bit if (is_null($node)) { $node = static::randomBytes(6); $node[0] = pack("C", ord($node[0]) | 1); } $uuid .= $node; */ return bindec($uuid); } /** * Randomness is returned as a string of bytes * * @param $bytes * @return string */ public static function randomBytes($bytes) { return call_user_func(array('static', static::initRandom()), $bytes); } /** * Trying for openSSL and Mcrypt random generators. Fallback to mt_rand * Since laravel 4.* and 5.0 requires Mcrypt and 5.1 requires OpenSSL the fallback should never be used. * * @throws Exception * @return string */ public static function initRandom() { if (function_exists('openssl_random_pseudo_bytes')) { return 'randomOpenSSL'; } elseif (function_exists('mcrypt_encrypt')) { return 'randomMcrypt'; } // This is not the best randomizer (using mt_rand)... return 'randomTwister'; } /** * Insure that an input string is either binary or hexadecimal. * Returns binary representation, or false on failure. * * @param string $str * @param integer $len * @return string|null */ protected static function makeBin($str, $len) { if ($str instanceof self) { return $str->bytes; } if (strlen($str) === $len) { return $str; } else { // strip URN scheme and namespace $str = preg_replace('/^urn:uuid:/is', '', $str); } // strip non-hex characters $str = preg_replace('/[^a-f0-9]/is', '', $str); if (strlen($str) !== ($len * 2)) { return null; } else { return pack("H*", $str); } } /** * Generates a Version 3 or Version 5 UUID. * These are derived from a hash of a name and its namespace, in binary form. * * @param string $ver * @param string $node * @param string $ns * @return string * @throws Exception */ protected static function mintName($ver, $node, $ns) { if (empty($node)) { throw new Exception('A name-string is required for Version 3 or 5 UUIDs.'); } // if the namespace UUID isn't binary, make it so $ns = static::makeBin($ns, 16); if (is_null($ns)) { throw new Exception('A binary namespace is required for Version 3 or 5 UUIDs.'); } $version = null; $uuid = null; switch ($ver) { case static::MD5: $version = static::VERSION_3; $uuid = md5($ns . $node, 1); break; case static::SHA1: $version = static::VERSION_5; $uuid = substr(sha1($ns . $node, 1), 0, 16); break; default: // no default really required here } // set variant $uuid[8] = chr(ord($uuid[8]) & static::CLEAR_VAR | static::VAR_RFC); // set version $uuid[6] = chr(ord($uuid[6]) & static::CLEAR_VER | $version); return ($uuid); } /** * Generate a Version 4 UUID. * These are derived solely from random numbers. * generate random fields * * @return string */ protected static function mintRand() { $uuid = static::randomBytes(16); // set variant $uuid[8] = chr(ord($uuid[8]) & static::CLEAR_VAR | static::VAR_RFC); // set version $uuid[6] = chr(ord($uuid[6]) & static::CLEAR_VER | static::VERSION_4); return $uuid; } /** * Import an existing UUID * * @param string $uuid * @return Uuid */ public static function import($uuid) { return new static(static::makeBin($uuid, 16)); } /** * Compares the binary representations of two UUIDs. * The comparison will return true if they are bit-exact, * or if neither is valid. * * @param string $a * @param string $b * @return string|string */ public static function compare($a, $b) { if (static::makeBin($a, 16) == static::makeBin($b, 16)) { return true; } else { return false; } } /** * Get the specified number of random bytes, using openssl_random_pseudo_bytes(). * Randomness is returned as a string of bytes. * * @param $bytes * @return mixed */ protected static function randomOpenSSL($bytes) { return openssl_random_pseudo_bytes($bytes); } /** * Get the specified number of random bytes, using mcrypt_create_iv(). * Randomness is returned as a string of bytes. * * @param $bytes * @return string */ protected static function randomMcrypt($bytes) { return mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM); } /** * Get the specified number of random bytes, using mt_rand(). * Randomness is returned as a string of bytes. * * @param integer $bytes * @return string */ protected static function randomTwister($bytes) { $rand = ""; for ($a = 0; $a < $bytes; $a++) { $rand .= chr(mt_rand(0, 255)); } return $rand; } /** * @param string $var * @return string|string|number|number|number|number|number|NULL|number|NULL|NULL */ public function __get($var) { switch ($var) { case "bytes": return $this->bytes; // no break case "hex": return bin2hex($this->bytes); // no break case "string": return $this->__toString(); // no break case "urn": return "urn:uuid:" . $this->__toString(); // no break case "version": return ord($this->bytes[6]) >> 4; // no break case "variant": $byte = ord($this->bytes[8]); if ($byte >= static::VAR_RES) { return 3; } elseif ($byte >= static::VAR_MS) { return 2; } elseif ($byte >= static::VAR_RFC) { return 1; } else { return 0; } // no break case "node": if (ord($this->bytes[6]) >> 4 == 1) { return bin2hex(substr($this->bytes, 10)); } else { return null; } // no break case "time": if (ord($this->bytes[6]) >> 4 == 1) { // Restore contiguous big-endian byte order $time = bin2hex($this->bytes[6] . $this->bytes[7] . $this->bytes[4] . $this->bytes[5] . $this->bytes[0] . $this->bytes[1] . $this->bytes[2] . $this->bytes[3]); // Clear version flag $time[0] = "0"; // Do some reverse arithmetic to get a Unix timestamp return (hexdec($time) - static::INTERVAL) / 10000000; } else { return null; } // no break default: return null; // no break } } /** * Return the UUID * * @return string */ public function __toString() { return $this->string; } } $uuid = Uuid::generate(); echo($uuid);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L4Er4
function name:  (null)
number of ops:  6
compiled vars:  !0 = $uuid
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_CLASS                                            'uuid'
  480     1        INIT_STATIC_METHOD_CALL                                  'Uuid', 'generate'
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
  481     4        ECHO                                                     !0
          5      > RETURN                                                   1

Class Uuid:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/L4Er4
function name:  __construct
number of ops:  65
compiled vars:  !0 = $uuid
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  112     0  E >   RECV                                             !0      
  114     1        ISSET_ISEMPTY_CV                                 ~1      !0
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ_EX                                          ~2      ~2, ->7
          4    >   STRLEN                                           ~3      !0
          5        IS_NOT_IDENTICAL                                 ~4      ~3, 16
          6        BOOL                                             ~2      ~4
          7    > > JMPZ                                                     ~2, ->12
  115     8    >   NEW                                              $5      'Exception'
          9        SEND_VAL_EX                                              'Input+must+be+a+128-bit+integer.'
         10        DO_FCALL                                      0          
         11      > THROW                                         0          $5
  118    12    >   ASSIGN_OBJ                                               'bytes'
         13        OP_DATA                                                  !0
  121    14        INIT_FCALL                                               'bin2hex'
         15        INIT_FCALL                                               'substr'
         16        SEND_VAR                                                 !0
         17        SEND_VAL                                                 0
         18        SEND_VAL                                                 4
         19        DO_ICALL                                         $9      
         20        SEND_VAR                                                 $9
         21        DO_ICALL                                         $10     
         22        CONCAT                                           ~11     $10, '-'
  122    23        INIT_FCALL                                               'bin2hex'
         24        INIT_FCALL                                               'substr'
         25        SEND_VAR                                                 !0
         26        SEND_VAL                                                 4
         27        SEND_VAL                                                 2
         28        DO_ICALL                                         $12     
         29        SEND_VAR                                                 $12
         30        DO_ICALL                                         $13     
         31        CONCAT                                           ~14     ~11, $13
         32        CONCAT                                           ~15     ~14, '-'
  123    33        INIT_FCALL                                               'bin2hex'
         34        INIT_FCALL                                               'substr'
         35        SEND_VAR                                                 !0
         36        SEND_VAL                                                 6
         37        SEND_VAL                                                 2
         38        DO_ICALL                                         $16     
         39        SEND_VAR                                                 $16
         40        DO_ICALL                                         $17     
         41        CONCAT                                           ~18     ~15, $17
         42        CONCAT                                           ~19     ~18, '-'
  124    43        INIT_FCALL                                               'bin2hex'
         44        INIT_FCALL                                               'substr'
         45        SEND_VAR                                                 !0
         46        SEND_VAL                                                 8
         47        SEND_VAL                                                 2
         48        DO_ICALL                                         $20     
         49        SEND_VAR                                                 $20
         50        DO_ICALL                                         $21     
         51        CONCAT                                           ~22     ~19, $21
         52        CONCAT                                           ~23     ~22, '-'
  125    53        INIT_FCALL                                               'bin2hex'
         54        INIT_FCALL                                               'substr'
         55        SEND_VAR                                                 !0
         56        SEND_VAL                                                 10
         57        SEND_VAL                                                 6
         58        DO_ICALL                                         $24     
         59        SEND_VAR                                                 $24
         60        DO_ICALL                                         $25     
         61        CONCAT                                           ~26     ~23, $25
  121    62        ASSIGN_OBJ                                               'string'
  125    63        OP_DATA                                                  ~26
  126    64      > RETURN                                                   null

End of function __construct

Function generate:
Finding entry points
Branch analysis from position: 0
7 jumps found. (Code = 187) Position 1 = 16, Position 2 = 24, Position 3 = 28, Position 4 = 39, Position 5 = 46, Position 6 = 57, Position 7 = 5
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 57
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 28
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 39
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 46
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 46
Branch analysis from position: 39
Branch analysis from position: 28
Branch analysis from position: 24
Branch analysis from position: 16
filename:       /in/L4Er4
function name:  generate
number of ops:  63
compiled vars:  !0 = $ver, !1 = $node, !2 = $ns
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  136     0  E >   RECV_INIT                                        !0      1
          1        RECV_INIT                                        !1      null
          2        RECV_INIT                                        !2      null
  139     3        CAST                                          4  ~3      !0
          4      > SWITCH_LONG                                              ~3, [ 1:->16, 2:->24, 3:->28, 4:->39, 5:->46, ], ->57
  140     5    >   CASE                                                     ~3, 1
          6      > JMPNZ                                                    ~4, ->16
  142     7    >   CASE                                                     ~3, 2
          8      > JMPNZ                                                    ~4, ->24
  145     9    >   CASE                                                     ~3, 3
         10      > JMPNZ                                                    ~4, ->28
  147    11    >   CASE                                                     ~3, 4
         12      > JMPNZ                                                    ~4, ->39
  149    13    >   CASE                                                     ~3, 5
         14      > JMPNZ                                                    ~4, ->46
         15    > > JMP                                                      ->57
  141    16    >   NEW                          static              $5      
         17        INIT_STATIC_METHOD_CALL                                  'mintTime'
         18        SEND_VAR_EX                                              !1
         19        DO_FCALL                                      0  $6      
         20        SEND_VAR_NO_REF_EX                                       $6
         21        DO_FCALL                                      0          
         22        FREE                                                     ~3
         23      > RETURN                                                   $5
  144    24    >   NEW                                              $8      'Exception'
         25        SEND_VAL_EX                                              'Version+2+is+unsupported.'
         26        DO_FCALL                                      0          
         27      > THROW                                         0          $8
  146    28    >   NEW                          static              $10     
         29        INIT_STATIC_METHOD_CALL                                  'mintName'
         30        FETCH_CLASS_CONSTANT                             ~11     'MD5'
         31        SEND_VAL_EX                                              ~11
         32        SEND_VAR_EX                                              !1
         33        SEND_VAR_EX                                              !2
         34        DO_FCALL                                      0  $12     
         35        SEND_VAR_NO_REF_EX                                       $12
         36        DO_FCALL                                      0          
         37        FREE                                                     ~3
         38      > RETURN                                                   $10
  148    39    >   NEW                          static              $14     
         40        INIT_STATIC_METHOD_CALL                                  'mintRand'
         41        DO_FCALL                                      0  $15     
         42        SEND_VAR_NO_REF_EX                                       $15
         43        DO_FCALL                                      0          
         44        FREE                                                     ~3
         45      > RETURN                                                   $14
  150    46    >   NEW                          static              $17     
         47        INIT_STATIC_METHOD_CALL                                  'mintName'
         48        FETCH_CLASS_CONSTANT                             ~18     'SHA1'
         49        SEND_VAL_EX                                              ~18
         50        SEND_VAR_EX                                              !1
         51        SEND_VAR_EX                                              !2
         52        DO_FCALL                                      0  $19     
         53        SEND_VAR_NO_REF_EX                                       $19
         54        DO_FCALL                                      0          
         55        FREE                                                     ~3
         56      > RETURN                                                   $17
  152    57    >   NEW                                              $21     'Exception'
         58        SEND_VAL_EX                                              'Selected+version+is+invalid+or+unsupported.'
         59        DO_FCALL                                      0          
         60      > THROW                                         0          $21
         61*       FREE                                                     ~3
  154    62*     > RETURN                                                   null

End of function generate

Function minttime:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L4Er4
function name:  mintTime
number of ops:  87
compiled vars:  !0 = $node, !1 = $time, !2 = $uuid
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  163     0  E >   RECV_INIT                                        !0      null
  170     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 1
          3        DO_ICALL                                         $3      
          4        MUL                                              ~4      $3, 10000000
          5        FETCH_CLASS_CONSTANT                             ~5      'INTERVAL'
          6        ADD                                              ~6      ~4, ~5
          7        ASSIGN                                                   !1, ~6
  173     8        INIT_FCALL                                               'sprintf'
          9        SEND_VAL                                                 '%25F'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $8      
         12        ASSIGN                                                   !1, $8
  176    13        INIT_FCALL                                               'preg_match'
         14        SEND_VAL                                                 '%2F%5E%5Cd%2B%2F'
         15        SEND_VAR                                                 !1
         16        SEND_REF                                                 !1
         17        DO_ICALL                                                 
  179    18        INIT_FCALL                                               'base_convert'
         19        FETCH_DIM_R                                      ~11     !1, 0
         20        SEND_VAL                                                 ~11
         21        SEND_VAL                                                 10
         22        SEND_VAL                                                 16
         23        DO_ICALL                                         $12     
         24        ASSIGN                                                   !1, $12
  180    25        INIT_FCALL                                               'pack'
         26        SEND_VAL                                                 'H%2A'
         27        INIT_FCALL                                               'str_pad'
         28        SEND_VAR                                                 !1
         29        SEND_VAL                                                 16
         30        SEND_VAL                                                 '0'
         31        SEND_VAL                                                 0
         32        DO_ICALL                                         $14     
         33        SEND_VAR                                                 $14
         34        DO_ICALL                                         $15     
         35        ASSIGN                                                   !1, $15
  184    36        FETCH_DIM_R                                      ~17     !1, 0
         37        FETCH_DIM_R                                      ~18     !1, 1
         38        CONCAT                                           ~19     ~17, ~18
         39        FETCH_DIM_R                                      ~20     !1, 2
         40        CONCAT                                           ~21     ~19, ~20
         41        FETCH_DIM_R                                      ~22     !1, 3
         42        CONCAT                                           ~23     ~21, ~22
         43        FETCH_DIM_R                                      ~24     !1, 4
         44        CONCAT                                           ~25     ~23, ~24
         45        FETCH_DIM_R                                      ~26     !1, 5
         46        CONCAT                                           ~27     ~25, ~26
         47        FETCH_DIM_R                                      ~28     !1, 6
         48        CONCAT                                           ~29     ~27, ~28
         49        FETCH_DIM_R                                      ~30     !1, 7
         50        CONCAT                                           ~31     ~29, ~30
         51        ASSIGN                                                   !2, ~31
  187    52        INIT_STATIC_METHOD_CALL                                  'randomBytes'
         53        SEND_VAL_EX                                              2
         54        DO_FCALL                                      0  $33     
         55        ASSIGN_OP                                     8          !2, $33
  190    56        INIT_FCALL                                               'chr'
         57        INIT_FCALL                                               'ord'
         58        FETCH_DIM_R                                      ~36     !2, 8
         59        SEND_VAL                                                 ~36
         60        DO_ICALL                                         $37     
         61        FETCH_CLASS_CONSTANT                             ~38     'CLEAR_VAR'
         62        BW_AND                                           ~39     $37, ~38
         63        FETCH_CLASS_CONSTANT                             ~40     'VAR_RFC'
         64        BW_OR                                            ~41     ~39, ~40
         65        SEND_VAL                                                 ~41
         66        DO_ICALL                                         $42     
         67        ASSIGN_DIM                                               !2, 8
         68        OP_DATA                                                  $42
  193    69        INIT_FCALL                                               'chr'
         70        INIT_FCALL                                               'ord'
         71        FETCH_DIM_R                                      ~44     !2, 6
         72        SEND_VAL                                                 ~44
         73        DO_ICALL                                         $45     
         74        FETCH_CLASS_CONSTANT                             ~46     'CLEAR_VER'
         75        BW_AND                                           ~47     $45, ~46
         76        FETCH_CLASS_CONSTANT                             ~48     'VERSION_1'
         77        BW_OR                                            ~49     ~47, ~48
         78        SEND_VAL                                                 ~49
         79        DO_ICALL                                         $50     
         80        ASSIGN_DIM                                               !2, 6
         81        OP_DATA                                                  $50
  212    82        INIT_FCALL                                               'bindec'
         83        SEND_VAR                                                 !2
         84        DO_ICALL                                         $51     
         85      > RETURN                                                   $51
  213    86*     > RETURN                                                   null

End of function minttime

Function randombytes:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L4Er4
function name:  randomBytes
number of ops:  10
compiled vars:  !0 = $bytes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  221     0  E >   RECV                                             !0      
  223     1        INIT_ARRAY                                       ~1      'static'
          2        INIT_STATIC_METHOD_CALL                                  'initRandom'
          3        DO_FCALL                                      0  $2      
          4        ADD_ARRAY_ELEMENT                                ~1      $2
          5        INIT_USER_CALL                                1          'call_user_func', ~1
          6        SEND_USER                                                !0
          7        DO_FCALL                                      0  $3      
          8      > RETURN                                                   $3
  224     9*     > RETURN                                                   null

End of function randombytes

Function initrandom:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L4Er4
function name:  initRandom
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  235     0  E >   INIT_FCALL                                               'function_exists'
          1        SEND_VAL                                                 'openssl_random_pseudo_bytes'
          2        DO_ICALL                                         $0      
          3      > JMPZ                                                     $0, ->6
  236     4    > > RETURN                                                   'randomOpenSSL'
          5*       JMP                                                      ->11
  237     6    >   INIT_FCALL                                               'function_exists'
          7        SEND_VAL                                                 'mcrypt_encrypt'
          8        DO_ICALL                                         $1      
          9      > JMPZ                                                     $1, ->11
  238    10    > > RETURN                                                   'randomMcrypt'
  242    11    > > RETURN                                                   'randomTwister'
  243    12*     > RETURN                                                   null

End of function initrandom

Function makebin:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L4Er4
function name:  makeBin
number of ops:  35
compiled vars:  !0 = $str, !1 = $len
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  253     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  255     2        INSTANCEOF                                               !0
          3      > JMPZ                                                     ~2, ->6
  256     4    >   FETCH_OBJ_R                                      ~3      !0, 'bytes'
          5      > RETURN                                                   ~3
  258     6    >   STRLEN                                           ~4      !0
          7        IS_IDENTICAL                                             !1, ~4
          8      > JMPZ                                                     ~5, ->11
  259     9    > > RETURN                                                   !0
         10*       JMP                                                      ->17
  262    11    >   INIT_FCALL                                               'preg_replace'
         12        SEND_VAL                                                 '%2F%5Eurn%3Auuid%3A%2Fis'
         13        SEND_VAL                                                 ''
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $6      
         16        ASSIGN                                                   !0, $6
  265    17        INIT_FCALL                                               'preg_replace'
         18        SEND_VAL                                                 '%2F%5B%5Ea-f0-9%5D%2Fis'
         19        SEND_VAL                                                 ''
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                         $8      
         22        ASSIGN                                                   !0, $8
  266    23        STRLEN                                           ~10     !0
         24        MUL                                              ~11     !1, 2
         25        IS_NOT_IDENTICAL                                         ~10, ~11
         26      > JMPZ                                                     ~12, ->29
  267    27    > > RETURN                                                   null
         28*       JMP                                                      ->34
  269    29    >   INIT_FCALL                                               'pack'
         30        SEND_VAL                                                 'H%2A'
         31        SEND_VAR                                                 !0
         32        DO_ICALL                                         $13     
         33      > RETURN                                                   $13
  271    34*     > RETURN                                                   null

End of function makebin

Function mintname:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 38
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
filename:       /in/L4Er4
function name:  mintName
number of ops:  79
compiled vars:  !0 = $ver, !1 = $node, !2 = $ns, !3 = $version, !4 = $uuid
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  283     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
  285     3        ISSET_ISEMPTY_CV                                         !1
          4      > JMPZ                                                     ~5, ->9
  286     5    >   NEW                                              $6      'Exception'
          6        SEND_VAL_EX                                              'A+name-string+is+required+for+Version+3+or+5+UUIDs.'
          7        DO_FCALL                                      0          
          8      > THROW                                         0          $6
  290     9    >   INIT_STATIC_METHOD_CALL                                  'makeBin'
         10        SEND_VAR_EX                                              !2
         11        SEND_VAL_EX                                              16
         12        DO_FCALL                                      0  $8      
         13        ASSIGN                                                   !2, $8
  291    14        TYPE_CHECK                                    2          !2
         15      > JMPZ                                                     ~10, ->20
  292    16    >   NEW                                              $11     'Exception'
         17        SEND_VAL_EX                                              'A+binary+namespace+is+required+for+Version+3+or+5+UUIDs.'
         18        DO_FCALL                                      0          
         19      > THROW                                         0          $11
  295    20    >   ASSIGN                                                   !3, null
  296    21        ASSIGN                                                   !4, null
  299    22        FETCH_CLASS_CONSTANT                             ~16     'MD5'
         23        IS_EQUAL                                                 !0, ~16
         24      > JMPNZ                                                    ~15, ->29
  303    25    >   FETCH_CLASS_CONSTANT                             ~17     'SHA1'
         26        IS_EQUAL                                                 !0, ~17
         27      > JMPNZ                                                    ~15, ->38
         28    > > JMP                                                      ->52
  300    29    >   FETCH_CLASS_CONSTANT                             ~18     'VERSION_3'
         30        ASSIGN                                                   !3, ~18
  301    31        INIT_FCALL                                               'md5'
         32        CONCAT                                           ~20     !2, !1
         33        SEND_VAL                                                 ~20
         34        SEND_VAL                                                 1
         35        DO_ICALL                                         $21     
         36        ASSIGN                                                   !4, $21
  302    37      > JMP                                                

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.87 ms | 1428 KiB | 41 Q