3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public function __call($name, $args) { $method = $name.'_'.join('_', array_map('gettype', $args)); //ugly, but more common: //$method = $name.'_'.md5(serialize(array_map('gettype', $args))); if(method_exists($this, $method)) { return call_user_func_array([$this, $method], $args); } } protected function foo_integer_string($x, $y) { echo('Called method implementation with 1-st (int) and 2-nd (string) parameters'.PHP_EOL); } protected function foo_integer_integer($x, $y) { echo('Called method implementation with 1-st (int) and 2-nd (int) parameters'.PHP_EOL); } } $obj=new Test(); $obj->foo(5, "bar"); $obj->foo(8, 2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZEOE6
function name:  (null)
number of ops:  12
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $1      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   27     3        INIT_METHOD_CALL                                         !0, 'foo'
          4        SEND_VAL_EX                                              5
          5        SEND_VAL_EX                                              'bar'
          6        DO_FCALL                                      0          
   28     7        INIT_METHOD_CALL                                         !0, 'foo'
          8        SEND_VAL_EX                                              8
          9        SEND_VAL_EX                                              2
         10        DO_FCALL                                      0          
         11      > RETURN                                                   1

Class Test:
Function __call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 27
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZEOE6
function name:  __call
number of ops:  28
compiled vars:  !0 = $name, !1 = $args, !2 = $method
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        CONCAT                                           ~3      !0, '_'
          3        INIT_FCALL                                               'join'
          4        SEND_VAL                                                 '_'
          5        INIT_FCALL                                               'array_map'
          6        SEND_VAL                                                 'gettype'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $4      
          9        SEND_VAR                                                 $4
         10        DO_ICALL                                         $5      
         11        CONCAT                                           ~6      ~3, $5
         12        ASSIGN                                                   !2, ~6
    9    13        INIT_FCALL                                               'method_exists'
         14        FETCH_THIS                                       ~8      
         15        SEND_VAL                                                 ~8
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                         $9      
         18      > JMPZ                                                     $9, ->27
   11    19    >   FETCH_THIS                                       ~10     
         20        INIT_ARRAY                                       ~11     ~10
         21        ADD_ARRAY_ELEMENT                                ~11     !2
         22        INIT_USER_CALL                                0          'call_user_func_array', ~11
         23        SEND_ARRAY                                               !1
         24        CHECK_UNDEF_ARGS                                         
         25        DO_FCALL                                      0  $12     
         26      > RETURN                                                   $12
   13    27    > > RETURN                                                   null

End of function __call

Function foo_integer_string:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZEOE6
function name:  foo_integer_string
number of ops:  4
compiled vars:  !0 = $x, !1 = $y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        ECHO                                                     'Called+method+implementation+with+1-st+%28int%29+and+2-nd+%28string%29+parameters%0A'
   18     3      > RETURN                                                   null

End of function foo_integer_string

Function foo_integer_integer:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZEOE6
function name:  foo_integer_integer
number of ops:  4
compiled vars:  !0 = $x, !1 = $y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   22     2        ECHO                                                     'Called+method+implementation+with+1-st+%28int%29+and+2-nd+%28int%29+parameters%0A'
   23     3      > RETURN                                                   null

End of function foo_integer_integer

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.13 ms | 1400 KiB | 19 Q