3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_cc() { $calls = debug_backtrace(); if (!isset($calls[1])) { return NULL; } $call = $calls[1]; var_dump($call); if (isset($call['object'])) { return get_class($call['object']); } elseif (isset($call['class'])) { return $call['class']; } } class Bar { public function bar() { return get_cc(); } public static function baz() { return get_cc(); } } class Foo extends Bar { } $bar = new Bar; echo ($bar->bar() === 'Bar' ? 'OK' : 'FAIL'), "\n<br>"; echo (Bar::baz() === 'Bar' ? 'OK' : 'FAIL'), "\n<br>"; $foo = new Foo; echo ($foo->bar() === 'Foo' ? 'OK' : 'FAIL'), "\n<br>"; echo (Foo::baz() === 'Foo' ? 'OK' : 'FAIL'), "\n<br>"; echo (get_cc() === NULL ? 'OK' : 'FAIL'), "\n<br>";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 39
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 48
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 48
Branch analysis from position: 46
Branch analysis from position: 48
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 39
Branch analysis from position: 37
Branch analysis from position: 39
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
Branch analysis from position: 30
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
Branch analysis from position: 18
filename:       /in/ZMHDn
function name:  (null)
number of ops:  52
compiled vars:  !0 = $bar, !1 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   NEW                                              $2      'Bar'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   44     3        INIT_METHOD_CALL                                         !0, 'bar'
          4        DO_FCALL                                      0  $5      
          5        IS_IDENTICAL                                             $5, 'Bar'
          6      > JMPZ                                                     ~6, ->9
          7    >   QM_ASSIGN                                        ~7      'OK'
          8      > JMP                                                      ->10
          9    >   QM_ASSIGN                                        ~7      'FAIL'
         10    >   ECHO                                                     ~7
         11        ECHO                                                     '%0A%3Cbr%3E'
   45    12        INIT_STATIC_METHOD_CALL                                  'Bar', 'baz'
         13        DO_FCALL                                      0  $8      
         14        IS_IDENTICAL                                             $8, 'Bar'
         15      > JMPZ                                                     ~9, ->18
         16    >   QM_ASSIGN                                        ~10     'OK'
         17      > JMP                                                      ->19
         18    >   QM_ASSIGN                                        ~10     'FAIL'
         19    >   ECHO                                                     ~10
         20        ECHO                                                     '%0A%3Cbr%3E'
   47    21        NEW                                              $11     'Foo'
         22        DO_FCALL                                      0          
         23        ASSIGN                                                   !1, $11
   48    24        INIT_METHOD_CALL                                         !1, 'bar'
         25        DO_FCALL                                      0  $14     
         26        IS_IDENTICAL                                             $14, 'Foo'
         27      > JMPZ                                                     ~15, ->30
         28    >   QM_ASSIGN                                        ~16     'OK'
         29      > JMP                                                      ->31
         30    >   QM_ASSIGN                                        ~16     'FAIL'
         31    >   ECHO                                                     ~16
         32        ECHO                                                     '%0A%3Cbr%3E'
   49    33        INIT_STATIC_METHOD_CALL                                  'Foo', 'baz'
         34        DO_FCALL                                      0  $17     
         35        IS_IDENTICAL                                             $17, 'Foo'
         36      > JMPZ                                                     ~18, ->39
         37    >   QM_ASSIGN                                        ~19     'OK'
         38      > JMP                                                      ->40
         39    >   QM_ASSIGN                                        ~19     'FAIL'
         40    >   ECHO                                                     ~19
         41        ECHO                                                     '%0A%3Cbr%3E'
   51    42        INIT_FCALL                                               'get_cc'
         43        DO_FCALL                                      0  $20     
         44        TYPE_CHECK                                    2          $20
         45      > JMPZ                                                     ~21, ->48
         46    >   QM_ASSIGN                                        ~22     'OK'
         47      > JMP                                                      ->49
         48    >   QM_ASSIGN                                        ~22     'FAIL'
         49    >   ECHO                                                     ~22
         50        ECHO                                                     '%0A%3Cbr%3E'
         51      > RETURN                                                   1

Function get_cc:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZMHDn
function name:  get_cc
number of ops:  23
compiled vars:  !0 = $calls, !1 = $call
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL                                               'debug_backtrace'
          1        DO_ICALL                                         $2      
          2        ASSIGN                                                   !0, $2
    6     3        ISSET_ISEMPTY_DIM_OBJ                         0  ~4      !0, 1
          4        BOOL_NOT                                         ~5      ~4
          5      > JMPZ                                                     ~5, ->7
    7     6    > > RETURN                                                   null
    9     7    >   FETCH_DIM_R                                      ~6      !0, 1
          8        ASSIGN                                                   !1, ~6
   10     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
   11    12        ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'object'
         13      > JMPZ                                                     ~9, ->18
   12    14    >   FETCH_DIM_R                                      ~10     !1, 'object'
         15        GET_CLASS                                        ~11     ~10
         16      > RETURN                                                   ~11
         17*       JMP                                                      ->22
   14    18    >   ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'class'
         19      > JMPZ                                                     ~12, ->22
   15    20    >   FETCH_DIM_R                                      ~13     !1, 'class'
         21      > RETURN                                                   ~13
   18    22    > > RETURN                                                   null

End of function get_cc

Class Bar:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZMHDn
function name:  bar
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'get_cc'
          1        DO_FCALL                                      0  $0      
          2      > RETURN                                                   $0
   28     3*     > RETURN                                                   null

End of function bar

Function baz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZMHDn
function name:  baz
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   INIT_FCALL                                               'get_cc'
          1        DO_FCALL                                      0  $0      
          2      > RETURN                                                   $0
   33     3*     > RETURN                                                   null

End of function baz

End of class Bar.

Class Foo:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZMHDn
function name:  bar
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'get_cc'
          1        DO_FCALL                                      0  $0      
          2      > RETURN                                                   $0
   28     3*     > RETURN                                                   null

End of function bar

Function baz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZMHDn
function name:  baz
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   INIT_FCALL                                               'get_cc'
          1        DO_FCALL                                      0  $0      
          2      > RETURN                                                   $0
   33     3*     > RETURN                                                   null

End of function baz

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.53 ms | 1406 KiB | 22 Q