3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class Time { private $hours, $minutes; public function __construct($hours, $minutes) { $this->hours = (int) $hours; $this->minutes = (int) $minutes; } public static function fromString($time) { list($hours, $minutes) = explode($time, ':', 2); return new static($hours, $minutes); } public static function fromString2($time) { list($hours, $minutes) = explode($time, ':', 2); return new self($hours, $minutes); } } var_dump(Time::fromString('10:45')); var_dump(Time::fromString2('10:45'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qveIb
function name:  (null)
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_STATIC_METHOD_CALL                                  'Time', 'fromString'
          2        SEND_VAL                                                 '10%3A45'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   27     6        INIT_FCALL                                               'var_dump'
          7        INIT_STATIC_METHOD_CALL                                  'Time', 'fromString2'
          8        SEND_VAL                                                 '10%3A45'
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

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

End of function __construct

Function fromstring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qveIb
function name:  fromString
number of ops:  17
compiled vars:  !0 = $time, !1 = $hours, !2 = $minutes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        INIT_FCALL                                               'explode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '%3A'
          4        SEND_VAL                                                 2
          5        DO_ICALL                                         $3      
          6        FETCH_LIST_R                                     $4      $3, 0
          7        ASSIGN                                                   !1, $4
          8        FETCH_LIST_R                                     $6      $3, 1
          9        ASSIGN                                                   !2, $6
         10        FREE                                                     $3
   16    11        NEW                          static              $8      
         12        SEND_VAR_EX                                              !1
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0          
         15      > RETURN                                                   $8
   17    16*     > RETURN                                                   null

End of function fromstring

Function fromstring2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qveIb
function name:  fromString2
number of ops:  17
compiled vars:  !0 = $time, !1 = $hours, !2 = $minutes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   21     1        INIT_FCALL                                               'explode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '%3A'
          4        SEND_VAL                                                 2
          5        DO_ICALL                                         $3      
          6        FETCH_LIST_R                                     $4      $3, 0
          7        ASSIGN                                                   !1, $4
          8        FETCH_LIST_R                                     $6      $3, 1
          9        ASSIGN                                                   !2, $6
         10        FREE                                                     $3
   22    11        NEW                          self                $8      
         12        SEND_VAR_EX                                              !1
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0          
         15      > RETURN                                                   $8
   23    16*     > RETURN                                                   null

End of function fromstring2

End of class Time.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.02 ms | 1392 KiB | 17 Q