3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Collection implements ArrayAccess { protected $items = []; public function __construct(array $items) { $this->items = $items; } public function offsetExists($offset) { return array_key_exists($offset, $this->items); } public function offsetGet($offset) { return $this->items[$offset]; } public function offsetSet($key, $value) { if (is_null($key)) { $this->items[] = $value; } else { $this->items[$key] = $value; } } public function offsetUnset($key) { unset($this->items[$key]); } } $arr = ['a' => null]; $coll = new Collection($arr); var_dump(isset($arr['a']), isset($coll['a']));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7Um54
function name:  (null)
number of ops:  13
compiled vars:  !0 = $arr, !1 = $coll
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'collection'
   37     1        ASSIGN                                                   !0, <array>
   38     2        NEW                                              $3      'Collection'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $3
   40     6        INIT_FCALL                                               'var_dump'
          7        ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !0, 'a'
          8        SEND_VAL                                                 ~6
          9        ISSET_ISEMPTY_DIM_OBJ                         0  ~7      !1, 'a'
         10        SEND_VAL                                                 ~7
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

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

End of function __construct

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7Um54
function name:  offsetExists
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        FETCH_OBJ_R                                      ~1      'items'
          2        ARRAY_KEY_EXISTS                                 ~2      !0, ~1
          3      > RETURN                                                   ~2
   15     4*     > RETURN                                                   null

End of function offsetexists

Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7Um54
function name:  offsetGet
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        FETCH_OBJ_R                                      ~1      'items'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3      > RETURN                                                   ~2
   20     4*     > RETURN                                                   null

End of function offsetget

Function offsetset:
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 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7Um54
function name:  offsetSet
number of ops:  12
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   24     2        TYPE_CHECK                                    2          !0
          3      > JMPZ                                                     ~2, ->8
   25     4    >   FETCH_OBJ_W                                      $3      'items'
          5        ASSIGN_DIM                                               $3
          6        OP_DATA                                                  !1
   24     7      > JMP                                                      ->11
   27     8    >   FETCH_OBJ_W                                      $5      'items'
          9        ASSIGN_DIM                                               $5, !0
         10        OP_DATA                                                  !1
   29    11    > > RETURN                                                   null

End of function offsetset

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

End of function offsetunset

End of class Collection.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.31 ms | 1018 KiB | 14 Q