3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function sing() { var_dump('Do re mi!'); } public function dance() { var_dump('Cha cha cha!'); } } function gimmeFoo(Foo $foo) { $foo->sing(); $foo->dance(); } $gimmeWhat = new ReflectionFunction('gimmeFoo'); $class = $gimmeWhat->getParameters()[0]->getClass(); $methods = $class->getMethods(); $evil = " class Fake extends $class->name { public function idoeverything() { var_dump('Just kidding!'); } "; foreach ($methods as $method) { $evil .= "public function $method->name() {\$this->idoeverything();}"; } $evil .= "}"; eval($evil); $fake = new Fake; gimmeFoo($fake);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 26
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 26
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/uMXpl
function name:  (null)
number of ops:  36
compiled vars:  !0 = $gimmeWhat, !1 = $class, !2 = $methods, !3 = $evil, !4 = $method, !5 = $fake
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $6      'ReflectionFunction'
          1        SEND_VAL_EX                                              'gimmeFoo'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $6
   23     4        INIT_METHOD_CALL                                         !0, 'getParameters'
          5        DO_FCALL                                      0  $9      
          6        FETCH_DIM_R                                      ~10     $9, 0
          7        INIT_METHOD_CALL                                         ~10, 'getClass'
          8        DO_FCALL                                      0  $11     
          9        ASSIGN                                                   !1, $11
   24    10        INIT_METHOD_CALL                                         !1, 'getMethods'
         11        DO_FCALL                                      0  $13     
         12        ASSIGN                                                   !2, $13
   25    13        ROPE_INIT                                     3  ~17     '%0A++++class+Fake+extends+'
   26    14        FETCH_OBJ_R                                      ~15     !1, 'name'
         15        ROPE_ADD                                      1  ~17     ~17, ~15
         16        ROPE_END                                      2  ~16     ~17, '%0A++++%7B%0A++++++++public+function+idoeverything%28%29+%7B%0A++++++++++++var_dump%28%27Just+kidding%21%27%29%3B%0A++++++++%7D%0A'
   25    17        ASSIGN                                                   !3, ~16
   33    18      > FE_RESET_R                                       $20     !2, ->26
         19    > > FE_FETCH_R                                               $20, !4, ->26
   34    20    >   ROPE_INIT                                     3  ~23     'public+function+'
         21        FETCH_OBJ_R                                      ~21     !4, 'name'
         22        ROPE_ADD                                      1  ~23     ~23, ~21
         23        ROPE_END                                      2  ~22     ~23, '%28%29+%7B%24this-%3Eidoeverything%28%29%3B%7D'
         24        ASSIGN_OP                                     8          !3, ~22
   33    25      > JMP                                                      ->19
         26    >   FE_FREE                                                  $20
   37    27        ASSIGN_OP                                     8          !3, '%7D'
   39    28        INCLUDE_OR_EVAL                                          !3, EVAL
   41    29        NEW                                              $28     'Fake'
         30        DO_FCALL                                      0          
         31        ASSIGN                                                   !5, $28
   43    32        INIT_FCALL                                               'gimmefoo'
         33        SEND_VAR                                                 !5
         34        DO_FCALL                                      0          
         35      > RETURN                                                   1

Function gimmefoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uMXpl
function name:  gimmeFoo
number of ops:  6
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        INIT_METHOD_CALL                                         !0, 'sing'
          2        DO_FCALL                                      0          
   18     3        INIT_METHOD_CALL                                         !0, 'dance'
          4        DO_FCALL                                      0          
   19     5      > RETURN                                                   null

End of function gimmefoo

Class Foo:
Function sing:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uMXpl
function name:  sing
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 'Do+re+mi%21'
          2        DO_ICALL                                                 
    8     3      > RETURN                                                   null

End of function sing

Function dance:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uMXpl
function name:  dance
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 'Cha+cha+cha%21'
          2        DO_ICALL                                                 
   12     3      > RETURN                                                   null

End of function dance

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.99 ms | 1403 KiB | 16 Q