3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Header { public function __construct() { $this->project = get_prior_object(); $this->modules = get_prior_object(1); } } class Modules { public function __construct() { $this->project = get_prior_object(); $this->header = new Header(); } } class Project { public $config = "config"; public function __construct() { $this->modules = new Modules(); } } $p = new Project(); var_dump($p->modules); function get_prior_object($skip = 0) { $bt = debug_backtrace(); foreach ($bt as $stack) { if (isset($stack['function']) && $stack['function'] === "__construct" && $skip-- <= 0) { return $stack['object']; } } return null; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9s1gK
function name:  (null)
number of ops:  8
compiled vars:  !0 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   NEW                                              $1      'Project'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   33     3        INIT_FCALL                                               'var_dump'
          4        FETCH_OBJ_R                                      ~4      !0, 'modules'
          5        SEND_VAL                                                 ~4
          6        DO_ICALL                                                 
   43     7      > RETURN                                                   1

Function get_prior_object:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 20
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 20
Branch analysis from position: 6
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 15
Branch analysis from position: 11
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/9s1gK
function name:  get_prior_object
number of ops:  23
compiled vars:  !0 = $skip, !1 = $bt, !2 = $stack
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV_INIT                                        !0      0
   36     1        INIT_FCALL                                               'debug_backtrace'
          2        DO_ICALL                                         $3      
          3        ASSIGN                                                   !1, $3
   37     4      > FE_RESET_R                                       $5      !1, ->20
          5    > > FE_FETCH_R                                               $5, !2, ->20
   38     6    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !2, 'function'
          7      > JMPZ_EX                                          ~6      ~6, ->11
          8    >   FETCH_DIM_R                                      ~7      !2, 'function'
          9        IS_IDENTICAL                                     ~8      ~7, '__construct'
         10        BOOL                                             ~6      ~8
         11    > > JMPZ_EX                                          ~6      ~6, ->15
         12    >   POST_DEC                                         ~9      !0
         13        IS_SMALLER_OR_EQUAL                              ~10     ~9, 0
         14        BOOL                                             ~6      ~10
         15    > > JMPZ                                                     ~6, ->19
   39    16    >   FETCH_DIM_R                                      ~11     !2, 'object'
         17        FE_FREE                                                  $5
         18      > RETURN                                                   ~11
   37    19    > > JMP                                                      ->5
         20    >   FE_FREE                                                  $5
   42    21      > RETURN                                                   null
   43    22*     > RETURN                                                   null

End of function get_prior_object

Class Header:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9s1gK
function name:  __construct
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL_BY_NAME                                       'get_prior_object'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN_OBJ                                               'project'
          3        OP_DATA                                                  $1
    8     4        INIT_FCALL_BY_NAME                                       'get_prior_object'
          5        SEND_VAL_EX                                              1
          6        DO_FCALL                                      0  $3      
          7        ASSIGN_OBJ                                               'modules'
          8        OP_DATA                                                  $3
    9     9      > RETURN                                                   null

End of function __construct

End of class Header.

Class Modules:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9s1gK
function name:  __construct
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL_BY_NAME                                       'get_prior_object'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN_OBJ                                               'project'
          3        OP_DATA                                                  $1
   17     4        NEW                                              $3      'Header'
          5        DO_FCALL                                      0          
          6        ASSIGN_OBJ                                               'header'
          7        OP_DATA                                                  $3
   18     8      > RETURN                                                   null

End of function __construct

End of class Modules.

Class Project:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9s1gK
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   NEW                                              $1      'Modules'
          1        DO_FCALL                                      0          
          2        ASSIGN_OBJ                                               'modules'
          3        OP_DATA                                                  $1
   28     4      > RETURN                                                   null

End of function __construct

End of class Project.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.3 ms | 1400 KiB | 17 Q