3v4l.org

run code in 300+ PHP versions simultaneously
<?php class LazyProperties { protected $foo; public function __construct() { unset($this->foo); } public function getFoo() { return $this->foo; } public function __get($property) { switch ($property) { case 'foo': echo __METHOD__."() is called\n"; return $this->foo = 'magic'; } } } $o = new LazyProperties(); var_dump($o->getFoo()); var_dump($o->getFoo()); var_dump($o->getFoo());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tYYMD
function name:  (null)
number of ops:  19
compiled vars:  !0 = $o
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   NEW                                              $1      'LazyProperties'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   29     3        INIT_FCALL                                               'var_dump'
          4        INIT_METHOD_CALL                                         !0, 'getFoo'
          5        DO_FCALL                                      0  $4      
          6        SEND_VAR                                                 $4
          7        DO_ICALL                                                 
   30     8        INIT_FCALL                                               'var_dump'
          9        INIT_METHOD_CALL                                         !0, 'getFoo'
         10        DO_FCALL                                      0  $6      
         11        SEND_VAR                                                 $6
         12        DO_ICALL                                                 
   31    13        INIT_FCALL                                               'var_dump'
         14        INIT_METHOD_CALL                                         !0, 'getFoo'
         15        DO_FCALL                                      0  $8      
         16        SEND_VAR                                                 $8
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Class LazyProperties:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tYYMD
function name:  __construct
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   UNSET_OBJ                                                'foo'
   10     1      > RETURN                                                   null

End of function __construct

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

End of function getfoo

Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tYYMD
function name:  __get
number of ops:  9
compiled vars:  !0 = $property
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   20     1        IS_EQUAL                                                 !0, 'foo'
          2      > JMPNZ                                                    ~1, ->4
          3    > > JMP                                                      ->8
   21     4    >   ECHO                                                     'LazyProperties%3A%3A__get%28%29+is+called%0A'
   22     5        ASSIGN_OBJ                                       ~2      'foo'
          6        OP_DATA                                                  'magic'
          7      > RETURN                                                   ~2
   24     8    > > RETURN                                                   null

End of function __get

End of class LazyProperties.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.9 ms | 1020 KiB | 14 Q