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 { } class SimpleObject { private $test; public function __construct(array $array) { $this->test = $array['test']; } } $inputArray = array('test' => 'value1'); $stdClassObject = (object)$inputArray; $simpleObject = new SimpleObject($inputArray); $arrayObject = new ArrayObject($inputArray); $arrayObjectSubclass = new ArrayObjectSubClass($inputArray); $arrayAccess = new ArrayAccessImplementer($inputArray); echo 'stdClass: '; var_export((array)$stdClassObject); echo PHP_EOL, 'SimpleObject: '; var_export((array)$simpleObject); echo PHP_EOL, 'ArrayObject: '; var_export((array)$arrayObject); echo PHP_EOL, 'ArrayObjectSubclass: '; var_export((array)$arrayObjectSubclass); echo PHP_EOL, 'ArrayAccess: '; var_export((array)$arrayAccess);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ti4aY
function name:  (null)
number of ops:  50
compiled vars:  !0 = $inputArray, !1 = $stdClassObject, !2 = $simpleObject, !3 = $arrayObject, !4 = $arrayObjectSubclass, !5 = $arrayAccess
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'arrayaccessimplementer'
   46     1        ASSIGN                                                   !0, <array>
   47     2        CAST                                          8  ~7      !0
          3        ASSIGN                                                   !1, ~7
   48     4        NEW                                              $9      'SimpleObject'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !2, $9
   49     8        NEW                                              $12     'ArrayObject'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !3, $12
   50    12        NEW                                              $15     'ArrayObjectSubClass'
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !4, $15
   51    16        NEW                                              $18     'ArrayAccessImplementer'
         17        SEND_VAR_EX                                              !0
         18        DO_FCALL                                      0          
         19        ASSIGN                                                   !5, $18
   53    20        ECHO                                                     'stdClass%3A+'
   54    21        INIT_FCALL                                               'var_export'
         22        CAST                                          7  ~21     !1
         23        SEND_VAL                                                 ~21
         24        DO_ICALL                                                 
   55    25        ECHO                                                     '%0A'
         26        ECHO                                                     'SimpleObject%3A+'
   56    27        INIT_FCALL                                               'var_export'
         28        CAST                                          7  ~23     !2
         29        SEND_VAL                                                 ~23
         30        DO_ICALL                                                 
   57    31        ECHO                                                     '%0A'
         32        ECHO                                                     'ArrayObject%3A+'
   58    33        INIT_FCALL                                               'var_export'
         34        CAST                                          7  ~25     !3
         35        SEND_VAL                                                 ~25
         36        DO_ICALL                                                 
   59    37        ECHO                                                     '%0A'
         38        ECHO                                                     'ArrayObjectSubclass%3A+'
   60    39        INIT_FCALL                                               'var_export'
         40        CAST                                          7  ~27     !4
         41        SEND_VAL                                                 ~27
         42        DO_ICALL                                                 
   61    43        ECHO                                                     '%0A'
         44        ECHO                                                     'ArrayAccess%3A+'
   62    45        INIT_FCALL                                               'var_export'
         46        CAST                                          7  ~29     !5
         47        SEND_VAL                                                 ~29
         48        DO_ICALL                                                 
         49      > RETURN                                                   1

Class ArrayAccessImplementer:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ti4aY
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/ti4aY
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/ti4aY
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/ti4aY
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/ti4aY
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]
Class SimpleObject:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ti4aY
function name:  __construct
number of ops:  5
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   RECV                                             !0      
   42     1        FETCH_DIM_R                                      ~2      !0, 'test'
          2        ASSIGN_OBJ                                               'test'
          3        OP_DATA                                                  ~2
   43     4      > RETURN                                                   null

End of function __construct

End of class SimpleObject.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.13 ms | 1404 KiB | 15 Q