3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ArrayAccessObject implements ArrayAccess { public function offsetSet($offset, $value){} public function offsetUnset($offset){} public function offsetExists($offset){} public function offsetGet($offset){ echo gettype($offset) . "\n"; } } $array = ['a', 'b', 'c']; $object = new ArrayAccessObject(); $string = '1'; $object[1]; // 'integer' $object['1']; // 'integer' <-- should be string $object[1.0]; // 'double' $object[0x00]; // 'double' $object[true]; // 'boolean' $object[$string]; // 'string' $object[$object]; // 'object' $object[$array]; // 'array'
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SoSBT
function name:  (null)
number of ops:  23
compiled vars:  !0 = $array, !1 = $object, !2 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'arrayaccessobject'
   14     1        ASSIGN                                                   !0, <array>
   15     2        NEW                                              $4      'ArrayAccessObject'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $4
   16     5        ASSIGN                                                   !2, '1'
   18     6        FETCH_DIM_R                                      ~8      !1, 1
          7        FREE                                                     ~8
   19     8        FETCH_DIM_R                                      ~9      !1, 1
          9        FREE                                                     ~9
   20    10        FETCH_DIM_R                                      ~10     !1, 1
         11        FREE                                                     ~10
   21    12        FETCH_DIM_R                                      ~11     !1, 0
         13        FREE                                                     ~11
   22    14        FETCH_DIM_R                                      ~12     !1, <true>
         15        FREE                                                     ~12
   23    16        FETCH_DIM_R                                      ~13     !1, !2
         17        FREE                                                     ~13
   24    18        FETCH_DIM_R                                      ~14     !1, !1
         19        FREE                                                     ~14
   25    20        FETCH_DIM_R                                      ~15     !1, !0
         21        FREE                                                     ~15
         22      > RETURN                                                   1

Class ArrayAccessObject:
Function offsetset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SoSBT
function name:  offsetSet
number of ops:  3
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2      > 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/SoSBT
function name:  offsetUnset
number of ops:  2
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function offsetunset

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SoSBT
function name:  offsetExists
number of ops:  2
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1      > 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/SoSBT
function name:  offsetGet
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        GET_TYPE                                         ~1      !0
          2        CONCAT                                           ~2      ~1, '%0A'
          3        ECHO                                                     ~2
   11     4      > RETURN                                                   null

End of function offsetget

End of class ArrayAccessObject.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.13 ms | 1399 KiB | 13 Q