3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { private $data; private $relations; public function __set($name, $value) { $this->data[$name] = $value; } public function __get($name) { if(isset($this->data[$name])){ return $this->data[$name]; } if(method_exists('bar',$name)){ $getCalled = get_called_class(); return (new $getCalled())->$name(); } } public function __construct() { $this->data = ['foo' => 'test', 'body' => 'content']; } public function test() { $function = debug_backtrace()[1]['function']; echo $function; $this->relations[$function] = ['a' =>'aa', 'b' =>'bb']; return $this; } } class bar extends foo{ public function aa(){ return $this->test(); } } $bar = new bar(); $bar->aa; print_r($bar);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6r30V
function name:  (null)
number of ops:  9
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   NEW                                              $1      'bar'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   57     3        FETCH_OBJ_R                                      ~4      !0, 'aa'
          4        FREE                                                     ~4
   59     5        INIT_FCALL                                               'print_r'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Class foo:
Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6r30V
function name:  __set
number of ops:  6
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        FETCH_OBJ_W                                      $2      'data'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   12     5      > RETURN                                                   null

End of function __set

Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 20
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6r30V
function name:  __get
number of ops:  21
compiled vars:  !0 = $name, !1 = $getCalled
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        FETCH_OBJ_IS                                     ~2      'data'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~2, !0
          3      > JMPZ                                                     ~3, ->7
   17     4    >   FETCH_OBJ_R                                      ~4      'data'
          5        FETCH_DIM_R                                      ~5      ~4, !0
          6      > RETURN                                                   ~5
   20     7    >   INIT_FCALL                                               'method_exists'
          8        SEND_VAL                                                 'bar'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $6      
         11      > JMPZ                                                     $6, ->20
   21    12    >   GET_CALLED_CLASS                                 ~7      
         13        ASSIGN                                                   !1, ~7
   22    14        FETCH_CLASS                                   0  $9      !1
         15        NEW                                              $10     $9
         16        DO_FCALL                                      0          
         17        INIT_METHOD_CALL                                         $10, !0
         18        DO_FCALL                                      0  $12     
         19      > RETURN                                                   $12
   24    20    > > RETURN                                                   null

End of function __get

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6r30V
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   ASSIGN_OBJ                                               'data'
          1        OP_DATA                                                  <array>
   29     2      > RETURN                                                   null

End of function __construct

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6r30V
function name:  test
number of ops:  12
compiled vars:  !0 = $function
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   INIT_FCALL                                               'debug_backtrace'
          1        DO_ICALL                                         $1      
          2        FETCH_DIM_R                                      ~2      $1, 1
          3        FETCH_DIM_R                                      ~3      ~2, 'function'
          4        ASSIGN                                                   !0, ~3
   35     5        ECHO                                                     !0
   36     6        FETCH_OBJ_W                                      $5      'relations'
          7        ASSIGN_DIM                                               $5, !0
          8        OP_DATA                                                  <array>
   38     9        FETCH_THIS                                       ~7      
         10      > RETURN                                                   ~7
   39    11*     > RETURN                                                   null

End of function test

End of class foo.

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

End of function aa

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6r30V
function name:  __set
number of ops:  6
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        FETCH_OBJ_W                                      $2      'data'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   12     5      > RETURN                                                   null

End of function __set

Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 20
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6r30V
function name:  __get
number of ops:  21
compiled vars:  !0 = $name, !1 = $getCalled
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        FETCH_OBJ_IS                                     ~2      'data'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~2, !0
          3      > JMPZ                                                     ~3, ->7
   17     4    >   FETCH_OBJ_R                                      ~4      'data'
          5        FETCH_DIM_R                                      ~5      ~4, !0
          6      > RETURN                                                   ~5
   20     7    >   INIT_FCALL                                               'method_exists'
          8        SEND_VAL                                                 'bar'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $6      
         11      > JMPZ                                                     $6, ->20
   21    12    >   GET_CALLED_CLASS                                 ~7      
         13        ASSIGN                                                   !1, ~7
   22    14        FETCH_CLASS                                   0  $9      !1
         15        NEW                                              $10     $9
         16        DO_FCALL                                      0          
         17        INIT_METHOD_CALL                                         $10, !0
         18        DO_FCALL                                      0  $12     
         19      > RETURN                                                   $12
   24    20    > > RETURN                                                   null

End of function __get

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6r30V
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   ASSIGN_OBJ                                               'data'
          1        OP_DATA                                                  <array>
   29     2      > RETURN                                                   null

End of function __construct

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6r30V
function name:  test
number of ops:  12
compiled vars:  !0 = $function
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   INIT_FCALL                                               'debug_backtrace'
          1        DO_ICALL                                         $1      
          2        FETCH_DIM_R                                      ~2      $1, 1
          3        FETCH_DIM_R                                      ~3      ~2, 'function'
          4        ASSIGN                                                   !0, ~3
   35     5        ECHO                                                     !0
   36     6        FETCH_OBJ_W                                      $5      'relations'
          7        ASSIGN_DIM                                               $5, !0
          8        OP_DATA                                                  <array>
   38     9        FETCH_THIS                                       ~7      
         10      > RETURN                                                   ~7
   39    11*     > RETURN                                                   null

End of function test

End of class bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.65 ms | 1400 KiB | 19 Q