3v4l.org

run code in 500+ PHP versions simultaneously
<?php error_reporting(E_ALL); class MyArray implements ArrayAccess { public $value; public function __construct($value = null) { $this->value = $value; } public function &offsetGet($offset) { var_dump(__METHOD__); if (!isset($this->value[$offset])) { throw new Exception('Undefined index: ' . $offset); } return $this->value[$offset]; } public function offsetExists($offset) { var_dump(__METHOD__); return isset($this->value[$offset]); } public function offsetSet($offset, $value) { var_dump(__METHOD__); $this->value[$offset] = $value; } public function offsetUnset($offset) { var_dump(__METHOD__); $this->value[$offset] = null; } } $record = new MyArray([ 'foo' => [ 'bar' => 'baz' ] ]); var_dump(isset($record['foo']['bar'])); var_dump(isset($record['hello']['world']));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7C2Fs
function name:  (null)
number of ops:  19
compiled vars:  !0 = $record
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                                   'error_reporting'
          1        SEND_VAL                                                     30719
          2        DO_ICALL                                                     
    5     3        DECLARE_CLASS                                                'myarray'
   47     4        NEW                                                  $2      'MyArray'
   49     5        SEND_VAL_EX                                                  <array>
   47     6        DO_FCALL                                          0          
          7        ASSIGN                                                       !0, $2
   53     8        INIT_FCALL                                                   'var_dump'
          9        FETCH_DIM_IS                                         ~5      !0, 'foo'
         10        ISSET_ISEMPTY_DIM_OBJ                             0  ~6      ~5, 'bar'
         11        SEND_VAL                                                     ~6
         12        DO_ICALL                                                     
   54    13        INIT_FCALL                                                   'var_dump'
         14        FETCH_DIM_IS                                         ~8      !0, 'hello'
         15        ISSET_ISEMPTY_DIM_OBJ                             0  ~9      ~8, 'world'
         16        SEND_VAL                                                     ~9
         17        DO_ICALL                                                     
         18      > RETURN                                                       1

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

End of function __construct

Function offsetget:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 13
Return found
filename:       /in/7C2Fs
function name:  offsetGet
number of ops:  17
compiled vars:  !0 = $offset
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
   16     1        INIT_FCALL                                                   'var_dump'
          2        SEND_VAL                                                     'MyArray%3A%3AoffsetGet'
          3        DO_ICALL                                                     
   18     4        FETCH_OBJ_IS                                         ~2      'value'
          5        ISSET_ISEMPTY_DIM_OBJ                             0  ~3      ~2, !0
          6        BOOL_NOT                                             ~4      ~3
          7      > JMPZ                                                         ~4, ->13
   19     8    >   NEW                                                  $5      'Exception'
          9        CONCAT                                               ~6      'Undefined+index%3A+', !0
         10        SEND_VAL_EX                                                  ~6
         11        DO_FCALL                                          0          
         12      > THROW                                             0          $5
   22    13    >   FETCH_OBJ_W                                          $8      'value'
         14        FETCH_DIM_W                                          $9      $8, !0
         15      > RETURN_BY_REF                                                $9
   23    16*     > RETURN_BY_REF                                                null

End of function offsetget

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7C2Fs
function name:  offsetExists
number of ops:  8
compiled vars:  !0 = $offset
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   25     0  E >   RECV                                                 !0      
   27     1        INIT_FCALL                                                   'var_dump'
          2        SEND_VAL                                                     'MyArray%3A%3AoffsetExists'
          3        DO_ICALL                                                     
   29     4        FETCH_OBJ_IS                                         ~2      'value'
          5        ISSET_ISEMPTY_DIM_OBJ                             0  ~3      ~2, !0
          6      > RETURN                                                       ~3
   30     7*     > 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/7C2Fs
function name:  offsetSet
number of ops:  9
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   32     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   34     2        INIT_FCALL                                                   'var_dump'
          3        SEND_VAL                                                     'MyArray%3A%3AoffsetSet'
          4        DO_ICALL                                                     
   36     5        FETCH_OBJ_W                                          $3      'value'
          6        ASSIGN_DIM                                                   $3, !0
          7        OP_DATA                                                      !1
   37     8      > 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/7C2Fs
function name:  offsetUnset
number of ops:  8
compiled vars:  !0 = $offset
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   39     0  E >   RECV                                                 !0      
   41     1        INIT_FCALL                                                   'var_dump'
          2        SEND_VAL                                                     'MyArray%3A%3AoffsetUnset'
          3        DO_ICALL                                                     
   43     4        FETCH_OBJ_W                                          $2      'value'
          5        ASSIGN_DIM                                                   $2, !0
          6        OP_DATA                                                      null
   44     7      > RETURN                                                       null

End of function offsetunset

End of class MyArray.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
170.1 ms | 2770 KiB | 15 Q