3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyArrayAccess implements \ArrayAccess { public function offsetExists($offset) { } public function offsetSet($offset, $value) { } public function offsetGet($offset) { } public function offsetUnset($offset) { } } function test(array $arr) { } function test2(\ArrayAccess $arr) { } $arrObj = new MyArrayAccess(); test([]); //result: works! test($arrObj); //result: does NOT work test2([]); //result: does NOT work test2($arrObj); // result: works!
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KXthb
function name:  (null)
number of ops:  17
compiled vars:  !0 = $arrObj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'myarrayaccess'
   37     1        NEW                                              $1      'MyArrayAccess'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   38     4        INIT_FCALL                                               'test'
          5        SEND_VAL                                                 <array>
          6        DO_FCALL                                      0          
   39     7        INIT_FCALL                                               'test'
          8        SEND_VAR                                                 !0
          9        DO_FCALL                                      0          
   40    10        INIT_FCALL                                               'test2'
         11        SEND_VAL                                                 <array>
         12        DO_FCALL                                      0          
   41    13        INIT_FCALL                                               'test2'
         14        SEND_VAR                                                 !0
         15        DO_FCALL                                      0          
         16      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KXthb
function name:  test
number of ops:  2
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   29     1      > RETURN                                                   null

End of function test

Function test2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KXthb
function name:  test2
number of ops:  2
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
   34     1      > RETURN                                                   null

End of function test2

Class MyArrayAccess:
Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KXthb
function name:  offsetExists
number of ops:  2
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    8     1      > 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/KXthb
function name:  offsetSet
number of ops:  3
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   13     2      > 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/KXthb
function name:  offsetGet
number of ops:  2
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   18     1      > 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/KXthb
function name:  offsetUnset
number of ops:  2
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   23     1      > RETURN                                                   null

End of function offsetunset

End of class MyArrayAccess.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.83 ms | 1403 KiB | 17 Q