3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Guid { private $guid = ''; public function __construct($guid) { $this->guid = $guid; } public static function newGuid() { return new Guid('35918bc9-196d-40ea-9779-889d79b753f0'); } public function __toString() { return $this->guid; } public function toByteArray() { $str = str_replace('-', '', $this->guid); $ints = array_map('hexdec', str_split($str, 2)); // swap $newints = $ints; $newints[0] = $ints[3]; $newints[1] = $ints[2]; $newints[2] = $ints[1]; $newints[3] = $ints[0]; $newints[4] = $ints[5]; $newints[5] = $ints[4]; $newints[6] = $ints[7]; $newints[7] = $ints[6]; return implode('', array_map('chr', $newints)); } public function printBytes($bytes) { for ($i = 0; $i < strlen($bytes); $i++) { echo strtoupper(dechex(ord($bytes[$i]))).' '; } echo "\n"; } } $guid = Guid::newGuid(); $str = $guid->toByteArray(); $guid->printBytes($str);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/thsIe
function name:  (null)
number of ops:  11
compiled vars:  !0 = $guid, !1 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'guid'
   47     1        INIT_STATIC_METHOD_CALL                                  'Guid', 'newGuid'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !0, $2
   48     4        INIT_METHOD_CALL                                         !0, 'toByteArray'
          5        DO_FCALL                                      0  $4      
          6        ASSIGN                                                   !1, $4
   49     7        INIT_METHOD_CALL                                         !0, 'printBytes'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10      > RETURN                                                   1

Class Guid:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/thsIe
function name:  __construct
number of ops:  4
compiled vars:  !0 = $guid
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        ASSIGN_OBJ                                               'guid'
          2        OP_DATA                                                  !0
    8     3      > RETURN                                                   null

End of function __construct

Function newguid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/thsIe
function name:  newGuid
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   NEW                                              $0      'Guid'
          1        SEND_VAL_EX                                              '35918bc9-196d-40ea-9779-889d79b753f0'
          2        DO_FCALL                                      0          
          3      > RETURN                                                   $0
   13     4*     > RETURN                                                   null

End of function newguid

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/thsIe
function name:  __toString
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   FETCH_OBJ_R                                      ~0      'guid'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   18     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function __tostring

Function tobytearray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/thsIe
function name:  toByteArray
number of ops:  51
compiled vars:  !0 = $str, !1 = $ints, !2 = $newints
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL                                               'str_replace'
          1        SEND_VAL                                                 '-'
          2        SEND_VAL                                                 ''
          3        FETCH_OBJ_R                                      ~3      'guid'
          4        SEND_VAL                                                 ~3
          5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !0, $4
   23     7        INIT_FCALL                                               'array_map'
          8        SEND_VAL                                                 'hexdec'
          9        INIT_FCALL                                               'str_split'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 2
         12        DO_ICALL                                         $6      
         13        SEND_VAR                                                 $6
         14        DO_ICALL                                         $7      
         15        ASSIGN                                                   !1, $7
   25    16        ASSIGN                                                   !2, !1
   26    17        FETCH_DIM_R                                      ~11     !1, 3
         18        ASSIGN_DIM                                               !2, 0
         19        OP_DATA                                                  ~11
   27    20        FETCH_DIM_R                                      ~13     !1, 2
         21        ASSIGN_DIM                                               !2, 1
         22        OP_DATA                                                  ~13
   28    23        FETCH_DIM_R                                      ~15     !1, 1
         24        ASSIGN_DIM                                               !2, 2
         25        OP_DATA                                                  ~15
   29    26        FETCH_DIM_R                                      ~17     !1, 0
         27        ASSIGN_DIM                                               !2, 3
         28        OP_DATA                                                  ~17
   30    29        FETCH_DIM_R                                      ~19     !1, 5
         30        ASSIGN_DIM                                               !2, 4
         31        OP_DATA                                                  ~19
   31    32        FETCH_DIM_R                                      ~21     !1, 4
         33        ASSIGN_DIM                                               !2, 5
         34        OP_DATA                                                  ~21
   32    35        FETCH_DIM_R                                      ~23     !1, 7
         36        ASSIGN_DIM                                               !2, 6
         37        OP_DATA                                                  ~23
   33    38        FETCH_DIM_R                                      ~25     !1, 6
         39        ASSIGN_DIM                                               !2, 7
         40        OP_DATA                                                  ~25
   35    41        INIT_FCALL                                               'implode'
         42        SEND_VAL                                                 ''
         43        INIT_FCALL                                               'array_map'
         44        SEND_VAL                                                 'chr'
         45        SEND_VAR                                                 !2
         46        DO_ICALL                                         $26     
         47        SEND_VAR                                                 $26
         48        DO_ICALL                                         $27     
         49      > RETURN                                                   $27
   36    50*     > RETURN                                                   null

End of function tobytearray

Function printbytes:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 3
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 3
Branch analysis from position: 19
Branch analysis from position: 3
filename:       /in/thsIe
function name:  printBytes
number of ops:  21
compiled vars:  !0 = $bytes, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
   40     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->16
   41     3    >   INIT_FCALL                                               'strtoupper'
          4        INIT_FCALL                                               'dechex'
          5        INIT_FCALL                                               'ord'
          6        FETCH_DIM_R                                      ~3      !0, !1
          7        SEND_VAL                                                 ~3
          8        DO_ICALL                                         $4      
          9        SEND_VAR                                                 $4
         10        DO_ICALL                                         $5      
         11        SEND_VAR                                                 $5
         12        DO_ICALL                                         $6      
         13        CONCAT                                           ~7      $6, '+'
         14        ECHO                                                     ~7
   40    15        PRE_INC                                                  !1
         16    >   STRLEN                                           ~9      !0
         17        IS_SMALLER                                               !1, ~9
         18      > JMPNZ                                                    ~10, ->3
   43    19    >   ECHO                                                     '%0A'
   44    20      > RETURN                                                   null

End of function printbytes

End of class Guid.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.21 ms | 1404 KiB | 27 Q