3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected $bar; public function __construct(Bar $bar) { $this->bar = $bar; } public function __get($key) { $exploded = explode('.', $key); $item = $this; do { $next = array_shift($exploded); var_dump($item, $next); if (!property_exists($item, $next)) { return null; } $item = $item->{$next}; } while ($exploded); return $item; } } class Bar { public $foo = 'test'; } $foo = new Foo(new Bar); var_dump($foo->{"bar.test"});
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UPBjc
function name:  (null)
number of ops:  11
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   NEW                                              $1      'Foo'
          1        NEW                                              $2      'Bar'
          2        DO_FCALL                                      0          
          3        SEND_VAR_NO_REF_EX                                       $2
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $1
   43     6        INIT_FCALL                                               'var_dump'
          7        FETCH_OBJ_R                                      ~6      !0, 'bar.test'
          8        SEND_VAL                                                 ~6
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UPBjc
function name:  __construct
number of ops:  4
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        ASSIGN_OBJ                                               'bar'
          2        OP_DATA                                                  !0
   11     3      > RETURN                                                   null

End of function __construct

Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 23
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 8
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/UPBjc
function name:  __get
number of ops:  28
compiled vars:  !0 = $key, !1 = $exploded, !2 = $item, !3 = $next
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '.'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !1, $4
   16     6        FETCH_THIS                                       ~6      
          7        ASSIGN                                                   !2, ~6
   19     8    >   INIT_FCALL                                               'array_shift'
          9        SEND_REF                                                 !1
         10        DO_ICALL                                         $8      
         11        ASSIGN                                                   !3, $8
   20    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !2
         14        SEND_VAR                                                 !3
         15        DO_ICALL                                                 
   22    16        INIT_FCALL                                               'property_exists'
         17        SEND_VAR                                                 !2
         18        SEND_VAR                                                 !3
         19        DO_ICALL                                         $11     
         20        BOOL_NOT                                         ~12     $11
         21      > JMPZ                                                     ~12, ->23
   23    22    > > RETURN                                                   null
   26    23    >   FETCH_OBJ_R                                      ~13     !2, !3
         24        ASSIGN                                                   !2, ~13
   27    25      > JMPNZ                                                    !1, ->8
   29    26    > > RETURN                                                   !2
   30    27*     > RETURN                                                   null

End of function __get

End of class Foo.

Class Bar: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.96 ms | 1400 KiB | 21 Q