3v4l.org

run code in 300+ PHP versions simultaneously
<?php class C implements ArrayAccess { public $data = array( "foo"=>"bar" ); public function offsetExists ( $offset ): bool{ return array_key_exists((string)$offset,$this->data); } public function offsetGet ( $offset ){ return $this->data[$offset]; } public function offsetSet ( $offset , $value ): void { $this->data[$offset]=$value; } public function offsetUnset ( $offset ): void { unset($this->data[$offset]); } } $o=new C(); if(array_key_exists('foo',$o)){ echo "ArrayAccess seems to work"; }else{ echo "ArrayAccess seems broken"; }
based on TcNR4
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
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/Woc0R
function name:  (null)
number of ops:  10
compiled vars:  !0 = $o
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   ADD_INTERFACE                                            'c'
  22     1        NEW                                              $1      :15
         2        DO_FCALL                                      0          
         3        ASSIGN                                                   !0, $1
  24     4        ARRAY_KEY_EXISTS                                 ~4      'foo', !0
         5      > JMPZ                                                     ~4, ->8
  25     6    >   ECHO                                                     'ArrayAccess+seems+to+work'
         7      > JMP                                                      ->9
  27     8    >   ECHO                                                     'ArrayAccess+seems+broken'
  28     9    > > RETURN                                                   1

Class C:
Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Woc0R
function name:  offsetExists
number of ops:  8
compiled vars:  !0 = $offset
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   7     0  E >   RECV                                             !0      
   8     1        MAKE_REF                                         ~1      !0
         2        FETCH_OBJ_R                                      ~2      'data'
         3        ARRAY_KEY_EXISTS                                 ~3      ~1, ~2
         4        VERIFY_RETURN_TYPE                                       ~3
         5      > RETURN                                                   ~3
   9     6*       VERIFY_RETURN_TYPE                                       
         7*     > 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/Woc0R
function name:  offsetGet
number of ops:  5
compiled vars:  !0 = $offset
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  10     0  E >   RECV                                             !0      
  11     1        FETCH_OBJ_R                                      ~1      'data'
         2        FETCH_DIM_R                                      ~2      ~1, !0
         3      > RETURN                                                   ~2
  12     4*     > RETURN                                                   null

End of function offsetget

Function offsetset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Woc0R
function name:  offsetSet
number of ops:  6
compiled vars:  !0 = $offset, !1 = $value
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  13     0  E >   RECV                                             !0      
         1        RECV                                             !1      
  14     2        FETCH_OBJ_W                                      $2      'data'
         3        ASSIGN_DIM                                               $2, !0
         4        OP_DATA                                                  !1
  15     5      > 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/Woc0R
function name:  offsetUnset
number of ops:  4
compiled vars:  !0 = $offset
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  16     0  E >   RECV                                             !0      
  17     1        FETCH_OBJ_UNSET                                  $1      'data'
         2        UNSET_DIM                                                $1, !0
  18     3      > RETURN                                                   null

End of function offsetunset

End of class C.

Generated using Vulcan Logic Dumper, using php 7.4.0