3v4l.org

run code in 500+ PHP versions simultaneously
<?php error_reporting(-1); class obj implements ArrayAccess { private $container = array(); public function __construct() { $this->container = array( "one" => 1, "two" => 2, "three" => 3, ); } public function offsetSet($offset, $value) { if (is_null($offset)) { $this->container[] = $value; } else { $this->container[$offset] = $value; } } public function offsetExists($offset) { return isset($this->container[$offset]); } public function offsetUnset($offset) { unset($this->container[$offset]); } public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; } } $obj = new obj; var_dump(isset($obj["two"])); var_dump($obj["two"]); unset($obj["two"]); var_dump(isset($obj["two"])); $obj["two"] = "A value"; var_dump($obj["two"]); $obj[] = 'Append 1'; $obj[] = 'Append 2'; $obj[] = 'Append 3'; $obj[][0] = 'Append 4';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uMrcs
function name:  (null)
number of ops:  36
compiled vars:  !0 = $obj
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                                   'error_reporting'
          1        SEND_VAL                                                     -1
          2        DO_ICALL                                                     
    4     3        DECLARE_CLASS                                                'obj'
   36     4        NEW                                                  $2      'obj'
          5        DO_FCALL                                          0          
          6        ASSIGN                                                       !0, $2
   38     7        INIT_FCALL                                                   'var_dump'
          8        ISSET_ISEMPTY_DIM_OBJ                             0  ~5      !0, 'two'
          9        SEND_VAL                                                     ~5
         10        DO_ICALL                                                     
   39    11        INIT_FCALL                                                   'var_dump'
         12        FETCH_DIM_R                                          ~7      !0, 'two'
         13        SEND_VAL                                                     ~7
         14        DO_ICALL                                                     
   40    15        UNSET_DIM                                                    !0, 'two'
   41    16        INIT_FCALL                                                   'var_dump'
         17        ISSET_ISEMPTY_DIM_OBJ                             0  ~9      !0, 'two'
         18        SEND_VAL                                                     ~9
         19        DO_ICALL                                                     
   42    20        ASSIGN_DIM                                                   !0, 'two'
         21        OP_DATA                                                      'A+value'
   43    22        INIT_FCALL                                                   'var_dump'
         23        FETCH_DIM_R                                          ~12     !0, 'two'
         24        SEND_VAL                                                     ~12
         25        DO_ICALL                                                     
   44    26        ASSIGN_DIM                                                   !0
         27        OP_DATA                                                      'Append+1'
   45    28        ASSIGN_DIM                                                   !0
         29        OP_DATA                                                      'Append+2'
   46    30        ASSIGN_DIM                                                   !0
         31        OP_DATA                                                      'Append+3'
   47    32        FETCH_DIM_W                                          $17     !0
         33        ASSIGN_DIM                                                   $17, 0
         34        OP_DATA                                                      'Append+4'
         35      > RETURN                                                       1

Class obj:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uMrcs
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   ASSIGN_OBJ                                                   'container'
    9     1        OP_DATA                                                      <array>
   13     2      > RETURN                                                       null

End of function __construct

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/uMrcs
function name:  offsetSet
number of ops:  12
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   16     2        TYPE_CHECK                                        2          !0
          3      > JMPZ                                                         ~2, ->8
   17     4    >   FETCH_OBJ_W                                          $3      'container'
          5        ASSIGN_DIM                                                   $3
          6        OP_DATA                                                      !1
   16     7      > JMP                                                          ->11
   19     8    >   FETCH_OBJ_W                                          $5      'container'
          9        ASSIGN_DIM                                                   $5, !0
         10        OP_DATA                                                      !1
   21    11    > > 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/uMrcs
function name:  offsetExists
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   23     0  E >   RECV                                                 !0      
   24     1        FETCH_OBJ_IS                                         ~1      'container'
          2        ISSET_ISEMPTY_DIM_OBJ                             0  ~2      ~1, !0
          3      > RETURN                                                       ~2
   25     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/uMrcs
function name:  offsetUnset
number of ops:  4
compiled vars:  !0 = $offset
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   27     0  E >   RECV                                                 !0      
   28     1        FETCH_OBJ_UNSET                                      $1      'container'
          2        UNSET_DIM                                                    $1, !0
   29     3      > RETURN                                                       null

End of function offsetunset

Function offsetget:
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/uMrcs
function name:  offsetGet
number of ops:  11
compiled vars:  !0 = $offset
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   31     0  E >   RECV                                                 !0      
   32     1        FETCH_OBJ_IS                                         ~1      'container'
          2        ISSET_ISEMPTY_DIM_OBJ                             0          ~1, !0
          3      > JMPZ                                                         ~2, ->8
          4    >   FETCH_OBJ_R                                          ~3      'container'
          5        FETCH_DIM_R                                          ~4      ~3, !0
          6        QM_ASSIGN                                            ~5      ~4
          7      > JMP                                                          ->9
          8    >   QM_ASSIGN                                            ~5      null
          9    > > RETURN                                                       ~5
   33    10*     > RETURN                                                       null

End of function offsetget

End of class obj.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
162.53 ms | 2888 KiB | 15 Q