3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { public $bar = null; public function &getBar() { if ($this->bar === null) { $this->bar[] = 'init'; } return $this->bar; } } $obj = new foo; $myValue = &$obj->getBar(); $myValue[] = 123; var_dump($obj->bar);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IY2J1
function name:  (null)
number of ops:  13
compiled vars:  !0 = $obj, !1 = $myValue
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   NEW                                              $2      'foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   17     3        INIT_METHOD_CALL                                         !0, 'getBar'
          4        DO_FCALL                                      0  $5      
          5        ASSIGN_REF                                               !1, $5
   19     6        ASSIGN_DIM                                               !1
          7        OP_DATA                                                  123
   21     8        INIT_FCALL                                               'var_dump'
          9        FETCH_OBJ_R                                      ~8      !0, 'bar'
         10        SEND_VAL                                                 ~8
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Class foo:
Function getbar:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
Return found
Branch analysis from position: 6
filename:       /in/IY2J1
function name:  getBar
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_OBJ_R                                      ~0      'bar'
          1        TYPE_CHECK                                    2          ~0
          2      > JMPZ                                                     ~1, ->6
    9     3    >   FETCH_OBJ_W                                      $2      'bar'
          4        ASSIGN_DIM                                               $2
          5        OP_DATA                                                  'init'
   12     6    >   FETCH_OBJ_W                                      $4      'bar'
          7      > RETURN_BY_REF                                            $4
   13     8*     > RETURN_BY_REF                                            null

End of function getbar

End of class foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.42 ms | 1395 KiB | 15 Q