3v4l.org

run code in 300+ PHP versions simultaneously
<?php class test { protected $_a = 6; function __get($key) { echo "__get({$key})\n"; if($key == 'stuff') { return $this->stuff(); } else if($key == 'a') { return $this->_a + 2; } } function stuff() { echo "stuff()\n"; return array('random' => 'key', 'using_getter' => 10 * $this->a); } function hey() { return $this->a; } } class me extends test { function __get( $name){ $val = parent::__get($name); if ($name === 'a' ) { $val = parent::a - 5; } return $val; } } $test = new test(); print 'this should be 60: '.$test->stuff['using_getter'].PHP_EOL; print 'this should be 6: '.$test->a.PHP_EOL; print $test->hey(); $me = new me(); print $me->a;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uf1Mq
function name:  (null)
number of ops:  21
compiled vars:  !0 = $test, !1 = $me
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   NEW                                              $2      'test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   41     3        FETCH_OBJ_R                                      ~5      !0, 'stuff'
          4        FETCH_DIM_R                                      ~6      ~5, 'using_getter'
          5        CONCAT                                           ~7      'this+should+be+60%3A+', ~6
          6        CONCAT                                           ~8      ~7, '%0A'
          7        ECHO                                                     ~8
   42     8        FETCH_OBJ_R                                      ~9      !0, 'a'
          9        CONCAT                                           ~10     'this+should+be+6%3A+', ~9
         10        CONCAT                                           ~11     ~10, '%0A'
         11        ECHO                                                     ~11
   43    12        INIT_METHOD_CALL                                         !0, 'hey'
         13        DO_FCALL                                      0  $12     
         14        ECHO                                                     $12
   46    15        NEW                                              $13     'me'
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !1, $13
   47    18        FETCH_OBJ_R                                      ~16     !1, 'a'
         19        ECHO                                                     ~16
         20      > RETURN                                                   1

Class test:
Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uf1Mq
function name:  __get
number of ops:  17
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        ROPE_INIT                                     3  ~2      '__get%28'
          2        ROPE_ADD                                      1  ~2      ~2, !0
          3        ROPE_END                                      2  ~1      ~2, '%29%0A'
          4        ECHO                                                     ~1
    9     5        IS_EQUAL                                                 !0, 'stuff'
          6      > JMPZ                                                     ~4, ->11
   10     7    >   INIT_METHOD_CALL                                         'stuff'
          8        DO_FCALL                                      0  $5      
          9      > RETURN                                                   $5
         10*       JMP                                                      ->16
   11    11    >   IS_EQUAL                                                 !0, 'a'
         12      > JMPZ                                                     ~6, ->16
   12    13    >   FETCH_OBJ_R                                      ~7      '_a'
         14        ADD                                              ~8      ~7, 2
         15      > RETURN                                                   ~8
   14    16    > > RETURN                                                   null

End of function __get

Function stuff:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uf1Mq
function name:  stuff
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ECHO                                                     'stuff%28%29%0A'
   19     1        INIT_ARRAY                                       ~0      'key', 'random'
          2        FETCH_OBJ_R                                      ~1      'a'
          3        MUL                                              ~2      ~1, 10
          4        ADD_ARRAY_ELEMENT                                ~0      ~2, 'using_getter'
          5      > RETURN                                                   ~0
   20     6*     > RETURN                                                   null

End of function stuff

Function hey:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uf1Mq
function name:  hey
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   FETCH_OBJ_R                                      ~0      'a'
          1      > RETURN                                                   ~0
   24     2*     > RETURN                                                   null

End of function hey

End of class test.

Class me:
Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/uf1Mq
function name:  __get
number of ops:  12
compiled vars:  !0 = $name, !1 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   30     1        INIT_STATIC_METHOD_CALL                                  '__get'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !1, $2
   31     5        IS_IDENTICAL                                             !0, 'a'
          6      > JMPZ                                                     ~4, ->10
   32     7    >   FETCH_CLASS_CONSTANT                             ~5      'a'
          8        SUB                                              ~6      ~5, 5
          9        ASSIGN                                                   !1, ~6
   35    10    > > RETURN                                                   !1
   36    11*     > RETURN                                                   null

End of function __get

Function stuff:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uf1Mq
function name:  stuff
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ECHO                                                     'stuff%28%29%0A'
   19     1        INIT_ARRAY                                       ~0      'key', 'random'
          2        FETCH_OBJ_R                                      ~1      'a'
          3        MUL                                              ~2      ~1, 10
          4        ADD_ARRAY_ELEMENT                                ~0      ~2, 'using_getter'
          5      > RETURN                                                   ~0
   20     6*     > RETURN                                                   null

End of function stuff

Function hey:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uf1Mq
function name:  hey
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   FETCH_OBJ_R                                      ~0      'a'
          1      > RETURN                                                   ~0
   24     2*     > RETURN                                                   null

End of function hey

End of class me.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.81 ms | 1403 KiB | 13 Q