3v4l.org

run code in 300+ PHP versions simultaneously
<?php class KeyValuePairs { private $pairs = []; public function __get($name) { return (isset($this->pairs[$name])) ? $this->pairs[$name] : null; } public function __set($name, $value) { $this->pairs[$name] = $value; } } class MyClass { public $foo; public $bar; public function __construct() { $this->bar = (object) ['tool' => 'Here we go']; } public function __get($name) { return (isset($this->$name)) ? $this->$name : null; } } $class1 = new MyClass; var_dump($class1->foo); // null var_dump($class1->boo); // null var_dump($class1->bar->tool); // 'Here we go' var_dump($class1->bar->mars);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/q0bHF
function name:  (null)
number of ops:  22
compiled vars:  !0 = $class1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   NEW                                              $1      'MyClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   34     3        INIT_FCALL                                               'var_dump'
          4        FETCH_OBJ_R                                      ~4      !0, 'foo'
          5        SEND_VAL                                                 ~4
          6        DO_ICALL                                                 
   35     7        INIT_FCALL                                               'var_dump'
          8        FETCH_OBJ_R                                      ~6      !0, 'boo'
          9        SEND_VAL                                                 ~6
         10        DO_ICALL                                                 
   36    11        INIT_FCALL                                               'var_dump'
         12        FETCH_OBJ_R                                      ~8      !0, 'bar'
         13        FETCH_OBJ_R                                      ~9      ~8, 'tool'
         14        SEND_VAL                                                 ~9
         15        DO_ICALL                                                 
   37    16        INIT_FCALL                                               'var_dump'
         17        FETCH_OBJ_R                                      ~11     !0, 'bar'
         18        FETCH_OBJ_R                                      ~12     ~11, 'mars'
         19        SEND_VAL                                                 ~12
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Class KeyValuePairs:
Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/q0bHF
function name:  __get
number of ops:  11
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        FETCH_OBJ_IS                                     ~1      'pairs'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, !0
          3      > JMPZ                                                     ~2, ->8
          4    >   FETCH_OBJ_R                                      ~3      'pairs'
          5        FETCH_DIM_R                                      ~4      ~3, !0
          6        QM_ASSIGN                                        ~5      ~4
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~5      null
          9    > > RETURN                                                   ~5
    9    10*     > RETURN                                                   null

End of function __get

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/q0bHF
function name:  __set
number of ops:  6
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   13     2        FETCH_OBJ_W                                      $2      'pairs'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   14     5      > RETURN                                                   null

End of function __set

End of class KeyValuePairs.

Class MyClass:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/q0bHF
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   CAST                                          8  ~1      <array>
          1        ASSIGN_OBJ                                               'bar'
          2        OP_DATA                                                  ~1
   25     3      > RETURN                                                   null

End of function __construct

Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/q0bHF
function name:  __get
number of ops:  9
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   29     1        ISSET_ISEMPTY_PROP_OBJ                                   !0
          2      > JMPZ                                                     ~1, ->6
          3    >   FETCH_OBJ_R                                      ~2      !0
          4        QM_ASSIGN                                        ~3      ~2
          5      > JMP                                                      ->7
          6    >   QM_ASSIGN                                        ~3      null
          7    > > RETURN                                                   ~3
   30     8*     > RETURN                                                   null

End of function __get

End of class MyClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.39 ms | 1400 KiB | 15 Q