3v4l.org

run code in 500+ PHP versions simultaneously
<?php class A { private $vars; public function __get($name) { if (!isset($this->vars[$name])) { $arrObj = array(); $arrObj[] = new B(); $arrObj[] = new B(); $this->vars[$name] = $arrObj; } return $this->vars[$name]; } } class B { public $rolename = 'foo'; } $a = new A; var_dump($a); echo $a->role[0]->rolename.PHP_EOL; $a->role[0]->rolename = 'test'; echo $a->role[0]->rolename;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iC3Ji
function name:  (null)
number of ops:  20
compiled vars:  !0 = $a
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   25     0  E >   NEW                                                  $1      'A'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $1
   26     3        INIT_FCALL                                                   'var_dump'
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                                     
   27     6        FETCH_OBJ_R                                          ~5      !0, 'role'
          7        FETCH_DIM_R                                          ~6      ~5, 0
          8        FETCH_OBJ_R                                          ~7      ~6, 'rolename'
          9        CONCAT                                               ~8      ~7, '%0A'
         10        ECHO                                                         ~8
   28    11        FETCH_OBJ_W                                          $9      !0, 'role'
         12        FETCH_DIM_W                                          $10     $9, 0
         13        ASSIGN_OBJ                                                   $10, 'rolename'
         14        OP_DATA                                                      'test'
   30    15        FETCH_OBJ_R                                          ~12     !0, 'role'
         16        FETCH_DIM_R                                          ~13     ~12, 0
         17        FETCH_OBJ_R                                          ~14     ~13, 'rolename'
         18        ECHO                                                         ~14
   31    19      > RETURN                                                       1

Class A:
Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 17
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/iC3Ji
function name:  __get
number of ops:  21
compiled vars:  !0 = $name, !1 = $arrObj
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
    7     1        FETCH_OBJ_IS                                         ~2      'vars'
          2        ISSET_ISEMPTY_DIM_OBJ                             0  ~3      ~2, !0
          3        BOOL_NOT                                             ~4      ~3
          4      > JMPZ                                                         ~4, ->17
    8     5    >   ASSIGN                                                       !1, <array>
    9     6        NEW                                                  $7      'B'
          7        DO_FCALL                                          0          
          8        ASSIGN_DIM                                                   !1
          9        OP_DATA                                                      $7
   10    10        NEW                                                  $10     'B'
         11        DO_FCALL                                          0          
         12        ASSIGN_DIM                                                   !1
         13        OP_DATA                                                      $10
   11    14        FETCH_OBJ_W                                          $12     'vars'
         15        ASSIGN_DIM                                                   $12, !0
         16        OP_DATA                                                      !1
   14    17    >   FETCH_OBJ_R                                          ~14     'vars'
         18        FETCH_DIM_R                                          ~15     ~14, !0
         19      > RETURN                                                       ~15
   15    20*     > RETURN                                                       null

End of function __get

End of class A.

Class B: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
180.06 ms | 3352 KiB | 14 Q