3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ArrayAccessImplementer implements ArrayAccess { private $array; public function __construct(array $array) { $this->array = $array; } public function offsetExists($offset) { return array_key_exists($this->array, $offset); } public function offsetSet($offset, $value) { $this->array[$offset] = $value; } public function offsetGet($offset) { return $this->array[$offset]; } public function offsetUnset($offset) { unset($this->array[$offset]); } } class ArrayObjectSubClass extends ArrayObject { } $arrayObject = new ArrayObject(array('test' => 'value1')); $arrayObjectCastedToArray = (array)$arrayObject; $arrayObjectSubclass = new ArrayObjectSubClass((array('test' => 'value1'))); $arrayObjectSubclassCastedToArray = (array) $arrayObjectSubclass; $arrayAccess = new ArrayAccessImplementer(array('test' => 'value1')); $arrayAccessCastedToArray = (array)$arrayAccess; $simpleObject = new stdClass(); $simpleObject->test = 'value1'; var_export((array)$simpleObject); var_export($arrayObjectCastedToArray); var_export($arrayObjectSubclassCastedToArray); var_export($arrayAccessCastedToArray);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a9MIr
function name:  (null)
number of ops:  38
compiled vars:  !0 = $arrayObject, !1 = $arrayObjectCastedToArray, !2 = $arrayObjectSubclass, !3 = $arrayObjectSubclassCastedToArray, !4 = $arrayAccess, !5 = $arrayAccessCastedToArray, !6 = $simpleObject
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'arrayaccessimplementer'
   36     1        NEW                                              $7      'ArrayObject'
          2        SEND_VAL_EX                                              <array>
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $7
   37     5        CAST                                          7  ~10     !0
          6        ASSIGN                                                   !1, ~10
   39     7        NEW                                              $12     'ArrayObjectSubClass'
          8        SEND_VAL_EX                                              <array>
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $12
   40    11        CAST                                          7  ~15     !2
         12        ASSIGN                                                   !3, ~15
   42    13        NEW                                              $17     'ArrayAccessImplementer'
         14        SEND_VAL_EX                                              <array>
         15        DO_FCALL                                      0          
         16        ASSIGN                                                   !4, $17
   43    17        CAST                                          7  ~20     !4
         18        ASSIGN                                                   !5, ~20
   45    19        NEW                                              $22     'stdClass'
         20        DO_FCALL                                      0          
         21        ASSIGN                                                   !6, $22
   46    22        ASSIGN_OBJ                                               !6, 'test'
         23        OP_DATA                                                  'value1'
   48    24        INIT_FCALL                                               'var_export'
         25        CAST                                          7  ~26     !6
         26        SEND_VAL                                                 ~26
         27        DO_ICALL                                                 
   49    28        INIT_FCALL                                               'var_export'
         29        SEND_VAR                                                 !1
         30        DO_ICALL                                                 
   50    31        INIT_FCALL                                               'var_export'
         32        SEND_VAR                                                 !3
         33        DO_ICALL                                                 
   51    34        INIT_FCALL                                               'var_export'
         35        SEND_VAR                                                 !5
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Class ArrayAccessImplementer:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a9MIr
function name:  __construct
number of ops:  4
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        ASSIGN_OBJ                                               'array'
          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/a9MIr
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      'array'
          2        ARRAY_KEY_EXISTS                                 ~2      ~1, !0
          3      > RETURN                                                   ~2
   15     4*     > 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/a9MIr
function name:  offsetSet
number of ops:  6
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2        FETCH_OBJ_W                                      $2      'array'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   20     5      > RETURN                                                   null

End of function offsetset

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

End of function offsetget

Function offsetunset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a9MIr
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      
   29     1        FETCH_OBJ_UNSET                                  $1      'array'
          2        UNSET_DIM                                                $1, !0
   30     3      > RETURN                                                   null

End of function offsetunset

End of class ArrayAccessImplementer.

Class ArrayObjectSubClass: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.48 ms | 1404 KiB | 15 Q