3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_caller(): ?object { foreach (debug_backtrace() as $call) { if (isset($call['object'])) { return $call['object']; } } return null; } function foo(): void { var_dump(get_caller()); } class Bar { public function __construct() { var_dump(get_caller()); new Baz(); } } class Baz { public function __construct() { foo(); } } foo(); new Bar();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6WG9i
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   INIT_FCALL                                               'foo'
          1        DO_FCALL                                      0          
   38     2        NEW                                              $1      'Bar'
          3        DO_FCALL                                      0          
          4        FREE                                                     $1
          5      > RETURN                                                   1

Function get_caller:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/6WG9i
function name:  get_caller
number of ops:  15
compiled vars:  !0 = $call
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL                                               'debug_backtrace'
          1        DO_ICALL                                         $1      
          2      > FE_RESET_R                                       $2      $1, ->11
          3    > > FE_FETCH_R                                               $2, !0, ->11
    6     4    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, 'object'
          5      > JMPZ                                                     ~3, ->10
    7     6    >   FETCH_DIM_R                                      ~4      !0, 'object'
          7        VERIFY_RETURN_TYPE                                       ~4
          8        FE_FREE                                                  $2
          9      > RETURN                                                   ~4
    5    10    > > JMP                                                      ->3
         11    >   FE_FREE                                                  $2
   11    12      > RETURN                                                   null
   12    13*       VERIFY_RETURN_TYPE                                       
         14*     > RETURN                                                   null

End of function get_caller

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6WG9i
function name:  foo
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'get_caller'
          2        DO_FCALL                                      0  $0      
          3        SEND_VAR                                                 $0
          4        DO_ICALL                                                 
   17     5      > RETURN                                                   null

End of function foo

Class Bar:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6WG9i
function name:  __construct
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'get_caller'
          2        DO_FCALL                                      0  $0      
          3        SEND_VAR                                                 $0
          4        DO_ICALL                                                 
   25     5        NEW                                              $2      'Baz'
          6        DO_FCALL                                      0          
          7        FREE                                                     $2
   26     8      > RETURN                                                   null

End of function __construct

End of class Bar.

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

End of function __construct

End of class Baz.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.74 ms | 1402 KiB | 21 Q