3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DefaultMap implements ArrayAccess { private $array; private $default; public function __construct($default = null) { $this->array = []; $this->default = $default; } public function &offsetGet($key) { if (!isset($this->array[$key])) { $this->array[$key] = $this->default; } return $this->array[$key]; } public function offsetSet($key, $value) { $this->array[$key] = $value; } public function offsetExists($key) { return isset($this->array[$key]); } public function offsetUnset($key) { unset($this->array[$key]); } public function toArray() { return $this->array; } } $map = new DefaultMap(0); $map["foo"]++; var_dump($map->toArray());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sU57S
function name:  (null)
number of ops:  13
compiled vars:  !0 = $map
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'defaultmap'
   37     1        NEW                                              $1      'DefaultMap'
          2        SEND_VAL_EX                                              0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   38     5        FETCH_DIM_RW                                     $4      !0, 'foo'
          6        PRE_INC                                                  $4
   39     7        INIT_FCALL                                               'var_dump'
          8        INIT_METHOD_CALL                                         !0, 'toArray'
          9        DO_FCALL                                      0  $6      
         10        SEND_VAR                                                 $6
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Class DefaultMap:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sU57S
function name:  __construct
number of ops:  6
compiled vars:  !0 = $default
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV_INIT                                        !0      null
    8     1        ASSIGN_OBJ                                               'array'
          2        OP_DATA                                                  <array>
    9     3        ASSIGN_OBJ                                               'default'
          4        OP_DATA                                                  !0
   10     5      > RETURN                                                   null

End of function __construct

Function offsetget:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
Return found
Branch analysis from position: 9
filename:       /in/sU57S
function name:  offsetGet
number of ops:  13
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        FETCH_OBJ_IS                                     ~1      'array'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      ~1, !0
          3        BOOL_NOT                                         ~3      ~2
          4      > JMPZ                                                     ~3, ->9
   14     5    >   FETCH_OBJ_R                                      ~6      'default'
          6        FETCH_OBJ_W                                      $4      'array'
          7        ASSIGN_DIM                                               $4, !0
          8        OP_DATA                                                  ~6
   17     9    >   FETCH_OBJ_W                                      $7      'array'
         10        FETCH_DIM_W                                      $8      $7, !0
         11      > RETURN_BY_REF                                            $8
   18    12*     > RETURN_BY_REF                                            null

End of function offsetget

Function offsetset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sU57S
function name:  offsetSet
number of ops:  6
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   21     2        FETCH_OBJ_W                                      $2      'array'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   22     5      > 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/sU57S
function name:  offsetExists
number of ops:  5
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   25     1        FETCH_OBJ_IS                                     ~1      'array'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      ~1, !0
          3      > RETURN                                                   ~2
   26     4*     > RETURN                                                   null

End of function offsetexists

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

End of function offsetunset

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

End of function toarray

End of class DefaultMap.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.98 ms | 1405 KiB | 15 Q