3v4l.org

run code in 500+ PHP versions simultaneously
<?php class MagicByRef { private $prop = 'hello'; private function &getProp($name) { printf( "%s: %s is %s\n", __METHOD__, $name, property_exists($this, $name) ? 'exists' : 'not exists' ); return $this->prop; } public function __set($name, $value) { echo __METHOD__ , "($name, $value)\n"; } public function &__get($name) { echo __METHOD__ , "($name)\n"; $this->$name = &$this->getProp($name); return $this->$name; } } echo 'Assignment by reference: $this->$name = &$this->getProp($name)', ":\n"; $m = new MagicByRef; $m->hello;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PBZRS
function name:  (null)
number of ops:  8
compiled vars:  !0 = $m
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   33     0  E >   ECHO                                                         'Assignment+by+reference%3A+%24this-%3E%24name+%3D+%26%24this-%3EgetProp%28%24name%29'
          1        ECHO                                                         '%3A%0A'
   34     2        NEW                                                  $1      'MagicByRef'
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !0, $1
   36     5        FETCH_OBJ_R                                          ~4      !0, 'hello'
          6        FREE                                                         ~4
          7      > RETURN                                                       1

Class MagicByRef:
Function getprop:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Return found
Branch analysis from position: 10
Return found
filename:       /in/PBZRS
function name:  getProp
number of ops:  16
compiled vars:  !0 = $name
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
    8     1        INIT_FCALL                                                   'printf'
    9     2        SEND_VAL                                                     '%25s%3A+%25s+is+%25s%0A'
   10     3        SEND_VAL                                                     'MagicByRef%3A%3AgetProp'
   11     4        SEND_VAR                                                     !0
   12     5        FETCH_THIS                                           ~1      
          6        FRAMELESS_ICALL_2                property_exists      ~2      ~1, !0
          7      > JMPZ                                                         ~2, ->10
          8    >   QM_ASSIGN                                            ~3      'exists'
          9      > JMP                                                          ->11
         10    >   QM_ASSIGN                                            ~3      'not+exists'
         11    >   SEND_VAL                                                     ~3
    8    12        DO_ICALL                                                     
   15    13        FETCH_OBJ_W                                          $5      'prop'
         14      > RETURN_BY_REF                                                $5
   16    15*     > RETURN_BY_REF                                                null

End of function getprop

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PBZRS
function name:  __set
number of ops:  10
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   20     2        ECHO                                                         'MagicByRef%3A%3A__set'
          3        ROPE_INIT                                         5  ~3      '%28'
          4        ROPE_ADD                                          1  ~3      ~3, !0
          5        ROPE_ADD                                          2  ~3      ~3, '%2C+'
          6        ROPE_ADD                                          3  ~3      ~3, !1
          7        ROPE_END                                          4  ~2      ~3, '%29%0A'
          8        ECHO                                                         ~2
   21     9      > RETURN                                                       null

End of function __set

Function __get:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /in/PBZRS
function name:  __get
number of ops:  15
compiled vars:  !0 = $name
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   23     0  E >   RECV                                                 !0      
   25     1        ECHO                                                         'MagicByRef%3A%3A__get'
          2        ROPE_INIT                                         3  ~2      '%28'
          3        ROPE_ADD                                          1  ~2      ~2, !0
          4        ROPE_END                                          2  ~1      ~2, '%29%0A'
          5        ECHO                                                         ~1
   27     6        INIT_METHOD_CALL                                             'getProp'
          7        SEND_VAR                                                     !0
          8        DO_FCALL                                          0  $5      
          9        MAKE_REF                                             $6      $5
         10        ASSIGN_OBJ_REF                                               !0
         11        OP_DATA                                                      $6
   29    12        FETCH_OBJ_W                                          $7      !0
         13      > RETURN_BY_REF                                                $7
   30    14*     > RETURN_BY_REF                                                null

End of function __get

End of class MagicByRef.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
129.51 ms | 482 KiB | 8 Q