3v4l.org

run code in 300+ PHP versions simultaneously
<?php class KeyValuePairs { private $pairs; public function __construct( $arr = []) { $this->pairs = []; foreach( $arr as $k => $k) { $this->pairs[$k] = $v; } } 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 = new KeyValuePairs( ['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/u6MAb
function name:  (null)
number of ops:  22
compiled vars:  !0 = $class1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   NEW                                              $1      'MyClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   42     3        INIT_FCALL                                               'var_dump'
          4        FETCH_OBJ_R                                      ~4      !0, 'foo'
          5        SEND_VAL                                                 ~4
          6        DO_ICALL                                                 
   43     7        INIT_FCALL                                               'var_dump'
          8        FETCH_OBJ_R                                      ~6      !0, 'boo'
          9        SEND_VAL                                                 ~6
         10        DO_ICALL                                                 
   44    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                                                 
   45    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 __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/u6MAb
function name:  __construct
number of ops:  12
compiled vars:  !0 = $arr, !1 = $k, !2 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV_INIT                                        !0      <array>
    8     1        ASSIGN_OBJ                                               'pairs'
          2        OP_DATA                                                  <array>
    9     3      > FE_RESET_R                                       $4      !0, ->10
          4    > > FE_FETCH_R                                       ~5      $4, !1, ->10
          5    >   ASSIGN                                                   !1, ~5
   10     6        FETCH_OBJ_W                                      $7      'pairs'
          7        ASSIGN_DIM                                               $7, !1
          8        OP_DATA                                                  !2
    9     9      > JMP                                                      ->4
         10    >   FE_FREE                                                  $4
   12    11      > RETURN                                                   null

End of function __construct

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/u6MAb
function name:  __get
number of ops:  11
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     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
   17    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/u6MAb
function name:  __set
number of ops:  6
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   21     2        FETCH_OBJ_W                                      $2      'pairs'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   22     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/u6MAb
function name:  __construct
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   NEW                                              $1      'KeyValuePairs'
          1        SEND_VAL_EX                                              <array>
          2        DO_FCALL                                      0          
          3        ASSIGN_OBJ                                               'bar'
          4        OP_DATA                                                  $1
   33     5      > 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/u6MAb
function name:  __get
number of ops:  9
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
   37     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
   38     8*     > RETURN                                                   null

End of function __get

End of class MyClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.34 ms | 1404 KiB | 15 Q