3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { protected $id; protected $displanyName; } class B extends A implements ArrayAccess { public function offsetSet($offset, $value) { $offset = $this->_mapField($offset); $this->$offset = $value; } public function offsetExists($offset) { $offset = $this->_mapField($offset); return isset($this->$offset); } public function offsetUnset($offset) { $offset = $this->_mapField($offset); throw new \Exception("Cannot remove the property $offset"); } public function offsetGet($offset) { $offset = $this->_mapField($offset); if ($this->offsetExists($offset)) { return $this->$offset; } throw new \Exception("$offset property does not exists"); } private function _mapField($keyFrom) { if ($keyFrom === 'id_user') { return 'id'; } elseif ($keyFrom === 'name') { return 'displayName'; } return $keyFrom; } } $b = new B(); var_dump($b->id); var_dump($b->id_user); var_dump($b->displayName); var_dump($b->name);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GebeT
function name:  (null)
number of ops:  21
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   DECLARE_CLASS                                            'b', 'a'
   51     1        NEW                                              $1      'B'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   53     4        INIT_FCALL                                               'var_dump'
          5        FETCH_OBJ_R                                      ~4      !0, 'id'
          6        SEND_VAL                                                 ~4
          7        DO_ICALL                                                 
   54     8        INIT_FCALL                                               'var_dump'
          9        FETCH_OBJ_R                                      ~6      !0, 'id_user'
         10        SEND_VAL                                                 ~6
         11        DO_ICALL                                                 
   55    12        INIT_FCALL                                               'var_dump'
         13        FETCH_OBJ_R                                      ~8      !0, 'displayName'
         14        SEND_VAL                                                 ~8
         15        DO_ICALL                                                 
   56    16        INIT_FCALL                                               'var_dump'
         17        FETCH_OBJ_R                                      ~10     !0, 'name'
         18        SEND_VAL                                                 ~10
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Class A: [no user functions]
Class B:
Function offsetset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GebeT
function name:  offsetSet
number of ops:  9
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        INIT_METHOD_CALL                                         '_mapField'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $2      
          5        ASSIGN                                                   !0, $2
   15     6        ASSIGN_OBJ                                               !0
          7        OP_DATA                                                  !1
   16     8      > RETURN                                                   null

End of function offsetset

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GebeT
function name:  offsetExists
number of ops:  8
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     1        INIT_METHOD_CALL                                         '_mapField'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
   21     5        ISSET_ISEMPTY_PROP_OBJ                           ~3      !0
          6      > RETURN                                                   ~3
   22     7*     > RETURN                                                   null

End of function offsetexists

Function offsetunset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/GebeT
function name:  offsetUnset
number of ops:  12
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   26     1        INIT_METHOD_CALL                                         '_mapField'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
   27     5        NEW                                              $3      'Exception'
          6        NOP                                                      
          7        FAST_CONCAT                                      ~4      'Cannot+remove+the+property+', !0
          8        SEND_VAL_EX                                              ~4
          9        DO_FCALL                                      0          
         10      > THROW                                         0          $3
   28    11*     > RETURN                                                   null

End of function offsetunset

Function offsetget:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/GebeT
function name:  offsetGet
number of ops:  18
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   32     1        INIT_METHOD_CALL                                         '_mapField'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
   33     5        INIT_METHOD_CALL                                         'offsetExists'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0  $3      
          8      > JMPZ                                                     $3, ->11
   34     9    >   FETCH_OBJ_R                                      ~4      !0
         10      > RETURN                                                   ~4
   36    11    >   NEW                                              $5      'Exception'
         12        NOP                                                      
         13        FAST_CONCAT                                      ~6      !0, '+property+does+not+exists'
         14        SEND_VAL_EX                                              ~6
         15        DO_FCALL                                      0          
         16      > THROW                                         0          $5
   37    17*     > RETURN                                                   null

End of function offsetget

Function _mapfield:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GebeT
function name:  _mapField
number of ops:  10
compiled vars:  !0 = $keyFrom
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   RECV                                             !0      
   41     1        IS_IDENTICAL                                             !0, 'id_user'
          2      > JMPZ                                                     ~1, ->5
   42     3    > > RETURN                                                   'id'
          4*       JMP                                                      ->8
   43     5    >   IS_IDENTICAL                                             !0, 'name'
          6      > JMPZ                                                     ~2, ->8
   44     7    > > RETURN                                                   'displayName'
   47     8    > > RETURN                                                   !0
   48     9*     > RETURN                                                   null

End of function _mapfield

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.25 ms | 1404 KiB | 15 Q