3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class CommandId { private $name; private $time; private $hash; public function __construct($name) { $this->time = microtime(true); $this->name = trim($name); $this->hash = hash('crc32', rand(0, $this->time)); if (empty($this->name)) { throw new DomainException('Name must not be empty'); } } public static function fromString($idString) { $parts = explode('_', $idString); if (count($parts) != 3) { throw new DomainException("Unexpected format [$idString]"); } $id = new static($parts[0]); $id->time = (float) $parts[1]; $id->hash = $parts[2]; return $id; } public function name() { return $this->name; } public function time() { return $this->time; } public function __toString() { return "{$this->name}_{$this->time}_{$this->hash}"; } } $one = new CommandId('foo'); $two = new CommandId('foo'); assert($one != $two); var_dump($one, $two, (string) $one, (string) $two);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/E20X5
function name:  (null)
number of ops:  24
compiled vars:  !0 = $one, !1 = $two
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'commandid'
   49     1        NEW                                              $2      'CommandId'
          2        SEND_VAL_EX                                              'foo'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   50     5        NEW                                              $5      'CommandId'
          6        SEND_VAL_EX                                              'foo'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $5
   51     9        ASSERT_CHECK                                             
         10        INIT_FCALL                                               'assert'
         11        IS_NOT_EQUAL                                     ~8      !0, !1
         12        SEND_VAL                                                 ~8
         13        SEND_VAL                                                 'assert%28%24one+%21%3D+%24two%29'
         14        DO_ICALL                                                 
   53    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !0
         17        SEND_VAR                                                 !1
         18        CAST                                          6  ~10     !0
         19        SEND_VAL                                                 ~10
         20        CAST                                          6  ~11     !1
         21        SEND_VAL                                                 ~11
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Class CommandId:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 28
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
filename:       /in/E20X5
function name:  __construct
number of ops:  29
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $2      
          4        ASSIGN_OBJ                                               'time'
          5        OP_DATA                                                  $2
   12     6        INIT_FCALL                                               'trim'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $4      
          9        ASSIGN_OBJ                                               'name'
         10        OP_DATA                                                  $4
   13    11        INIT_FCALL                                               'hash'
         12        SEND_VAL                                                 'crc32'
         13        INIT_FCALL                                               'rand'
         14        SEND_VAL                                                 0
         15        FETCH_OBJ_R                                      ~6      'time'
         16        SEND_VAL                                                 ~6
         17        DO_ICALL                                         $7      
         18        SEND_VAR                                                 $7
         19        DO_ICALL                                         $8      
         20        ASSIGN_OBJ                                               'hash'
         21        OP_DATA                                                  $8
   15    22        ISSET_ISEMPTY_PROP_OBJ                                   'name'
         23      > JMPZ                                                     ~9, ->28
   16    24    >   NEW                                              $10     'DomainException'
         25        SEND_VAL_EX                                              'Name+must+not+be+empty'
         26        DO_FCALL                                      0          
         27      > THROW                                         0          $10
   18    28    > > RETURN                                                   null

End of function __construct

Function fromstring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/E20X5
function name:  fromString
number of ops:  31
compiled vars:  !0 = $idString, !1 = $parts, !2 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   22     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '_'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
   23     6        COUNT                                            ~5      !1
          7        IS_NOT_EQUAL                                             ~5, 3
          8      > JMPZ                                                     ~6, ->16
   24     9    >   NEW                                              $7      'DomainException'
         10        ROPE_INIT                                     3  ~9      'Unexpected+format+%5B'
         11        ROPE_ADD                                      1  ~9      ~9, !0
         12        ROPE_END                                      2  ~8      ~9, '%5D'
         13        SEND_VAL_EX                                              ~8
         14        DO_FCALL                                      0          
         15      > THROW                                         0          $7
   26    16    >   NEW                          static              $12     
         17        CHECK_FUNC_ARG                                           
         18        FETCH_DIM_FUNC_ARG                               $13     !1, 0
         19        SEND_FUNC_ARG                                            $13
         20        DO_FCALL                                      0          
         21        ASSIGN                                                   !2, $12
   27    22        FETCH_DIM_R                                      ~17     !1, 1
         23        CAST                                          5  ~18     ~17
         24        ASSIGN_OBJ                                               !2, 'time'
         25        OP_DATA                                                  ~18
   28    26        FETCH_DIM_R                                      ~20     !1, 2
         27        ASSIGN_OBJ                                               !2, 'hash'
         28        OP_DATA                                                  ~20
   30    29      > RETURN                                                   !2
   31    30*     > RETURN                                                   null

End of function fromstring

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

End of function name

Function time:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/E20X5
function name:  time
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   FETCH_OBJ_R                                      ~0      'time'
          1      > RETURN                                                   ~0
   41     2*     > RETURN                                                   null

End of function time

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/E20X5
function name:  __toString
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   FETCH_OBJ_R                                      ~0      'name'
          1        ROPE_INIT                                     5  ~4      ~0
          2        ROPE_ADD                                      1  ~4      ~4, '_'
          3        FETCH_OBJ_R                                      ~1      'time'
          4        ROPE_ADD                                      2  ~4      ~4, ~1
          5        ROPE_ADD                                      3  ~4      ~4, '_'
          6        FETCH_OBJ_R                                      ~2      'hash'
          7        ROPE_END                                      4  ~3      ~4, ~2
          8        VERIFY_RETURN_TYPE                                       ~3
          9      > RETURN                                                   ~3
   46    10*       VERIFY_RETURN_TYPE                                       
         11*     > RETURN                                                   null

End of function __tostring

End of class CommandId.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.91 ms | 1396 KiB | 27 Q