3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class CommandId { private $name; private $time; public function __construct($name) { $this->time = microtime(true); $this->name = trim($name); if (empty($this->name)) { throw new DomainException('Name must not be empty'); } } public static function fromString($idString) { $parts = explode('_', $idString); if (count($parts) != 2) { throw new DomainException("Unexpected format [$idString]"); } $id = new static($parts[0]); $id->time = (float) $parts[1]; return $id; } public function name() { return $this->name; } public function time() { return $this->time; } public function __toString() { return "{$this->name}_{$this->time}"; } } $one = new CommandId('foo'); $two = new CommandId('foo'); assert($one != $two, 'one should not equal 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/4S1Y5
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'
   46     1        NEW                                              $2      'CommandId'
          2        SEND_VAL_EX                                              'foo'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   47     5        NEW                                              $5      'CommandId'
          6        SEND_VAL_EX                                              'foo'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $5
   48     9        ASSERT_CHECK                                             
         10        INIT_FCALL                                               'assert'
         11        IS_NOT_EQUAL                                     ~8      !0, !1
         12        SEND_VAL                                                 ~8
         13        SEND_VAL                                                 'one+should+not+equal+two'
         14        DO_ICALL                                                 
   50    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 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4S1Y5
function name:  __construct
number of ops:  18
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $2      
          4        ASSIGN_OBJ                                               'time'
          5        OP_DATA                                                  $2
   11     6        INIT_FCALL                                               'trim'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $4      
          9        ASSIGN_OBJ                                               'name'
         10        OP_DATA                                                  $4
   13    11        ISSET_ISEMPTY_PROP_OBJ                                   'name'
         12      > JMPZ                                                     ~5, ->17
   14    13    >   NEW                                              $6      'DomainException'
         14        SEND_VAL_EX                                              'Name+must+not+be+empty'
         15        DO_FCALL                                      0          
         16      > THROW                                         0          $6
   16    17    > > 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/4S1Y5
function name:  fromString
number of ops:  28
compiled vars:  !0 = $idString, !1 = $parts, !2 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '_'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
   21     6        COUNT                                            ~5      !1
          7        IS_NOT_EQUAL                                             ~5, 2
          8      > JMPZ                                                     ~6, ->16
   22     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
   24    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
   25    22        FETCH_DIM_R                                      ~17     !1, 1
         23        CAST                                          5  ~18     ~17
         24        ASSIGN_OBJ                                               !2, 'time'
         25        OP_DATA                                                  ~18
   27    26      > RETURN                                                   !2
   28    27*     > 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/4S1Y5
function name:  name
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   FETCH_OBJ_R                                      ~0      'name'
          1      > RETURN                                                   ~0
   33     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/4S1Y5
function name:  time
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   FETCH_OBJ_R                                      ~0      'time'
          1      > RETURN                                                   ~0
   38     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/4S1Y5
function name:  __toString
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   FETCH_OBJ_R                                      ~0      'name'
          1        ROPE_INIT                                     3  ~3      ~0
          2        ROPE_ADD                                      1  ~3      ~3, '_'
          3        FETCH_OBJ_R                                      ~1      'time'
          4        ROPE_END                                      2  ~2      ~3, ~1
          5        VERIFY_RETURN_TYPE                                       ~2
          6      > RETURN                                                   ~2
   43     7*       VERIFY_RETURN_TYPE                                       
          8*     > RETURN                                                   null

End of function __tostring

End of class CommandId.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.9 ms | 1404 KiB | 23 Q