3v4l.org

run code in 300+ PHP versions simultaneously
<?php //! PHP magic wrapper class Magic0 implements ArrayAccess { var $properties; //protected would be better function exists($key) { return isset($this->properties[$key]); } function set($key,$val) { return $this->properties[$key]=$val; } function get($key) { return isset($this->properties[$key])?$this->properties[$key]:NULL; } function clear($key) { unset($this->properties[$key]); } function __isset($key) { return $this->offsetexists($key); } function __set($key,$val) { return $this->offsetset($key,$val); } function offsetexists($key) { return exists($key); } function offsetset($key,$val) { return $this->set($key,$val); } function offsetget($key) { return $this->get($key); } function offsetunset($key) { $this->clear($key); } function __get($key) { return $this->offsetget($key); } function __unset($key) { $this->offsetunset($key); } } //in every case, it will create entry in internal array $sample=new Magic0(); $sample->a=11; $sample->b="Muse"; $sample['c']=13; //we can get them through array index as well echo $sample['a'] ."\n"; echo $sample['b'] ."\n"; echo $sample->c ."\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PCn1n
function name:  (null)
number of ops:  20
compiled vars:  !0 = $sample
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'magic0'
   64     1        NEW                                              $1      'Magic0'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   65     4        ASSIGN_OBJ                                               !0, 'a'
          5        OP_DATA                                                  11
   66     6        ASSIGN_OBJ                                               !0, 'b'
          7        OP_DATA                                                  'Muse'
   67     8        ASSIGN_DIM                                               !0, 'c'
          9        OP_DATA                                                  13
   69    10        FETCH_DIM_R                                      ~7      !0, 'a'
         11        CONCAT                                           ~8      ~7, '%0A'
         12        ECHO                                                     ~8
   70    13        FETCH_DIM_R                                      ~9      !0, 'b'
         14        CONCAT                                           ~10     ~9, '%0A'
         15        ECHO                                                     ~10
   71    16        FETCH_OBJ_R                                      ~11     !0, 'c'
         17        CONCAT                                           ~12     ~11, '%0A'
         18        ECHO                                                     ~12
         19      > RETURN                                                   1

Class Magic0:
Function exists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PCn1n
function name:  exists
number of ops:  5
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        FETCH_OBJ_IS                                     ~1      'properties'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      ~1, !0
          3      > RETURN                                                   ~2
   10     4*     > RETURN                                                   null

End of function exists

Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PCn1n
function name:  set
number of ops:  7
compiled vars:  !0 = $key, !1 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        FETCH_OBJ_W                                      $2      'properties'
          3        ASSIGN_DIM                                       ~3      $2, !0
          4        OP_DATA                                                  !1
          5      > RETURN                                                   ~3
   15     6*     > RETURN                                                   null

End of function set

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/PCn1n
function name:  get
number of ops:  11
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        FETCH_OBJ_IS                                     ~1      'properties'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, !0
          3      > JMPZ                                                     ~2, ->8
          4    >   FETCH_OBJ_R                                      ~3      'properties'
          5        FETCH_DIM_R                                      ~4      ~3, !0
          6        QM_ASSIGN                                        ~5      ~4
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~5      null
          9    > > RETURN                                                   ~5
   20    10*     > RETURN                                                   null

End of function get

Function clear:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PCn1n
function name:  clear
number of ops:  4
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   24     1        FETCH_OBJ_UNSET                                  $1      'properties'
          2        UNSET_DIM                                                $1, !0
   25     3      > RETURN                                                   null

End of function clear

Function __isset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PCn1n
function name:  __isset
number of ops:  6
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   27     1        INIT_METHOD_CALL                                         'offsetexists'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   28     5*     > RETURN                                                   null

End of function __isset

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PCn1n
function name:  __set
number of ops:  8
compiled vars:  !0 = $key, !1 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   32     2        INIT_METHOD_CALL                                         'offsetset'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $2      
          6      > RETURN                                                   $2
   33     7*     > RETURN                                                   null

End of function __set

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PCn1n
function name:  offsetexists
number of ops:  6
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
   36     1        INIT_FCALL_BY_NAME                                       'exists'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   37     5*     > RETURN                                                   null

End of function offsetexists

Function offsetset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PCn1n
function name:  offsetset
number of ops:  8
compiled vars:  !0 = $key, !1 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   40     2        INIT_METHOD_CALL                                         'set'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $2      
          6      > RETURN                                                   $2
   41     7*     > RETURN                                                   null

End of function offsetset

Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PCn1n
function name:  offsetget
number of ops:  6
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   RECV                                             !0      
   44     1        INIT_METHOD_CALL                                         'get'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   45     5*     > RETURN                                                   null

End of function offsetget

Function offsetunset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PCn1n
function name:  offsetunset
number of ops:  5
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   RECV                                             !0      
   49     1        INIT_METHOD_CALL                                         'clear'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
   50     4      > RETURN                                                   null

End of function offsetunset

Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PCn1n
function name:  __get
number of ops:  6
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   RECV                                             !0      
   54     1        INIT_METHOD_CALL                                         'offsetget'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   55     5*     > RETURN                                                   null

End of function __get

Function __unset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PCn1n
function name:  __unset
number of ops:  5
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   58     0  E >   RECV                                             !0      
   59     1        INIT_METHOD_CALL                                         'offsetunset'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
   60     4      > RETURN                                                   null

End of function __unset

End of class Magic0.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.57 ms | 1407 KiB | 13 Q