3v4l.org

run code in 300+ PHP versions simultaneously
<?php $wp_version = '6.2.0'; // WP Core code. class Foo { public function __call( $name, $arguments ) { if ( 'new_method_A' === $name || 'new_method_B' === $name || 'new_method_C' === $name ) { return $this->$name( ...$arguments ); } $class = get_class( $this ); $trace = debug_backtrace(); $file = $trace[0]['file']; $line = $trace[0]['line']; throw new BadMethodCallException( "Call to undefined method $class::$name() in $file on line $line" ); } private function new_method_A() { echo __FUNCTION__, ' called!', PHP_EOL; } private function new_method_B() { echo __FUNCTION__, ' called!', PHP_EOL; } public function new_method_C() { echo __FUNCTION__, ' called!', PHP_EOL; } } // Plugin code. $obj = new Foo(); try { $obj->new_method_A(); $obj->new_method_B(); $obj->new_method_C(); } catch(BadMethodCallException $e) { // Do it some other way to support older WP versions. } finally { // Do something with the output of the methods, no matter whether it was created via the code in `try` or the code in `catch`. }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 162) Position 1 = 14, Position 2 = 13
Branch analysis from position: 14
1 jumps found. (Code = 163) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 11
Branch analysis from position: 11
2 jumps found. (Code = 107) Position 1 = 12, Position 2 = -2
Branch analysis from position: 12
filename:       /in/XtmLn
function name:  (null)
number of ops:  16
compiled vars:  !0 = $wp_version, !1 = $obj, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '6.2.0'
   35     1        NEW                                              $4      'Foo'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $4
   37     4        INIT_METHOD_CALL                                         !1, 'new_method_A'
          5        DO_FCALL                                      0          
   38     6        INIT_METHOD_CALL                                         !1, 'new_method_B'
          7        DO_FCALL                                      0          
   39     8        INIT_METHOD_CALL                                         !1, 'new_method_C'
          9        DO_FCALL                                      0          
         10      > JMP                                                      ->12
   40    11  E > > CATCH                                       last         'BadMethodCallException'
   42    12    > > FAST_CALL                                                ->14
         13    > > JMP                                                      ->15
         14    > > FAST_RET                                                 
   44    15    > > RETURN                                                   1

Class Foo:
Function __call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
2 jumps found. (Code = 47) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 9
Branch analysis from position: 6
filename:       /in/XtmLn
function name:  __call
number of ops:  40
compiled vars:  !0 = $name, !1 = $arguments, !2 = $class, !3 = $trace, !4 = $file, !5 = $line
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        IS_IDENTICAL                                     ~6      !0, 'new_method_A'
          3      > JMPNZ_EX                                         ~6      ~6, ->6
    8     4    >   IS_IDENTICAL                                     ~7      !0, 'new_method_B'
          5        BOOL                                             ~6      ~7
          6    > > JMPNZ_EX                                         ~6      ~6, ->9
    9     7    >   IS_IDENTICAL                                     ~8      !0, 'new_method_C'
          8        BOOL                                             ~6      ~8
          9    > > JMPZ                                                     ~6, ->15
   11    10    >   INIT_METHOD_CALL                                         !0
         11        SEND_UNPACK                                              !1
         12        CHECK_UNDEF_ARGS                                         
         13        DO_FCALL                                      1  $9      
         14      > RETURN                                                   $9
   14    15    >   FETCH_THIS                                       ~10     
         16        GET_CLASS                                        ~11     ~10
         17        ASSIGN                                                   !2, ~11
   15    18        INIT_FCALL                                               'debug_backtrace'
         19        DO_ICALL                                         $13     
         20        ASSIGN                                                   !3, $13
   16    21        FETCH_DIM_R                                      ~15     !3, 0
         22        FETCH_DIM_R                                      ~16     ~15, 'file'
         23        ASSIGN                                                   !4, ~16
   17    24        FETCH_DIM_R                                      ~18     !3, 0
         25        FETCH_DIM_R                                      ~19     ~18, 'line'
         26        ASSIGN                                                   !5, ~19
   18    27        NEW                                              $21     'BadMethodCallException'
         28        ROPE_INIT                                     8  ~23     'Call+to+undefined+method+'
         29        ROPE_ADD                                      1  ~23     ~23, !2
         30        ROPE_ADD                                      2  ~23     ~23, '%3A%3A'
         31        ROPE_ADD                                      3  ~23     ~23, !0
         32        ROPE_ADD                                      4  ~23     ~23, '%28%29+in+'
         33        ROPE_ADD                                      5  ~23     ~23, !4
         34        ROPE_ADD                                      6  ~23     ~23, '+on+line+'
         35        ROPE_END                                      7  ~22     ~23, !5
         36        SEND_VAL_EX                                              ~22
         37        DO_FCALL                                      0          
         38      > THROW                                         0          $21
   19    39*     > RETURN                                                   null

End of function __call

Function new_method_a:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XtmLn
function name:  new_method_A
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   ECHO                                                     'new_method_A'
          1        ECHO                                                     '+called%21'
          2        ECHO                                                     '%0A'
   23     3      > RETURN                                                   null

End of function new_method_a

Function new_method_b:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XtmLn
function name:  new_method_B
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   ECHO                                                     'new_method_B'
          1        ECHO                                                     '+called%21'
          2        ECHO                                                     '%0A'
   27     3      > RETURN                                                   null

End of function new_method_b

Function new_method_c:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XtmLn
function name:  new_method_C
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   ECHO                                                     'new_method_C'
          1        ECHO                                                     '+called%21'
          2        ECHO                                                     '%0A'
   31     3      > RETURN                                                   null

End of function new_method_c

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.45 ms | 1404 KiB | 15 Q