3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function __construct() { $args = func_get_args(); switch (count($args)) { case 2: return call_user_func_array(array($this, 'constr2'), $args); //break; case 1: return call_user_func_array(array($this, 'constr1'), $args); break; } throw new Exception("invalid number of arguments"); } protected function constr1($a) { print "constr1 called\n"; } protected function constr2($a, $b) { print "constr2 called\n"; } } $a = new Foo(2); $b = new Foo(2, 3); $c = new Foo("a", "b", 3);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eHb0e
function name:  (null)
number of ops:  16
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   NEW                                              $3      'Foo'
          1        SEND_VAL_EX                                              2
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   25     4        NEW                                              $6      'Foo'
          5        SEND_VAL_EX                                              2
          6        SEND_VAL_EX                                              3
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $6
   26     9        NEW                                              $9      'Foo'
         10        SEND_VAL_EX                                              'a'
         11        SEND_VAL_EX                                              'b'
         12        SEND_VAL_EX                                              3
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !2, $9
         15      > RETURN                                                   1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 17
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eHb0e
function name:  __construct
number of ops:  33
compiled vars:  !0 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   FUNC_GET_ARGS                                    ~1      
          1        ASSIGN                                                   !0, ~1
    6     2        COUNT                                            ~3      !0
    7     3        CASE                                                     ~3, 2
          4      > JMPNZ                                                    ~4, ->8
   10     5    >   CASE                                                     ~3, 1
          6      > JMPNZ                                                    ~4, ->17
          7    > > JMP                                                      ->27
    8     8    >   FETCH_THIS                                       ~5      
          9        INIT_ARRAY                                       ~6      ~5
         10        ADD_ARRAY_ELEMENT                                ~6      'constr2'
         11        INIT_USER_CALL                                0          'call_user_func_array', ~6
         12        SEND_ARRAY                                               !0
         13        CHECK_UNDEF_ARGS                                         
         14        DO_FCALL                                      0  $7      
         15        FREE                                                     ~3
         16      > RETURN                                                   $7
   11    17    >   FETCH_THIS                                       ~8      
         18        INIT_ARRAY                                       ~9      ~8
         19        ADD_ARRAY_ELEMENT                                ~9      'constr1'
         20        INIT_USER_CALL                                0          'call_user_func_array', ~9
         21        SEND_ARRAY                                               !0
         22        CHECK_UNDEF_ARGS                                         
         23        DO_FCALL                                      0  $10     
         24        FREE                                                     ~3
         25      > RETURN                                                   $10
   12    26*       JMP                                                      ->27
         27    >   FREE                                                     ~3
   14    28        NEW                                              $11     'Exception'
         29        SEND_VAL_EX                                              'invalid+number+of+arguments'
         30        DO_FCALL                                      0          
         31      > THROW                                         0          $11
   15    32*     > RETURN                                                   null

End of function __construct

Function constr1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eHb0e
function name:  constr1
number of ops:  3
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1        ECHO                                                     'constr1+called%0A'
   18     2      > RETURN                                                   null

End of function constr1

Function constr2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eHb0e
function name:  constr2
number of ops:  4
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   20     2        ECHO                                                     'constr2+called%0A'
   21     3      > RETURN                                                   null

End of function constr2

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.77 ms | 1399 KiB | 13 Q